Converting Asterisk Dialplans to FreeSWITCH

From FreeSWITCH Wiki
Revision as of 16:37, 30 April 2014 by Mario G (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This page was converted to Confluence April 30 2014. The new page is located at:




In switching from Asterisk to FreeSWITCH™ you may discover that it's a little different doing things in the dialplan when compared to what you're used to, especially when you're dealing with IVRs. This page shows how I chose to convert my Asterisk IVRs to FreeSWITCH™ XML Dialplans.

The Asterisk Dialplan

include => queue-inject
exten => s,1,Background(IVR/00200003/brand)
exten => s,n,Background(IVR/00200003/greeting)
exten => s,n,WaitExten(5)
exten => s,n,Goto(3,1)

exten => 2,1,Playback(IVR/00200003/ivr2)
exten => 2,n,Set(IVROPT=DSL Issue)
exten => 2,n,Playback(IVR/callmonitoring)
exten => 2,n,Queue(L2-00200003)
exten => 2,n,Hangup()

exten => 3,1,Playback(IVR/00200003/ivr3)
exten => 3,n,Set(IVROPT=Dial-up Support)
exten => 3,n,Playback(IVR/callmonitoring)
exten => 3,n,Queue(L1-00200003)
exten => 3,n,Hangup()

exten => i,1,Goto(s,2)

So, this is a relatively simple IVR, but it does pretty much everything you'd expect to see in something like this, it plays some sounds to the caller, waits for DTMF input and based on that input does some different behaviour.

More specifically, it asks the caller to press 2 if they're a DSL customer and 3 or nothing if they're anything else (dialup, effectively). Then, depending on that selection, it plays an additional message, stores what they picked and puts them in queue.

Now, here's how I converted it to FreeSWITCH™

The FreeSWITCH™ Version

  <extension name="IVR Conversion">
    <condition field="destination_number" expression="^2617559$"/>
    <condition field="${ivrlevel}" expression="^$" break="never">
      <action application="set" data="domain_name=$${domain}"/>
      <action application="playback" data="IVR/00200003/brand.wav"/>
      <action application="play_and_get_digits" data="0 1 1 5000 # IVR/00200003/greeting.wav /invalid.wav ivrsel (2|3)"/>
      <action application="set" data="ivrlevel=2"/>
      <action application="transfer" data="${destination_number}"/>
    <condition field="${ivrlevel}-${ivrsel}" expression="^2-2$" break="never">
      <action application="playback" data="IVR/00200003/ivr2.wav"/>
      <action application="set" data="ivropt=DSL Issue"/>
      <action application="playback" data="IVR/callmonitoring.wav"/>
      <action application="fifo" data="L2-00200003 in /tmp/exit-message.wav /tmp/music-on-hold.wav"/>
    <condition field="${ivrlevel}-${ivrsel}" expression="^2-(3|)$">
      <action application="playback" data="IVR/00200003/ivr3.wav"/>
      <action application="set" data="ivropt=Dial-up Support"/>
      <action application="playback" data="IVR/callmonitoring.wav"/>
      <action application="fifo" data="L1-00200003 in /tmp/exit-message.wav /tmp/music-on-hold.wav"/>

This is looks a little different than the original but the behaviour is the same:

  • Condition checks destination number - this must match to continue.
  • Condition check is if we've traversed the IVR before (via the ivrlevel variable), if not, the following occurs:
    • Play the first sound
    • Play the second sound and wait 5 seconds for 1 digit of either 2 or 3 (stored in the ivrsel variable)
    • Set the ivrlevel variable to 2 to indicate we're going to the second level of the IVR
    • Transfer back to the destination number we originally matched on (the extension is evaluated again, go back to the start)
  • Condition check to see if the ivrlevel is 2 and the ivr selection is 2:
    • Play message
    • Store choice in channel variable
    • Play a message about calls being monitored for QA
    • Insert into a FIFO queue
  • Condition check to see if the ivrlevel is 2 and the ivr selection is 3 or blank (invalid input)
    • Same as previous condition

If you wanted to re-prompt on invalid input, you could do so by checking for when ivrlevel is 2 and ivrsel is blank and then do another play_and_get_digits and transfer back to destination_number.