<div class="gmail_quote">2009/2/4 Gordon Henderson <span dir="ltr"><<a href="mailto:gordon%2Basterisk@drogon.net">gordon+asterisk@drogon.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Tue, 3 Feb 2009, Geoff Lane wrote:<br>
<br>
> Hi All,<br>
><br>
> Asterisk 1.4.12 on CentOS 5<br>
><br>
> I'd like to be able to look up each incoming CLI to retrieve an<br>
> associated name, if available, and then pass that to the extensions so<br>
> that they can see both the name and number of the caller. I'm not<br>
> after LDAP or anything else maintained externally, just a contact<br>
> lookup for my system.<br>
><br>
> I suspect that Astdb could be used for this, as could a relational<br>
> database like MySQL or postgres (accessed via AGI?) Probably simpler<br>
> would be to maintain a text configuration file since I'm only<br>
> concerned about less than a hundred entries initially.<br>
><br>
> I'd appreciate insight into which is the easiest way to do this, and<br>
> also any pointers to tutorials etc.<br>
<br>
</div>AstDB:<br>
<br>
At it's very simplest:<br>
<br>
exten => s,n,Set(CALLERID(name)=Unknown)<br>
exten => s,n,Set(name=${DB(cid/${CALLERID(number)})})<br>
exten => s,n,GotoIf($["${name}" = ""]?endCID)<br>
exten => s,n,Set(CALLERID(name)=${name})<br>
exten => s,n(endCID),Noop(fixCallerID - End of processing - returning ${CALLERID(all)})<br>
<br>
... somewhere in the incoming processing. (This is an extract from an<br>
overly complcated macro I use) Things to check for - a name already being<br>
present - eg. on an incoming SIP call. No name in the astDB - might want<br>
to substitute "Unknown" ..<br>
<br>
All you need to do now is populate the astDB - I use a web interface and<br>
some php to drive the manager interface...<br>
<br>
My biggest site has just under 300 lookup entries... (Which presents other<br>
issues with the web interface, but ...)<br>
<font color="#888888"><br>
</font></blockquote><div>I use a slight variant of this...<br><br>exten => s,n,Set(CALLERID(name)=${IF(${ISNULL(${DB(cidname/${CALLERID(num)})})}?"Unknown":${DB(cidname/${CALLERID(num)})})})<br>exten => s,n,NoOp("Caller ID name mapped to ${CALLERID(name)}")<br>
<br>Basically the same as yours above (including substitution of Unknown when not found), but, all on one line... <br><br>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...<br>
</div></div><br>d<br>