Thursday, September 15, 2016

Customizing FreePBX dialplans

Want to modify the existing code that FreePBX generates slightly for your own and not have it get overwritten every time you update the GUI?  Here's how.

First, find the code that you want to alter

In the example below, I wanted to customize the code that asterisk used when asking for a pin# when someone dials the phone.

So I found the code I wanted to change in: extensions_additional.com

[outrt-11] ; PSTN_PIN
include => outrt-11-custom
exten => _6666X.,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _6666X.,n(pinsets),Macro(pinsets,1,1)
exten => _6666X.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _6666X.,n,Set(_NODEST=)
exten => _6666X.,n,Gosub(sub-record-check,s,1(out,${EXTEN},))
exten => _6666X.,n,Macro(dialout-trunk,2,${EXTEN:4},,off)
exten => _6666X.,n,Macro(outisbusy,)

Copy that code and then paste it in: extensions_override_freepbx.conf

Now alter the file as you need.  You'll see I've added a "NoOp" line to echo a message into the live log.  Remember, don't alter the ["HEADING"], leave as is.

[outrt-11] ; PSTN_PIN
include => outrt-11-custom
exten => _6666X.,1,Macro(user-callerid,LIMIT,EXTERNAL,)
exten => _6666X.,n,NoOp( THIS IS THE ALTERED CODE!!!!!!!!!!!!!! )
exten => _6666X.,n(pinsets),Macro(pinsets,1,1)
exten => _6666X.,n,Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})})
exten => _6666X.,n,Set(_NODEST=)
exten => _6666X.,n,Gosub(sub-record-check,s,1(out,${EXTEN},))
exten => _6666X.,n,Macro(dialout-trunk,2,${EXTEN:4},,off)
exten => _6666X.,n,Macro(outisbusy,)

Save the changes then reload the config in asterisk and you will be good to go.

In the above example, the calls behave the same, but in the live log you'll see "THIS IS THE ALTERED CODE" appear when the module is triggered.


No comments:

Post a Comment