<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 08.00.0681.000">
<TITLE>Conditional testing on caller_id_name</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Thanks Brian,</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">I think</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">t</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">he lights just came on...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">I think I</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">finally</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">see what’s going on here. Looking through the wiki</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> some more</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">, I</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">came across</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> the following:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">“The XML Dialplan has the ability to test a number of conditions based upon variables with expressions; however, it needs to be understood that some variables may not be available for conditional testing until the first transfer or execute_extension is performed.”</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">When I do a conditional test</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">such as</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> the following</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><condition field="caller_id_name" expression="^Currently running a lookup"></FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">the console output shows the ani</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">instead of the CNAM</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">in parentheses as</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">shown, and fails</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Dialplan: sofia/external/4105551212@140.239.</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">xx.xx</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> Regex (FAIL) [currently_running] caller_id_name(410</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">5551212</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">) =~ /^Currently running a lookup/ break=on-false</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">BUT when I ask for the variable as follows:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><action application="log" data="${caller_id_name}"/></FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">I get the expected value</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> in the console output</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">EXECUTE sofia/external/410</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">5551212</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">@140.239.</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">xx.xx</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> log(</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">SMITH</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">,</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">JOHN</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">2012-08-02 12:12:50.679592 [DEBUG] mod_dptools.c:1458</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">SMITH,JOHN</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">(the names</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">and numbers</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">have been changed to protect the</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">clueless</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">So</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">just to be sure,</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">is this in fact what's going on</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> here</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">? </FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">I learned something today</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">...</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> n</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">ow that I understand</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> it</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">, I can deal with it.</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> By next year I'm bound</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">to comprehend things well enough to</FONT></SPAN><SPAN LANG="en-us"> <FONT FACE="Consolas">get something useful from ClueCon.</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Thanks!</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">The rest of th</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas">e</FONT></SPAN><SPAN LANG="en-us"><FONT FACE="Consolas"> message that follows was written before I came across this little tidbit of information but I’m keeping it in here for reference:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><clueless banter follows></FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">I have no idea how to use Perl in FS but after a bit of looking around it appears that I would need to do something like:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><action application="perl" data="/usr/src/freeswitch/scripts/perl/cnam.cgi $1"/></FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Is that correct?</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Better yet, is there any way to get to the CID name variable without having to resort to Perl? Doing an ‘info’ in the dialplan during an incoming call shows the following:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Caller-Caller-ID-Name: [JOHN SMITH]</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">How can I get to that data? ‘caller_id_name’ just seems to contain the number instead of the CNAM info, which doesn’t make any sense.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">The wiki shows the following example to set a variable directly:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><action application="set" data="cid_name=${cidlookup(${caller_id_number})}"/> and this looks like it might work, but I’d like to understand why the variables aren’t already set after the cidlookup is done in public.xml.</FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"><clueless banter ends/></FONT></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Phil Quesinberry</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Q Systems Engineering, Inc.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Electronic Controls and Embedded Systems Development</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">(410) 969-8002</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN><A HREF="http://www.qsystemsengineering.com"><SPAN LANG="en-us"><U><FONT COLOR="#0000FF" FACE="Consolas">http://www.qsystemsengineering.co</FONT></U></SPAN><SPAN LANG="en-us"><U><FONT COLOR="#0000FF" FACE="Consolas">m</FONT></U></SPAN><SPAN LANG="en-us"></SPAN></A><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">----------</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">[Freeswitch-users] Setting effecting_caller_id_name</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Brian West </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Sat Jul 28 17:46:14 MSD 2012</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Sounds like your doing openCNAM, check the cnam.cgi in tree, you should be</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">checking the response code and not the text returned. I built the wrapper</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">to clean up the input before I query because of this.</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">--</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Brian West</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">brian at freeswitch.org</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">FreeSWITCH Solutions, LLC</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">PO BOX PO BOX 2531</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Brookfield, WI 53008-2531</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Twitter: @FreeSWITCH_Wire</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">T: +1.213.286.0410 | F: +1.213.286.0401 | M: +1.918.424.WEST</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">iNUM: +883 5100 1286 0410</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">On Jul 27, 2012, at 10:06 AM, Ken Rice <krice at freeswitch.org> wrote:</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">Re: [Freeswitch-users] Setting effecting_caller_id_name This exmaple should</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">be correct provided that caller_id_name containts “Currently runnint a</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">lookup” with this pinned to that start of the field...</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">On that extension in your dialplan toss a <anti-action application=”info”/></FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">If your regex isnt matching on the caller_id_name field the above will show</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">you whats in there (along with every thing else too heh)</FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas"> </FONT></SPAN></P>
<P DIR=LTR><SPAN LANG="en-us"><FONT FACE="Consolas">K</FONT></SPAN></P>
</BODY>
</HTML>