wardmundy
Nerd Uno
- Joined
- Oct 12, 2007
- Messages
- 19,170
- Reaction score
- 5,199
Incredible PBX for Asterisk-GUI was designed in a modular way to make it easy to add your own Custom Scripts and those of others as we move forward. The scripts can be activated for all-trunks for incoming and/or outgoing calls. Or scripts can be activated for an individual trunk for incoming and/or outgoing calls. Moving forward, we will provide a number of custom scripts that are developed by us and by others. There's no practical limit to the number of custom scripts you can include in your dialplan.
NOTE: These scripts are subroutines designed to return control to the existing dialplan. Do NOT use them to branch to a destination! We'll cover that separately.
In its most basic form, a Custom Script looks like this and is added at the end of extensions_custom.conf:
The BEGIN and END markers are important. They make it easy to remove and replace a script with just two lines of code:
To activate a Custom Script for ALL Incoming Calls:
Insert a Gosub line in [incoming-sub] in extensions_custom.conf before the Return() command:
To activate a Custom Script for ALL Outgoing Calls:
Insert a Gosub line in [outgoing-sub] in extensions_custom.conf before the Return() command:
To activate a Custom Script for Incoming Calls on an Individual Trunk:
Insert a Gosub line in DID_sometrunk_default in extensions.conf just before the Goto command that sends a call off to its final destination:
To activate a Custom Script for Outgoing Calls on an Individual Trunk:
Insert a Gosub line in CallingRule_sometrunk in extensions.conf just before the Goto(outbound-allroutes) command (NOTE: there may be more than one entry and be careful to always match the XXX dial string of the trunk):
Whenever you add scripts or make changes in your dialplan: asterisk-reload
See also:
NOTE: These scripts are subroutines designed to return control to the existing dialplan. Do NOT use them to branch to a destination! We'll cover that separately.
In its most basic form, a Custom Script looks like this and is added at the end of extensions_custom.conf:
Code:
;# // BEGIN demo-script
[demo-script]
exten => s,1,Noop("here is a demo script")
exten => s,n,Return()
;# // END demo-script
The BEGIN and END markers are important. They make it easy to remove and replace a script with just two lines of code:
Code:
sed -i '\:// BEGIN demo-script:,\:// END demo-script:d' /etc/asterisk/extensions_custom.conf
cat demo-script.pbx >> /etc/asterisk/extensions_custom.conf
To activate a Custom Script for ALL Incoming Calls:
Insert a Gosub line in [incoming-sub] in extensions_custom.conf before the Return() command:
Code:
exten => incoming-sub_1,n,Gosub(demo-script,s,1())
exten => incoming-sub_1,n,Return()
To activate a Custom Script for ALL Outgoing Calls:
Insert a Gosub line in [outgoing-sub] in extensions_custom.conf before the Return() command:
Code:
exten => outgoing-sub_1,n,Gosub(demo-script,s,1())
exten => outgoing-sub_1,n,Return()
To activate a Custom Script for Incoming Calls on an Individual Trunk:
Insert a Gosub line in DID_sometrunk_default in extensions.conf just before the Goto command that sends a call off to its final destination:
Code:
exten = _.,n,Gosub(demo-script,s,1())
exten = _.,n,Goto(voicemenu-custom-1,s,1) ; routes incoming call to Stealth AutoAttendant
To activate a Custom Script for Outgoing Calls on an Individual Trunk:
Insert a Gosub line in CallingRule_sometrunk in extensions.conf just before the Goto(outbound-allroutes) command (NOTE: there may be more than one entry and be careful to always match the XXX dial string of the trunk):
Code:
exten = _NXXNXXXXXX,n,Gosub(demo-script,s,1())
exten = _NXXNXXXXXX,n,Goto(outbound-allroutes,${EXTEN},1)
Whenever you add scripts or make changes in your dialplan: asterisk-reload
See also: