[asterisk-users] Dialplan / AGI autoanswer question

Gordon Henderson gordon+asterisk at drogon.net
Wed Aug 15 17:47:36 CDT 2007


On Wed, 15 Aug 2007, Matthew Harrell wrote:

> The intent of this sequence is to take the incoming callerid, replace it if
> known with something in the database, and branch on the state from the DB
> and time of the day.

FWIW: I do something similar, but purely in dial-plan using the astdb - 
here's an extract, it demos jumping to named labels too:



exten => incoming,1,Noop(New incoming call. CallerId is ${CALLERID(all)})

; See if we have a name:

exten => incoming,n,GotoIf($["${CALLERID(name)}" != ""]?gotName)

; OK. No Name. Set a default name

exten => incoming,n,Set(CALLERID(name)=Unknown)
exten => incoming,n(gotName),Noop(Carrying on after name check)

; See if we have a number:

exten => incoming,n,GotoIf($["${CALLERID(number)}" != ""]?gotNumber)

; OK. No Number. Set a default number

exten => incoming,n,Set(CALLERID(number)=Withheld)
exten => incoming,n(gotNumber),Noop(Carrying on after number check)

; Now see if the number is the our internal database which will override any
;       name we might have.

exten => incoming,n,Set(name=${DB(cid/${CALLERID(number)})})
exten => incoming,n,GotoIf($["${name}" = ""]?doneCIDprocessing)
exten => incoming,n,Set(CALLERID(name)=${name})
exten => incoming,n,Noop(We set our name to ${name} from the database)

exten => incoming,n(doneCIDprocessing),Noop(Done with incoming CID processing - we have a call from ${CALLERID(all)})


You could keep a separate list of number "states" in the database too, and 
extract this. Eg. above the line where we get the name out of the astdb 
above:

exten => incoming,n,Set(CALLSTATE=${DB(state/${CALLERID(number)})})

and so on...

I'm not sure what (if any!) benefit this might have over running an 
external PHP application... I'd like to think it might actually be quicker 
for simple cases like this, but I've never benchmarked it.

Gordon



More information about the asterisk-users mailing list