Asterisk/FreePBX Blind Transfer Return Call to Origin

Another customer of ours requested this feature. By default, with blind transfers if the internal destination doesn’t answer the call, it goes to vociemail or terminates if vociemail is not configured. This customer wanted to return the call to the originator so that they can direct the call elsewhere.

You need to modify two places. They’re listed below.

globals_custom.conf:
TRANSFER_CONTEXT = custom-test_transfer

extensions_custom.conf:
[custom-test_transfer]
exten => _X.,1,NOOP(entering custom-test_transfer)
exten => _X.,n,set(timeoutd=25) ; set timeout in seconds
exten => _X.,n,set(extLeng=${LEN(${EXTEN})})
exten => _X.,n,noop(the extenlength is ${extLeng})
exten => _x.,n,dial(local/${EXTEN}@from-internal,${timeoutd})
exten => _X.,n,Gotoif($[“$\{DIALSTATUS}”=”ANSWER”]?hangup,callback)
exten => _X.,n,Set(CALLERID(name)=RB:${CALLERID(name)})
exten => _X.,n(callback),dial(local/${BLINDTRANSFER:4:${extLeng}}@from-internal)
exten => _X.,n(hangup),hangup()
exten => _*X.,1,dial(local/${EXTEN}@from-internal,15)
exten => _*X.,n,hangup()

Thanks to Alexander for fixing my earlier code. I am yet to test this on a live site 🙂

extensions_custom.conf:
[custom-test_transfer]
exten => _X.,1,NoOp(Entering custom-test_transfer)
exten => _X.,n,Set(timeoutd=25) ; set timeout in seconds
exten => _X.,n,Set(extLeng=${LEN(${EXTEN})})
exten => _X.,n,NoOp(The extenlength is ${extLeng})
exten => _X.,n,Dial(Local/${EXTEN}@from-internal,${timeoutd})
exten => _X.,n,Set(CALLERID(name)=RB:${CALLERID(name)})
exten => _X.,n,Dial(Local/${BLINDTRANSFER:4:${extLeng}}@from-internal)
exten => _X.,n,Hangup()

Once setup, reload asterisk and test this out.

There are several other scripts out there, but this is the one that worked correctly for me.

6 thoughts on “Asterisk/FreePBX Blind Transfer Return Call to Origin”

  1. Hi asanka,

    This method doesn’t work for me. Wich version of freepbx do you use? I’m trying to do this with FreePBX 2.11.

    Regards.

  2. If you don’t provide a “g” option to your Dial application, Asterisk will stop processing dialplan after a successful call, so checking for DIALPLAN to be equal to “ANSWER” is useless here.

    The code you provided needs to be fixed, it’s nonworking atm.

  3. Here, I fixed your context – removed all unreachable and useless code, fixed the extension cases and tidied the application names:

    globals_custom.conf:
    TRANSFER_CONTEXT = custom-test_transfer

    extensions_custom.conf:
    [custom-test_transfer]
    exten => _X.,1,NoOp(Entering custom-test_transfer)
    exten => _X.,n,Set(timeoutd=25) ; set timeout in seconds
    exten => _X.,n,Set(extLeng=${LEN(${EXTEN})})
    exten => _X.,n,NoOp(The extenlength is ${extLeng})
    exten => _X.,n,Dial(Local/${EXTEN}@from-internal,${timeoutd})
    exten => _X.,n,Set(CALLERID(name)=RB:${CALLERID(name)})
    exten => _X.,n,Dial(Local/${BLINDTRANSFER:4:${extLeng}}@from-internal)
    exten => _X.,n,Hangup()

Leave a Reply

Your email address will not be published. Required fields are marked *