Upgrade 3CX to v18 and get it hosted free!

Asterisk cmd LookupCIDName

Author image

Synopsis:

Look up CallerID Name from local database

Description:

LookupCIDName

Looks 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.
LookupCIDName is deprecated from Asterisk 1.4. Please use Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})}) instead. [NOTE: In 1.6 (maybe 1.4?) this will blank out your Caller ID Name if there is not a DB entry for the number. I use Set(CALLERID(name)=${IF(${DB_EXISTS(cidname/${CALLERID(num)})}?${DB(cidname/${CALLERID(num)})}:${CALLERID(name)})}) instead.]

Examples

exten => s,X,LookupCIDName

CLI command for storing CID names:

database put cidname 12345 “John Smith”

CLI command for listing CID names:

database show cidname

Using 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. 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


Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.