[asterisk-users] Contact lookup

Geoff Lane geoff at gjctech.co.uk
Wed Feb 4 04:53:47 CST 2009


On Wednesday, February 4, 2009, D Tucny wrote:

> I use a slight variant of this...

> exten => s,n,Set(CALLERID(name)=${IF(${ISNULL(${DB(cidname/${CALLERID(num)})})}?"Unknown":${DB(cidname/${CALLERID(num)})})})
> exten => s,n,NoOp("Caller ID name mapped to ${CALLERID(name)}")

> Basically the same as yours above (including substitution of Unknown when not found), but, all on one line...

Once I'd got a handle on it, the task seems almost trivial. Here's
what I've got:

exten => s,1,Set(CALLERID(name)=${DB(cidname/${CALLERID(num)})})

I don't need "unknown" because all my handsets show something similar
(e.g. "Unavailable name") by default.

> I've been looking into changing it recently such that where I don't
> have the name I can substitute something more useful than Unknown,
> such as the site, or for external calls, the
> country/province/state/city/type/telco/etc, though that won't be in
> astdb due to the current 100s of thousands of rows...

That might be a good AGI project...

FWIW, I had trouble loading astdb with the contact list. I dumped the
caller list from my old PBX to a CSV file and then parsed it to give
one line of the following form for each contact:

/usr/sbin/asterisk -rx 'database put cidname 01234567 "Caller Name"'

I ran the script and it appeared to go well. However, when did
"database show cidname" at the * CLI prompt, the family and key were
in a right mess. For example, the entry above might have appeared as:

"         34567:      Caller Name"

I suspect that it would still have worked since "database show
cidname" listed these entries but I didn't take chances. There were
only thirty or so entries, so I cleared the cidname family and copied
each "database put" command from a terminal window and pasted to the *
CLI prompt.

So, this is now sorted for me and I've learned a thing or two about
astdb in the process.

Thanks all.

-- 
Geoff




More information about the asterisk-users mailing list