CNAM Lookup

Here is a simple way to perform a CNAM lookup when CallerId Name information is absent on incoming calls.
You would add the following to your extensions.conf which would call the lookup script when CallerID name is missing on incoming calls, if CID name is present it just continues:

extensions.conf:

exten => s,n,GotoIf($["${CALLERID(num)}" = ""]?NOCID,1)
exten => s,n,GotoIf($["${CALLERID(name)}" = ""]?NONID,1)
exten => s,n,GotoIf($[${LEN(${CALLERID(name)})} = 1]?NONID,1)
exten => s,n,GotoIf($["${CALLERID(name)}" = "${CALLERID(num)}"]?NONID,1) ; if callerid name and num are the same
exten => s,n,Goto(ring-the-house,s,1)
exten => SETNID,1,Set(CALLERID(name)=${DB(names/${CALLERID(num)})}) ; set CNAM from the AstDB if present
exten => SETNID,n,Goto(ring-the-house,s,1)

exten => NOCID,1,Set(CALLERID(name)="No CallerID") ; if there's no CID number then there isn't much else we can do
exten => NOCID,n,Answer
exten => NOCID,n,Wait(2)
exten => NOCID,n,Playback(pls-wait-connect-call)
exten => NOCID,n,Goto(ring-the-house,s,1)

exten => NONID,1,agi(callerid_shell.agi,${CALLERID(num)}) ; perform the lookup script
exten => NONID,n,Set(CALLERID(name)=${lookupname})
exten => NONID,n,GotoIf(${CALLERID(name)}?ring-the-house,s,1) ; continue if lookup was successful
exten => NONID,n,Set(ac=${CALLERID(num):0:3}) ; otherwise I like to set the name to be the same as number
exten => NONID,n,Set(ex=${CALLERID(num):3:3})
exten => NONID,n,Set(ext=${CALLERID(num):6:4})
exten => NONID,n,Set(CALLERID(name)=${ac}-${ex}-${ext})
exten => NONID,n,Goto(ring-the-house,s,1)

Next you need to pick a callerid script for the lookup. The attached file is a modified version of Brad House's script that adds Whitepages.com lookups which is very good for Canadian lookups as well:
callerid_shell.agi


Here is a simple way to perform a CNAM lookup when CallerId Name information is absent on incoming calls.
You would add the following to your extensions.conf which would call the lookup script when CallerID name is missing on incoming calls, if CID name is present it just continues:

extensions.conf:

exten => s,n,GotoIf($["${CALLERID(num)}" = ""]?NOCID,1)
exten => s,n,GotoIf($["${CALLERID(name)}" = ""]?NONID,1)
exten => s,n,GotoIf($[${LEN(${CALLERID(name)})} = 1]?NONID,1)
exten => s,n,GotoIf($["${CALLERID(name)}" = "${CALLERID(num)}"]?NONID,1) ; if callerid name and num are the same
exten => s,n,Goto(ring-the-house,s,1)
exten => SETNID,1,Set(CALLERID(name)=${DB(names/${CALLERID(num)})}) ; set CNAM from the AstDB if present
exten => SETNID,n,Goto(ring-the-house,s,1)

exten => NOCID,1,Set(CALLERID(name)="No CallerID") ; if there's no CID number then there isn't much else we can do
exten => NOCID,n,Answer
exten => NOCID,n,Wait(2)
exten => NOCID,n,Playback(pls-wait-connect-call)
exten => NOCID,n,Goto(ring-the-house,s,1)

exten => NONID,1,agi(callerid_shell.agi,${CALLERID(num)}) ; perform the lookup script
exten => NONID,n,Set(CALLERID(name)=${lookupname})
exten => NONID,n,GotoIf(${CALLERID(name)}?ring-the-house,s,1) ; continue if lookup was successful
exten => NONID,n,Set(ac=${CALLERID(num):0:3}) ; otherwise I like to set the name to be the same as number
exten => NONID,n,Set(ex=${CALLERID(num):3:3})
exten => NONID,n,Set(ext=${CALLERID(num):6:4})
exten => NONID,n,Set(CALLERID(name)=${ac}-${ex}-${ext})
exten => NONID,n,Goto(ring-the-house,s,1)

Next you need to pick a callerid script for the lookup. The attached file is a modified version of Brad House's script that adds Whitepages.com lookups which is very good for Canadian lookups as well:
callerid_shell.agi


Created by: bromont, Last modification: Fri 05 of Nov, 2010 (23:57 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+