[Freeswitch-users] Use of execute_extension

Dominique Jeannerod dominique.jeannerod at interact-iv.com
Wed Sep 30 18:28:36 MSD 2015


Thank you very much Sergey, for this valuable example.
Do you execute this inside your main dialplan, or inside and extension ?
What's the difference between set and set_profile_var ?

*Dominique Jeannerod*

*Interact-iv.com*
Mobile: +33 698 778 763

Headquarter : 600 rue Felix Trombe – tecnosud – 66100 Perpignan - France
France : 0826 10 23 21 (0,15€/mn) International +33 (0)4 20 10 45 45

2015-09-30 16:08 GMT+02:00 Sergey Safarov <s.safarov at gmail.com>:

> From my dialplan
>
>
>       <extension name="normalizeDestinationNumber" continue="true">
>          <!-- Normalizing destination_number -->
>          <condition field="${destination_number}"
> expression="^\+?[\d\*\(\)\s-]*$">
>             <action application="set_profile_var"
>                     data="destination_number=${replace
> ${destination_number}|-|'' }"
>                     inline="true"/>
>             <action application="set_profile_var"
>                     data="destination_number=${replace
> ${destination_number}|(|'' }"
>                     inline="true"/>
>             <action application="set_profile_var"
>                     data="destination_number=${replace
> ${destination_number}|)|'' }"
>                     inline="true"/>
>             <action application="set_profile_var"
>                     data="destination_number=${replace
> ${destination_number}|\s|'' }"
>                     inline="true"/>
>          </condition>
>          <condition field="${destination_number}" expression="^9(\d+)$"
> break="on-false">
>             <action application="set_profile_var"
> data="destination_number=$1" inline="true"/>
>          </condition>
>          <condition>
>             <action application="set_profile_var"
>                     data="destination_number=${translate
> ${destination_number} ${country}}"
>                     inline="true"/>
>             <action application="log" data="INFO New number
> ${destination_number}" inline="true"/>
>          </condition>
>       </extension>
>
> and
>
>
> [root at voip freeswitch]# cat autoload_configs/translate.conf.xml
> <?xml version="1.0" encoding="UTF-8"?>
> <include>
>    <configuration name="translate.conf" description="Number Translation
> Rules">
>       <profiles>
>          <profile name="Russia">
>             <rule regex="^(\+\d+)$" replace="$1"/>
>             <rule regex="^810(\d+)$" replace="+$1"/>
>             <rule regex="^8(\d{10})$" replace="+7$1"/>
>             <rule regex="^(\d+)$" replace="+7${areacode}$1"/>
>          </profile>
>          </profile>
>       </profiles>
>    </configuration>
> </include>
>
>
> On Wed, Sep 30, 2015 at 4:12 PM, Dominique Jeannerod <
> dominique.jeannerod at interact-iv.com> wrote:
>
>> I tried to remove the () on the first regex : same result (and problem
>> with ARRAY result)
>> I didn't try to remove them on the other regex, as I want to catch the 9
>> digits and set a variable
>>
>> I also tried the syntax <regex field="sip_req_user"
>> expression="^0(\d{9})$"/> (without the ${}), but in this case, the variable
>> seems empty (which is not the case as seen with the info app)
>>
>> I'm just trying to :
>> - Call an extension to check the destination number
>> - Normalise the dest number and modify it (or set a custom variable)
>> - Return to the main dialplan to route the call
>>
>> I still stuck on that. Does someone have any advice or a working example ?
>>
>>
>> *Dominique Jeannerod*
>>
>> *Interact-iv.com*
>> Mobile: +33 698 778 763
>>
>> Headquarter : 600 rue Felix Trombe – tecnosud – 66100 Perpignan - France
>> France : 0826 10 23 21 (0,15€/mn) International +33 (0)4 20 10 45 45
>>
>> 2015-09-29 18:04 GMT+02:00 Sergey Safarov <s.safarov at gmail.com>:
>>
>>> Try remove "()" symbols in first condition or all regex.
>>>
>>> On Tue, Sep 29, 2015, 18:26 Dominique Jeannerod <
>>> dominique.jeannerod at interact-iv.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> i'm trying to call an extension, to normalize the called number to FR
>>>> format, needed by an external operator SIP trunk, using the sip_req_user
>>>> variable, and set a variable iv_dest_number to bridge the call using the
>>>> normalized dest number.
>>>> I'd like to use extensions to split a big dialplan, and make my
>>>> configuration more readable.
>>>>
>>>> I'm quite confused by the way the regex is returning the $1 variable
>>>> inside this extension : ARRAY
>>>> This same code is working without problem inside the main dialplan.
>>>>
>>>> What am i doing wrong ?
>>>> What would be the best way to do that ?
>>>>
>>>> Thanks with anticipation for any advice
>>>>
>>>> Extension :
>>>>     <extension name="N_called_FR">
>>>>         <!-- All numeric and non empty called number
>>>>  -->
>>>>         <condition field="${sip_req_user}" expression="^\+?(\d+)$"
>>>> break="on-true">
>>>>             <condition regex="any">
>>>>                 <!-- Called number in FR format
>>>>  -->
>>>>                 <regex field="${sip_req_user}" expression="^0(\d{9})$"/>
>>>>                 <regex field="${sip_req_user}"
>>>> expression="^33(\d{9})$"/>
>>>>                 <regex field="${sip_req_user}"
>>>> expression="^\+33(\d{9})$"/>
>>>>                 <regex field="${sip_req_user}"
>>>> expression="^0033(\d{9})$"/>
>>>>
>>>>                 <action application="set" data="iv_dest_number=0$1"/>
>>>>             </condition>
>>>>         </condition>
>>>>     </extension>
>>>>
>>>> Freeswitch log :
>>>> EXECUTE sofia/external_trk/33123456789 at 10.199.16.172
>>>> execute_extension(N_called_FR XML iv_common_N_called)
>>>> 2015-09-29 12:09:34.644195 [INFO] mod_dialplan_xml.c:635 Processing
>>>> Test <33123456789>->N_called_FR in context iv_common_N_called
>>>> Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 parsing
>>>> [iv_common_N_called->N_called_FR] continue=false
>>>> |--- Dialplan: Processing recursive conditions level:1
>>>> [N_called_FR_recur_1] require-nested=TRUE
>>>> |--- Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 Regex
>>>> (FAIL) [N_called_FR_recur_1] ${sip_req_user}(0698778763) =~
>>>> /^([1-9]\d{8})$/ match=any
>>>> |--- Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 Regex
>>>> (PASS) [N_called_FR_recur_1] ${sip_req_user}(0698778763) =~ /^0(\d{9})$/
>>>> match=any
>>>> |--- Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 Action
>>>> log(INFO N_called_FR : FR Called number)
>>>> |--- Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 Action
>>>> set(iv_dest_number=0RRAY::04)
>>>> Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 Regex (PASS)
>>>> [N_called_FR] ${sip_req_user}(0698778763) =~ /^\+?(\d+)$/ break=on-true
>>>> 2015-09-29 12:09:34.644195 [NOTICE] switch_core_session.c:2866 Execute
>>>> log(INFO N_called_FR : FR Called number)
>>>> EXECUTE sofia/external_trk/33123456789 at 10.199.16.172 log(INFO
>>>> N_called_FR : FR Called number)
>>>> 2015-09-29 12:09:34.644195 [INFO] mod_dptools.c:1670 N_called_FR : FR
>>>> Called number
>>>> 2015-09-29 12:09:34.644195 [NOTICE] switch_core_session.c:2866 Execute
>>>> set(iv_dest_number=0RRAY::04)
>>>> EXECUTE sofia/external_trk/33123456789 at 10.199.16.172
>>>> set(iv_dest_number=0RRAY::04)
>>>> 2015-09-29 12:09:34.644195 [DEBUG] mod_dptools.c:1477
>>>> sofia/external_trk/33123456789 at 10.199.16.172 SET
>>>> [iv_dest_number]=[0RRAY::04]
>>>>
>>>> D. Jeannerod
>>>>
>>>> _________________________________________________________________________
>>>> 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
>>>
>>>
>>> _________________________________________________________________________
>>> 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
>>>
>>
>>
>> _________________________________________________________________________
>> 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
>>
>
>
> _________________________________________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150930/ac9c7c07/attachment-0001.html 


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