[Freeswitch-users] Cleanup destination_number with country code

Andrew Cassidy andrew at cassidywebservices.co.uk
Wed Sep 9 15:23:04 MSD 2015


Hi,

I use mod_translate as a dialplan module, it proprocesses such things
before hitting the dialplan. I translate everything into E164 format. It
can access channel variables as part of the replacement expression.

Don't forget that different countries use different international dialling
codes too, such as the US is 011 rather than the 00 we europeans are used
to.

On 8 September 2015 at 12:48, Michael Nielsen <mic.niel84 at gmail.com> wrote:

> Ok, this seems to work (http://pastebin.com/BS4JY2gn):
>
> Can anyone see anything inappropriate or does this dial plan seems OK?
>
>   <extension name="test-dialplan">
>     <condition field="destination_number" expression="^(\+\d{3,20})$"
> break="never">
>       <action application="set" data="dialed_number=$1" inline="true"/>
>     </condition>
>     <condition field="destination_number" expression="^(\d{3,20})$"
> break="never">
>       <action application="set" data="dialed_number=${country_code}$1"
> inline="true"/>
>     </condition>
>     <condition>
>       <action application="set" data="user_exists=${user_exists id
> ${dialed_number} ${domain_name}}" inline="true"/>
>     </condition>
>     <condition field="${user_exists}" expression="^true$" break="never">
>       <action application="set" data="call_timeout=20"/>
>       <action application="set" data="hangup_after_bridge=true"/>
>       <action application="set" data="continue_on_fail=true"/>
>       <action application="bridge" data="user/${dialed_number}@
> ${domain_name}"/>
>       <action application="answer"/>
>       <action application="sleep" data="1000"/>
>       <action application="bridge" data="loopback/app=voicemail:default
> ${domain_name} ${dialed_number}"/>
>     </condition>
>     <condition field="${user_exists}" expression="^false$" break="never">
>       <action application="set"
> data="effective_caller_id_number=${effective_caller_id_number}"/>
>       <action application="set"
> data="effective_caller_id_name=${effective_caller_id_number}"/>
>       <action application="bridge"
> data="sofia/gateway/pstn-outbound/${dialed_number}"/>
>     </condition>
>   </extension>
>
> On Tue, Sep 8, 2015 at 11:20 AM, Michael Nielsen <mic.niel84 at gmail.com>
> wrote:
>
>> This is my dialplan so far, where I want to add this functionality (
>> http://pastebin.com/k1hffPBp):
>>
>>     <condition field="destination_number" expression="^(\+\d{3,20})$">
>>       <action application="set" data="dialed_number=$1" inline="true"/>
>>       <action application="export" data="dialed_number=$1" inline="true"/>
>>     </condition>
>>     <condition field="destination_number" expression="^(\d{3,20})$">
>>       <action application="set" data="dialed_number=${country_code}$1"
>> inline="true"/>
>>       <action application="export" data="dialed_number=${country_code}$1"
>> inline="true"/>
>>     </condition>
>>     <condition field="${dialed_number}" IF-USER-EXISTS>
>>       <action application="set" data="call_timeout=20"/>
>>       <action application="set" data="hangup_after_bridge=true"/>
>>       <action application="set" data="continue_on_fail=true"/>
>>       <action application="bridge" data="user/${dialed_number}@
>> ${domain_name}"/>
>>       <action application="answer"/>
>>       <action application="sleep" data="1000"/>
>>       <action application="bridge" data="loopback/app=voicemail:default
>> ${domain_name} ${dialed_number}"/>
>>     </condition>
>>     <condition field="${dialed_number}" IF-USER-DO-NOT-EXISTS>
>>       <action application="set"
>> data="effective_caller_id_number=${effective_caller_id_number}"/>
>>       <action application="set"
>> data="effective_caller_id_name=${effective_caller_id_number}"/>
>>       <action application="bridge"
>> data="sofia/gateway/pstn-outbound/${dialed_number}"/>
>>     </condition>
>>
>> On Tue, Sep 8, 2015 at 9:32 AM, Michael Nielsen <mic.niel84 at gmail.com>
>> wrote:
>>
>>> I would like to check if the called number contains a country code, if
>>> not then one should be added.
>>> I've got a variable in my user's XML file called country_code containing
>>> +44.
>>>
>>> This is my code so far, however, I think the last to conditions overlap:
>>>
>>>     <condition field="destination_number" expression="^(\+\d{3,20})$">
>>>
>>>       <action application="export" data="dialed_extension=$1"/>
>>>
>>>     </condition>
>>>
>>>     <condition field="destination_number" expression="^00(\d{3,20})$">
>>>
>>>       <action application="export" data="dialed_extension=+$1"/>
>>>
>>>     </condition>
>>>
>>>     <condition field="destination_number" expression="^(\d{3,20})$">
>>>
>>>       <action application="export"
>>> data="dialed_extension=${country_code}$1"/>
>>>
>>>     </condition>
>>>
>>>
>>> I would like to change 00 to +, and if no + is on the number then use
>>> country_code from the user. If it does contain a +, then just use the
>>> dialled number.
>>>
>>
>>
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>



-- 
*Andrew Cassidy BSc (Hons) MBCS SSCA*
Managing Director


*T <info at cassidywebservices.co.uk> *03300 100 960  *F
<info at cassidywebservices.co.uk> *03300 100 961
*E <info at cassidywebservices.co.uk> *andrew at cassidywebservices.co.uk
*W <info at cassidywebservices.co.uk> *www.cassidywebservices.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150909/bd2db299/attachment-0001.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list