AstriCon 2023 Fun With FreePBX

Fun with Firewall

Custom dialplan to use DTMF input from a local extension in order to add an IPv4 address to the FreePBX Firewall trusted zone

https://gist.github.com/lgaetz/8a043b7aa39484f622f0f7c138909558

Fun with Marketing Campaigns

Custom dialplan example to automate sending SMS messages from FreePBX using Voip Innovations

FreePBX Dialplan Customization AstriCon 2020#CustomDestinations

Fun with Phone Ins

The idea is to use FreePBX to replicate the concept of the radio call in contest, i.e. Caller number ten to 555-234-1212 will win ${prize}. The core components of this configuration are two Asterisk database keys named "contest/current" and "contest/winner". The contest/current database entry keeps track of how many callers have come in since the last reset. The contest/winner database entry defines which caller wins. There are also two Dynamic Routes to make it all work. One is used for internal purposes to manually reset the contest counter back to zero, and the other is used as a destination for inbound contest callers to keep track of the count and branch the call based on if they are the winner or a loser.

Create Dynamic Route #1 to reset the phone in contest counter

  1. Enter an arbitrary name and description. You don't need to enable any DTMF input.

  2. Under the Dynamic Route Lookup Source section you want Source Type set to Asterisk Variable and use the following expression

    ${SET(DB(contest/current)=0)}
  3. You don't need any dynamic route entries for this. Set the default destination to whatever you want, but probably want to terminate/hangup

  4. You probably want a Misc Application for this so that you can dial a feature code from an internal extension to do the reset. You could also add it to an IVR as a hidden option or behind a PIN if you need to reset the contest from an external number

The config for dynroute #1 will look something like this

Create Dynamic Route #2 to keep a running count of inbound callers to the contest line

  1. Enter arbitrary name and description. You don't need to enable any DTMF input.

  2. Set the "Saved result variable name" to "caller-count". At any point later in the call flow you can reference the current caller's contest count number with the channel var DYNROUTE_caller-count

  3. In the Dynamic Route Lookup Source section set the "Source Type" to Asterisk Variable and use the following expression

    ${SET(DB(contest/current)=${MATH(${DB(contest/current)} + 1,i)})}
  4. Set the default destination where you want all the losing callers to go

  5. Under Dynamic Route entries, define the caller count that you want to win, i.e. caller number 10. Set the destination where you want winning callers to go

The Config will look something like this: 

Create Custom Destination to read back caller counter

If you want to announce to the inbound caller what number they are, you can do that with some custom diaplan and a Custom Destination. In extensions_custom.conf you would need dialplan that looks something like this:

[contest-playback-callernum] exten => s,1,NoOp(Entering user defined context [contest-playback-callernum] in extensions_custom.conf) exten => s,n,Answer exten => s,n,wait(1) exten => s,n,Playback(you-are-caller-num) exten => s,n,SayNumber(${DYNROUTE_caller-count},f) exten => s,n,Return

Then create a Custom Destination referencing the above dialplan with a target of 

In the Custom destination, enabled the return option and then send the caller to another destination or set to Terminate call

This creates a destination in FreePBX such that if you route the contest caller thru it, it will announce "You are caller number <count>". After this you can route the call elsewhere for more announcements etc.

Return to Documentation Home I Return to Sangoma Support