[Asterisk-doc] Simple tweaks and customisations: LookupCIDName

Randolph Resnick randulo at ssl-mail.com
Wed Mar 9 04:20:23 CST 2005


Simple tweaks and customisations

Asterisk has a useful feature if you subscribe to callerID or use it 
internally at your installation. A one-line call to the application 
LookupCIDName will set any name you want to be associates with an 
incoming number for display on phones and workstation callerid popups. 
Sometimes the names sent by the phone company are not specific enough. 
If your local install has a lot of user extensions, "Support: Bernie" is 
better than "2002".

Using the feature is simple. Early in a dialplan extension that 
processes incoming calls, you just add this line:

  exten => s,6,LookupCIDName

This will look up the number in the asterisk database and if a key is 
found in the cidname family, it will place that value into 
${CALLERIDNAME} replacing what was there before, if anything, during 
this extension execution.

 From the CLI, type database show cidname for the full list or

  database show cidname/0102030405

A few simple shell scripts can help you get the list started and 
maintain it:

To add a name to a number create a command called "cidset":

/usr/sbin/asterisk -rx "database put cidname $1 \"$2\""

./cidset 0102030405 "His Majesty the Boss"
Updated database successfully

To show a name associated with a number, or the whole list, we'll create 
"cidshow":

if [ ! "$1" = "" ]; then
/usr/sbin/asterisk -rx "database show cidname/$1"
else
/usr/sbin/asterisk -rx "database show cidname"
fi

./cidshow 0102030405
/cidname/0102030405                               : His Majesty the Boss

If you already have a list of phone correspondants in electronic form, 
you can see how simple it would be to insert it into the asterisk db 
with a simple script.

rr


More information about the Asterisk-Doc mailing list