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.

Comments

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

  1. Foplui Avatar
    Foplui

    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. Alexander Avatar
    Alexander

    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.

    1. Alexander Avatar
      Alexander

      *I meant DIALSTATUS, not DIALPLAN.

  3. Alexander Avatar
    Alexander

    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()

    1. Aurelio Avatar
      Aurelio

      Great script! But it works only for SIP to SIP Blind Transfer. I have FXS too. How can I solve this?

  4. Kalde Avatar
    Kalde

    Good!

    Does anyone tried on FreePBX15?

Leave a Reply

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