Handling e164 numbers in FreeSWITCH

SIP clients installed on smartphones may pick up the destination number from the phone book, and it’s sometimes in e.164 format (+[countrycode][localdigits]).

The following piece of XML dialplan transforms such numbers into the standard form that is expected by most PSTN VoIP providers. This example assumes that the FreeSWITCH server is located in Switzerland and +41 is the e.164 prefix for in-land calls. It returns the call to the same context, making the switch traverse the whole context dialplan from the beginning. It makes sense to place this extension at the bottom of a context.

    <extension name="e164_pstn">
      <condition field="destination_number" expression="^\+41(\d+)" break="on-true">
        <action application="transfer" data="0$1 XML ${context}"/>
      </condition>
      <condition field="destination_number" expression="^\+(\d+)" break="on-true">
        <action application="transfer" data="00$1 XML ${context}"/>
      </condition>
    </extension>

Advertisements

, ,

  1. #1 by Raymond Chandler on July 8, 2013 - 3:44 pm

    This is a good first step for e.164 dialing. I used to do this myself. Something else that could add value would be setting you users’ numbering plan in the variables on their user, then you can support multiple countries easily.

    Also, it could be worth looking at mod_translate which will translate the number in the existing dialplan without having to transfer, and you can even add it as the first dialplan on your sip profile (e.g. )

    • #2 by txlab on July 8, 2013 - 4:15 pm

      Raymond, thanks a lot for the tip on mod_translate. At the moment I’m using the release version from debian packages, but will look into it in the next update. Also a wiki page will be appreciated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: