Issue Transfer() command to provider mid-call

Running Asterisk 11.7

I have a situation where I need to issue a SIP REFER, using the Transfer() command to a provider after the call has been bridged to an internal extension. This REFER will be utilized to redirect the incoming call channel to a conference bridge at the provider and conference in a 3rd party. So after the REFER is issued, the two channels need to remain bridged together. The bridge server sits in the cloud and Asterisk does not have access to make outbound calls through this provider so we don’t have the option of having Asterisk conference the 3 endpoints together.

More detail:
-Provider (channel A) initiates call to Asterisk
-Call is sent to Channel B and the two channels are bridged together
-The two parties converse
-Extension requests Asterisk to issue the Transfer command on Channel A (method tbd)
-Asterisk issues REFER to provider on Channel A
-Provider Reinvites Channel A to the conference bridge and conferences in a 3rd party
-Channel A and Channel B either remain bridged or are re-bridged after the REFER is completed (regardless of result).

The issue I’m running into is how to get Channel A to execute the Transfer() command while it is bridged to Channel B? I’ve contemplated issuing a dual redirect through AMI. Channel B will just execute a “wait” command. Channel A will execute the Transfer() command and, on completion, execute a Bridge command to bridge it back to Channel B. However, I’m wondering if there is a better/easier/cleaner way to accomplish this.

Any help is appreciated.

I’m pretty sure you want to do an attended transfer, which is not something that standard Asterisk supports.

Thanks David55. For this specific situation, the REFER does not have to utilize REPLACES and after looking at it, I’m pretty confident the Transfer() command will supply what I need if I can just figure out how to get it to work and keep the channels bridged at the end.

I do have to utilize REPLACES for some future work. But I’ll cross that hurdle when I get to it.

Might be showing my ignorance here, but does anyone know if it is possible to inject the REFER into the SIP stream using a proxy, such as Kamilio, ahead of Asterisk? I’ve not worked with any of the proxies at all.

The normal expectation would be that the provider would issue BYE on completion of the transfer, so you wouldn’t be able to maintain the original call as bridged.

If they don’t, you might get away with it in in Asterisk, but you would be in an area of the code that is fragile at the best of times.

You can use G on Dial with one leg going to Transfer then to Bridge, and the other leg going to Wait, but you are are on your own as to whether Asterisk can really cope with a REFER that doesn’t close the original leg.