|
Asterisk Tips/Fixes/Features
by
John Johnson
These
are various Asterisk how-to items I have found/developed over the last few
years. Feel free to use or share them, I look forward to adding more as I
am able to compile them into a share-able format from my own notes.
“Experience
is what you don’t get until just after you needed it.”
|
Home
Call Flow Multi-Toggle
By
John Johnson 10/1/2013
Often
in more complex Asterisk implementations you will find yourself creating multiple
inbound routes that require “Call Flow Control” or “Day/Night Control”
toggles. In the example below a company has different DID routes for
different departments that are similar in structure and while using time
conditions to put the system into “night mode” they needed to retain the
ability to force it into night mode under some circumstances and put it
into “Holiday Mode” when appropriate playing a pre-recorded additional
“Holiday” greeting. Notice the multiple “Holiday” and “Night” toggles circled
in red:
Requiring someone to dial three separate codes
to “flip” the system into Holiday or Night mode and again three codes to
set it back when business resumes could be pretty cumbersome. The following
is some dial plan code to create a single code to toggle multiple call flow
instances. If you enable “custom device states” in your advanced settings
you should also be able to create pre-programmed BLF keys on SIP phones
that will toggle the multi-code and light an associated status indicator on
the button (depending on phone make/model)
|
In /etc/asterisk/extensions_custom.conf add the following at the bottom of the file with at
least one blank line separating it from the preceding lines:
[set-call-flow-holiday]
exten =>
*288,1,Answer
exten => *288,2,Set(togglestate=${DB(DAYNIGHT/C2)})
exten =>
*288,3,GotoIf($[${togglestate} = NIGHT]]?8:4)
exten => *288,4,Set(DB(DAYNIGHT/C2)=NIGHT)
exten =>
*288,5,Set(DB(DAYNIGHT/C3)=NIGHT)
exten => *288,6,Set(DB(DAYNIGHT/C4)=NIGHT)
exten =>
*288,7,Hangup
exten => *288,8,Set(DB(DAYNIGHT/C2)=DAY)
exten =>
*288,9,Set(DB(DAYNIGHT/C3)=DAY)
exten =>
*288,10,Set(DB(DAYNIGHT/C4)=DAY)
exten =>
*288,11,Hangup
We
are using the state of Call Flow *282, (specified by the red C2 in the second exten=> line), to direct the GotoIf to the correct label line (if matching NIGHT goto 8 and set to “Day”, if
not matching goto 4 and set to “Night”).
In both the “Set” groups (NIGHT or DAY) there is an exten=> for each Call Flow we want to “flip”, add more
“Set” lines for more Call Flows adjusting labels numbers and the GotoIf line appropriately.
|
In /etc/asterisk/extensions_custom.conf add the following at the bottom of the file with at
least one blank line separating it from the preceding lines:
[set-call-flow-night]
exten =>
*289,1,Answer
exten => *289,2,Set(togglestate=${DB(DAYNIGHT/C5)})
exten =>
*289,3,GotoIf($[${togglestate} = NIGHT]]?8:4)
exten => *289,4,Set(DB(DAYNIGHT/C5)=NIGHT)
exten => *289,5,Set(DB(DAYNIGHT/C6)=NIGHT)
exten =>
*289,6,Set(DB(DAYNIGHT/C7)=NIGHT)
exten =>
*289,7,Hangup
exten => *289,8,Set(DB(DAYNIGHT/C5)=DAY)
exten =>
*289,9,Set(DB(DAYNIGHT/C6)=DAY)
exten =>
*289,10,Set(DB(DAYNIGHT/C7)=DAY)
exten =>
*289,11,Hangup
We
are using the state of Call Flow *285, (specified by the red C5 in the second exten=> line), to direct the GotoIf to the correct label line (if matching NIGHT goto 8 and set to “Day”, if
not matching goto 4 and set to “Night”). In
both the “Set” groups (NIGHT or DAY) there is an exten=> for each Call Flow we want to “flip”, add more
“Set” lines for more Call Flows adjusting labels numbers and the GotoIf line appropriately.
|
While still editing
/etc/asterisk/extensions_custom.conf find the existing
“from-internal-custom” context (probably toward the top of the file) it
will generally look like this:
[from-internal-custom]
exten =>
1234,1,Playback(demo-congrats)
; extensions can dial 1234
exten =>
1234,2,Hangup()
exten =>
h,1,Hangup()
include => agentlogin
include =>
conferences
include =>
calendar-event
include =>
weather-wakeup
And add this line to the bottom of
it making sure to leave at least one blank line separating your addition
and the next entries in the file:
include =>
set-call-flow-holiday
include =>
set-call-flow-night
This adds the new
custom contexts to the dialplan.
|
Save
the changes you have made to /etc/asterisk/extensions_custom.conf and reload the Asterisk configuration (you
can do that from the Asterisk CLI with a simple “reload” command and not
even drop a call). The feature is now enabled!
You
should be able to dial *288 to “flip” Call Flow toggles *282, *283 and *284
throwing the system into “Holiday” mode, and when *288 is dialed again all
toggles should go back to normal operation. And *289 should work the same
way for Call Flow toggles *285, *286 and *287 forcing the system into
“Night” mode and back.
|
Home
|