[Freeswitch-users] Cleanup destination_number with country code

Michael Nielsen mic.niel84 at gmail.com
Tue Sep 8 15:48:18 MSD 2015


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.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150908/41da3977/attachment-0001.html 


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