Synopsis:
Look up CallerID Name from local databaseDescription:
LookupCIDNameLooks up the Caller*ID number on the active channel in the Asterisk database (family 'cidname') and sets the Caller*ID name. Does nothing if no Caller*ID was received on the channel. This is useful if you do not subscribe to Caller*ID name delivery, or if you want to change the names on some incoming
calls.
Examples
exten => s,X,LookupCIDNameCLI command for storing CID names:
database put cidname 12345 "John Smith"CLI command for listing CID names:
database show cidnameUsing Trixbox / FreePBX with Third Party Caller Name Lookup Scripts
This is the original caller-id macro used by FreePBX (v 2.1.2)
[macro-user-callerid]
exten => s,1,GotoIf($["${CHANNEL:0:5}" = "Local"]?report)
exten => s,n,GotoIf($["${REALCALLERIDNUM:1:2}" != ""]?start)
exten => s,n,Set(REALCALLERIDNUM=${CALLERID(number)})
exten => s,n(start),NoOp(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => s,n,Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)})
exten => s,n,Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)})
exten => s,n,GotoIf($["x${AMPUSERCIDNAME:1:2}" = "x"]?report)
exten => s,n,Set(CALLERID(all)=${AMPUSERCIDNAME} <${AMPUSER}>)
exten => s,n(report),NoOp(Using CallerID ${CALLERID(all)})
exten => s,n,GotoIf($["${CALLERID(name)}" != ""]?done)
exten => s,n,AGI(callerid_shell.agi|${CALLERIDNUM})
exten => s,n,NoOp(AGI Returned ${lookupname})
exten => s,n,Set(CALLERID(name)=${lookupname})
exten => s,n(done),NoOp(Callerid Lookup Complete)
The second paragraph of code will kick in if no Caller Name has been set,
perform the lookup and return it. I've used the following script (also linked below) to do this. Just place the
second block of code below the existing macro-user-callerid section.
As an alternative, you can use the smartCID script (available at www.generationd.com). This script can do callerid lookup from a local MYSQL database, but can also go out to websites like 411.com and do a reverse phone lookup to get the caller's name and address. This script also offers a call screening field - usefull!
See also
- SetCIDNAme and Asterisk cmd SetCIDNum: For Asterisk 1.0 and earlier
- Asterisk tips managing CID names: Simple web interface for managing Caller ID Names
- US Reverse Lookup AGI - 411.com, google.com, and anywho.com with caching and NANPA lookups
- www.got-name.com provides a "no-software needed" Caller*ID name service for Asterisk and Trixbox.
- CLI
- Tips & Tricks
Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ
Page Changes
Works Great