For those using FreePBX (a configuration/administrative interface that manages Asterisk) there is a CallerID Lookup module, published by the FreePBX team. The module allows you to interface with data sources using several methods, one of them being http.
Like many companies, we maintain several systems that can be easily integrated with our VoIP PBX system, but we also receive a number of calls from the public, viz. companies interested in advertising on GEO|ADS, adding their business to AthensBook or ThessBook, or asking for a quote for a project. OTE recently revamped its aging whitepages.gr site and incorporated its content into their ‘umbrella’ 11888 business directory operation. The new site is faster, more beautiful and written in a more professional manner, as far as the markup is concerned, which makes it a perfect source of caller id information for a large number of telephone subscribers in Greece. Around one hour of Ruby scripting using Mechanize, Sinatra and some custom transliteration tables to convert the scraped names to their latinised counterparts (Cisco phones don’t seem to like Greek characters all that much) resulted in the following script (github).
In our version, we interface with some additional internal systems (viz. we have several lookups performed serially in
searchAll), so we only ‘hit’ OTE’s servers when we don’t get a result back from those ‘higher-frequency’ stores. Additional support can be provided, of course, via LDAP for internal corporate directories, ENUM, etc. Clearly this is not the most rubyesque script ever, nor the most elegant one, its transliteration is crude (and arguably incomplete), but it seems to work fine at least for our purposes. Coupled with the caching support that the FreePBX clid module supports, the lookup performance is more than acceptable for ‘frequent’ callers. In our tests, OTE alone returns a result in less than 0.8s on average, which is good enough in almost every scenario; even if it were longer, in corporate PBX environments, IVRs, Queues allow for pretty ‘slow’ lookups anyway.
The code above is provided under the MIT License. This means you can do whatever you want with it, as long as you retain the license block (see below) in every piece of software that derives from or contains it. Obviously, by using this piece of code you accept the license, understand that is not warranted for any purpose, assume all responsibility pertaining its use, are liable for any claim etc. Here’s the requisite legalese:
Copyright (C) 2012 cosmix.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.