login | register
Sat 13 of Mar, 2010 [14:59 UTC]

voip-info.org

History

Asterisk cmd LookupCIDName

Created by: oej,Last modification on Sat 20 of Jun, 2009 [15:05 UTC] by jcdemars

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.

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 (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



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


Comments

Comments Filter
222

333Works Great

by kevman, Tuesday 08 of November, 2005 [02:20:27 UTC]
This works great. I had my caller ID customized in no time. Well it took a little time to figure out where to put in the database commands but I finally found that "asterisk -r" from the console or ssh will get you where you can do that. Maybe this will help future users on this page.
222

333

by bzly2000, Tuesday 01 of November, 2005 [18:39:21 UTC]
It took awhile to figure this one out! I had used a text file (containing number and name) to feed a perl script to load cidname entries into the * database. Then I used LookupCIDName in extensions.conf to populate the caller id name. Everything worked fine. However, after externally generating the number/name text file and updating the cidname entries with the file and perl script, I could no longer answer a call on a Polycom IP 500 phone. The call would show on the display with the caller's name, but you couldn't answer it. The problem was that I had accidently embedded a linefeed in the name data. This extra data in the caller id name prevented the phones from answering an incoming call (where LookupCIDName had updated the cidname).