<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Warren,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for the help.&nbsp; I agree I like the AGI best.&nbsp; I am not a programmer and don&#8217;t know the AGI piece but I would like to learn.&nbsp; I will try your first two examples and then attempt to do something with AGI.&nbsp; I really like the idea of using a database and keeping the dialplan as clean as possible.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks very much.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] <b>On Behalf Of </b>Warren Selby<br><b>Sent:</b> Wednesday, April 11, 2012 5:47 PM<br><b>To:</b> Asterisk Users Mailing List - Non-Commercial Discussion<br><b>Subject:</b> Re: [asterisk-users] Dial Plan - Routing via Caller ID<o:p></o:p></span></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal>On Wed, Apr 11, 2012 at 4:11 PM, &lt;<a href="mailto:lists65@gmail.com">lists65@gmail.com</a>&gt; wrote:<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Here is an example.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Let&#8217;s say that I want to send all calls to a context that would answer the call via voicemail.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Let&#8217;s say that I want to only right a SIP phone if calls cam from a particular Area Code (maybe the Area Codes in your state).</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Let&#8217;s say that I would want to send calls from a particular A/C and certain NNX&#8217;s to a particular sales group.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Does that help define the purpose of directing calls *<b>from</b>* different Area Codes and NNX&#8217;s?</span><o:p></o:p></p></div></div><div><p class=MsoNormal><br><br>You've got a few ways you can do this:<br><br>1 - In the dialplan with ex-girlfriend logic.&nbsp; You should be able to use patterns with your ex-girlfriend logic matches, as so:<br><br>exten =&gt; 15558675309/_255NXXXXXX,1,Verbose(Calls to 867-5309 from area code 255 end up here)<br>exten =&gt; 15558675309/_256123XXXX,1,Verbose(Calls to 867-5309 from phone numbers 256123XXXX end up here)<br><br>etc.&nbsp; <br><br>2 - In the dialplan with GotoIf logic:<br><br>exten =&gt; 15558675309,1,Verbose(Call from ${CALLERID(num)} to 867-5309)<br>exten =&gt; 15558675309,n,GotoIf($[&quot;${CALLERID(num):1:3}&quot;=&quot;255&quot;]?areacode255)<br>exten =&gt; 15558675309,n,GotoIf($[&quot;${CALLERID(num):1:6}&quot;=&quot;256123&quot;]?num256123)<br>exten =&gt; 15558675309,n(areacode255),Verbose(Calls to 867-5309 from area code 255 end up here)<br>exten =&gt; 15558675309,n(num256123),Verbose(Calls to 867-5309 from phone numbers 256123XXXX end up here)<br><br>etc.<br><br>3 - Outside the dialplan with an AGI that allows you many more conditional logic choices (plus keeps your dialplan nice and clean):<br><br>exten =&gt; 15558675309,1,Verbose(Call from ${CALLERID(num)} to 867-5309)<br>&nbsp;same =&gt; n,AGI(route_by_clid)<br><br>In your AGI, you'll be most interested in the agi_callerid environment variable and you can control where the call goes next using the SET CONTEXT and SET EXTENSION agi commands, or simply EXEC a GoTo command (either way works).<br><br>Ultimately, I would go with the AGI option, because that then allows you to do things like use a database to store your routing information, use case statements, create routing loops, etc.&nbsp; It's up to you though.&nbsp; <o:p></o:p></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><br>-- <br>Thanks,<br>--Warren Selby, dCAP<br><a href="http://www.selbytech.com" target="_blank">http://www.SelbyTech.com</a><o:p></o:p></p></div></body></html>