[Freeswitch-users] Localized Numbering Plans

Raymond Chandler intralanman at gmail.com
Fri Oct 19 16:46:15 EDT 2007


After seeing how many people responded to Brian's requests on localized 
say stuff, I figured I'd run this up the flagpole and see who salutes it....

I'd like to see FreeSwitch have localized numbering plans for many 
different areas out of the box. So, I've written a semi-complete version 
of a US numbering plan to spark some discussion on how others think it 
should be done.... and maybe get some examples written for other areas. 
If you notice any syntax errors, etc.... keep in mind this was written 
rather quickly and NOT thoroughly tested.... it's really just a 
(somewhat functional?) draft.

---- In Existing default_context ----
  <!--
  This will send a user to their localized numbering plan (provided the 
variable (maybe it should be a param?) is in directory.conf)
  -->
  <extension name="Localized_Dialplan">
    <condition field="${numbering_plan}" expression="^[[:alnum:]]+$"/>
    <condition field="destination_number" expression="^([[:alnum:]]+)$">
      <action application="transfer" data="$1 XML 
${numbering_plan}-Numbering-Plan"/>
    </condition>
  </extension>
 


---- in numberplans/US.conf.xml (needs to be included)----
<context name="US-Numbering-Plan">

  <!--
  If the destination starts with 011, then check enum and route the call 
accordingly
  -->
  <extension name="US_International">
    <condition field="destination_number" expression="^011(\d*)$">
      <action application="set" data="continue_on_fail=true"/>
      <action application="set" data="hangup_after_bridge=true"/>
      <action application="enum" data="1$1"/>
      <action application="bridge" data="${enum_auto_route}"/>
      <action application="bridge" data="sofia/$${domain}/011$1"/>
    </condition>
  </extension>
 
  <!--
  If the destination is a 10 or 11 digit US-Style number, then check 
enum and route accordingly
  -->
  <extension name="US_LD">
    <condition field="destination_number" 
expression="^1?([2-9]\d{2}[2-9]\d{6})$">
      <action application="set" data="continue_on_fail=true"/>
      <action application="set" data="hangup_after_bridge=true"/>
      <action application="enum" data="1$1"/>
      <action application="bridge" data="${enum_auto_route}"/>
      <action application="bridge" data="sofia/$${domain}/1$1"/>
    </condition>
  </extension>
 
  <!--
  Check for the existence of a default area code.... If found and the 
destination was dialed
  as 7 digits prefix a 1 and the default area code to the dialstring, 
then check enum,
  then (you guessed it) route accordingly
  -->
  <extension name="US_Local">
    <condition field="${default_area_code}" expression="\d{3}" 
continue="on-true">
      <anti-action application="say" data="you must dial the area code 
to call this destination"/>
    </condition>
    <condition field="destination_number" expression="^([2-9]\d{6})$">
      <action application="set" data="continue_on_fail=true"/>
      <action application="set" data="hangup_after_bridge=true"/>
      <action application="enum" data="1$1"/>
      <action application="bridge" data="${enum_auto_route}"/>
      <action application="bridge" 
data="sofia/$${domain}/1${default_area_code}$1"/>
    </condition>
  </extension>
 
  <!--
  If the number dialed was
  411 (Directory Services),
  611 (Pretty Standard for Provider Customer Service),
  811 (call before you dig i think?),
  or 911 (Emergency Services) then send directly out the default profile
  -->
  <extension name="FCC_Services">
    <condition field="^([4689]11)$">
      <action application="bridge" data="sofia/$${domain}/$1"/>
    </condition>
  </extension>
</context>



More information about the Freeswitch-users mailing list