[asterisk-users] Routing incoming call based on caller id

Steve Edwards asterisk.org at sedwards.com
Fri Nov 6 12:13:15 CST 2009


Un-top-posting...

> [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Lyle Giese

> Currently I have this in my extensions.conf for incoming calls on our 
> house phone line:
>
> [housemenu]
> exten => s,1,GotoIF($["${CALLERID(num)}" = > "815xxxxxxx"]?s|12)
> ; 815xxxxxxx is our home phone number, when caller id 
> fails or is missing that is what is recorded.
>
> I want to expand this from just branching on our home phone number to 
> include any toll free number, (800, 866, 877, etc) as a telemarketer 
> screening system.  But I am not sure of the syntax here, but don't want 
> to add another line for each 8xx toll free npa either.

On Fri, 6 Nov 2009, Danny Nicholas wrote:

> This might be the worst suggestion you'll get

Get's my vote :)

> but it WILL work
>
> - exten => s,1,AGI(testval.agi,${CALLERID(num)})
> - exten => s,2,Gotoif(${marketer})
>
> The AGI should read a variable from STDIN, evaluate the first 3 digits 
> and return variable marketer as TRUE or FALSE.  You can do this in about 
> 30 lines of PERL/PHP.

Creating unnecessary processes, dragging a bajillion bytes of interpreter 
off disk and into memory, parsing and interpreting 30 lines of script* all 
to avoid 1/2 dozen lines of dialplan doesn't sound like the correct 
approach -- even though I am an AGI fanboy.

[housemenu]
 	exten = s,1,			verbose(1,[${CONTEXT}:${EXTEN}])
 	exten = s,n,			set(NPA=${CALLERID(num):0:3})
 	exten = s,n,			gotoif($["800" = "${NPA}"] ?toll-free,s,1)
 	exten = s,n,			gotoif($["888" = "${NPA}"] ?toll-free,s,1)
 	exten = s,n,			gotoif($["866" = "${NPA}"] ?toll-free,s,1)
 	exten = s,n,			gotoif($["877" = "${NPA}"] ?toll-free,s,1)

(untested, but should be close)

Simple to maintain and obvious.

*) If you decide to go the AGI route, it's not quite that simple. You have 
to follow the AGI protocol where the first thing you need to do is read 
the AGI environment passed to you by Asterisk on STDIN. You should use an 
established AGI library and use a "real" language like C -- (ducking 
quickly).

-- 
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                              Fax: +1-760-731-3000



More information about the asterisk-users mailing list