Custom IVR for Dialing External Number by Key Events


Customers want to dial caller in IVR can be forwarded to an a external number by IVR key event. For example, press 1 to a external mobile number 1384561932.

Note: with the following custom IVR dialplan, the change on the web interface will take effect. System will only follow the customized dialplan.


Firstly make sure the you have created an outbound route for the external number, and with the proper dial pattern. This route can be exclusive for the external number dialing from IVR key event or not. We recommend create a exclusive one, and remember its outbound route name like the figure: To126


How to Create the Custom IVR

We take IVR number 679 and external number 6000 as example.

  1. Login MyPBX via SSH
  2. Edit the configuration file extensions.conf.
  3. Search IVR 679 by typing “/679” on your keyboard. If the first result is not the one you want, type "n" to find the next one until you find it.
  4. You will find the rule of IVR 679 as below.
  5. Copy the calling rule.
    On putty, you should hold left click and drag the area of the code to copy them.
  6. Press the Esc key to exit the modified mode. Type ":q!" to quit and not save this configuration file.
  7. Create a custom configuration file under path: /persistent/custom-cfg/ 
    Enter command ” vi /persistent/custom-cfg/extensions_custom.conf ” to creat a new custom file.
  8. Paste the rule you’d copied by right click from the green cursor. If you don’t like the mouse operation of copy and paste action, you could type the code of the rule as you like.
  9. Add a rule “ exten = 1,1,Goto(CallingRule_To126,6000,1) ”, if you can’t edit or input any word, you could enter “ i ” to swap to Modified mode.
  10. Press to Esc key to exit and swap to Command mode. Enter “:wq” to save and quit the custom file.
  11. Then enter command “ mypbxconf ”&” asterisk –rx ”module reload” ” to reload all configuration files. Or simply apply any changes on the web or reboot MyPBX to take effect.
  12. Finally check the whether the new is generated or not. Enter “ vi etc/asterisk/extension.conf ” and find the IVR 679.

    Explanation of the Added Rule

    exten = 1,1,Goto(CallingRule_To126,6000,1)
    1: means the key you press(key event)
    To126: is the name of the outbound route
    6000: if you press key 1 in IVR, MyPBX will send 6000 to the outbound route “To126”. It means the number you fill here should match the dial pattern of Outbound route“To126”. You could replace the number as required.

    If you need more exteral number dialing, no matter from same outbound route or different outbound route. you could do like this:

    exten = 679,1,NoOp(679)
    exten = 679,n,Set(CDR(orgdst)=679)
    exten = 679,n,Background(record/default)
    exten = 679,n,WaitExten(3)
    exten = 679,n,Background(record/default)
    exten = 679,n,WaitExten(3)
    exten = 679,n,Background(record/default)
    exten = 679,n,WaitExten(3)
    exten = 1,1,Goto(CallingRule_To126,6000,1)
    exten = 2,1,Goto(CallingRule_To126,7000,1)
    exten = 3,1,Goto(CallingRule_To127,8000,1)

    exten = 9,1,Goto(CallingRule_To128,9000,1)
    exten = t,1,NoOp(do..)
    exten = i,1,NoOp(do..)
    include = from-outside
    include = conferences
    include = vmm
    exten = fax,1,Goto(detect-fax-to-email,s,1)

  13. Dail to IVR 679 to test.

How to Delete the Custom File

If you don’t need the custom rule any more. Enter command “ cd /persistent/custom-cfg ”& “ rm extensions_custom.conf

Have more questions? Submit a request


  • 0

    If you are worry about that you are not good at Linux.
    Here is another solution for transfer the call to outside when someone press key event in IVR.
    for example, I wanna dial 1 in IVR to external number 1005 in this scenario

    1. create an outbound route for external call (go to PBX>Outbound Route>Add)

    Note: Make sure the trunk you choose is available.

    2. choose an extension as the destination of IVR key event

    3. set transfer number on the extension 302

    4. After the configuration above, when someone call IVR, then dial 1, the call will be route to 61005 (prefix+external number)

Please sign in to leave a comment.