[Freeswitch-users] Use of execute_extension

Raphael Lechner raphael.lechner at gmail.com
Tue Sep 29 20:08:21 MSD 2015


Hi,

I can’t say why the regex is giving you the array output, but I can show you a example how I resolved that to normalize the numbers to the IT Format.
I split them to different extensions and it’s not so easy to read, but maybe It helps you to understand.
The last part is calling cidlookup with the normalized number:

<extension name="cid_number_cleanup_italy" continue="true" inline="true">
  <condition field="caller_id_number" expression="^(?:\+39|0039)(\d+)$">
    <action application="set" data="effective_caller_id_number=$1" inline="true"/>
  </condition>
</extension>
<extension name="cid_number_cleanup_other" continue="true" inline="true">
  <condition field="${effective_caller_id_number}" expression="^$"/>
  <condition field="caller_id_number" expression="^(?:\+)(\d+)$">
    <action application="set" data="effective_caller_id_number=00$1"/>
  </condition>
</extension>
<extension name="cid_name_cleanup" continue="true" inline="true">
  <condition field="${effective_caller_id_number}" expression="^$" inline="true"/>
  <condition field="caller_id_name" expression="^(?:\+)(\d+)$">
    <action application="set" data="effective_caller_id_name=$1" inline="true"/>
  </condition>
</extension>
<extension name="cid_lookup-1" continue="true" inline="true">
  <condition field="${module_exists(mod_cidlookup)}" expression="true"/>
  <condition field="caller_id_name" expression="(\d+)$"/>
  <condition field="${effective_caller_id_number}" expression="^$" inline="true">
    <anti-action application="cidlookup" data="${effective_caller_id_number}"/>
  </condition>
  <condition field="caller_id_number" expression="(\d+)$">
    <action application="cidlookup" data="$1"/>
    <anti-action application="cidlookup" data="${effective_caller_id_number}"/>
  </condition>
</extension>
<extension name="verify-caller-name" continue="true" inline="true">
  <condition field="${caller_id_name}" expression="UNKNOWN">
    <action application="log" data="INFO callee_id_name is UNKNOWN reset to caller_id_number '${caller_id_number}'"/>
    <action application="set" data="effective_caller_id_name=${caller_id_number}"/>
    <anti-action application="log" data="INFO caller_id_name is known as '${caller_id_name}'"/>
  </condition>
</extension>

Raphael

> On 29 Sep 2015, at 12:20, 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 <mailto: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 <mailto: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 <mailto: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 <mailto: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 <mailto: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 <mailto:33123456789 at 10.199.16.172> Action set(iv_dest_number=0RRAY::04)
> Dialplan: sofia/external_trk/33123456789 at 10.199.16.172 <mailto: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 <mailto: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 <mailto: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 <mailto: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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150929/9423363c/attachment-0001.html 


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