Can you send a call transfer to an outgoing call in Asterisk?

Hello everyone.
I want to know if it is possible to make a call transfer when making an outgoing call.

The scenario is:

User-A (softphone) dials Asterisk-A, Asterisk-A passes the call to Asterisk-B to route it to user-B. When user-A hangs up Asterisk-A sends a REFER for Asterisk-B to transfer the call to user-C and Asterisk-A disconnects.

At the moment I have tried to handle the hang up and send a transfer over the channel between Asterisk-A and Asterisk-B but the REFER message to Asterisk-B does not go out.

Dialplan:
exten = _X.,1,NoOp()
same => n,Dial(SIP/3.89.177.141/7001,Ttgb(test^callee_handler^1))
same => n,Hangup()

exten => callee_handler,1,NoOp()
same => n,Set(CHANNEL(hangup_handler_push)=test,hangup_handler_B,1)
same => n,Return()

exten => hangup_handler_B,1,NoOp()
same => n,Transfer(SIP/XXX)
same => n,Return()

Hangup handler is too late. You want the Dial application to use the option that does a GoTo on the B side when the a side hangs up. I think it is F, from another recent question, but look it up to be sure.

Note that you should be redesigning to use chan_pjsip, and that XXX needs to be in the form of a full SIP URI.

With your current code, the SIP sesson has already been terminated on the B side.

2 Likes

Thank you very much @david551, it worked

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.