Google Contacts to Asterisk Caller ID

Caller ID doesn't always contain the best data, especially with mobile phones. To remedy that, it's nice to use Asterisk to re-write the Caller ID. Instead of maintaining a separate list, I chose to export my contact list from Gmail and import that.

The script to do the import is attached to this post. By default it reads a file named "google.csv", but you can pass it whatever file you want as a command line parameter. It outputs a shell script to stdout.

./ >

Of course, you may want to inspect that file before you actually execute it, but I promise there are no backdoors hidden in it. The output should look something like this:

asterisk -rx 'database put cid 12015550101 "John Doe (Home)"'
asterisk -rx 'database put cid 12015550102 "Jane Doe (Work)"'

Then in your Asterisk dialplan, you'll need to check for the existence of a Caller ID override.

exten => s,n,Set(CALLERID(name)=${IF(${DB_EXISTS(cid/${CALLERID(num)})}?${DB(cid/${CALLERID(num)})}:${CALLERID(name)})})

Of course, if you store your Caller ID per-endpoint or something like that, you'll need to modify the script somewhat. That's left as an exercise for the reader.

Plain text icon import-google-to-asterisk.pl_.txt1.46 KB
Subscribe to Comments for "Google Contacts to Asterisk Caller ID" Subscribe to - All comments