Here is a little script that allows you to look up for the caller name based on the caller phone number. It is pretty basic and works with parsing the HTML returned by http://findaperson.canada-411.ca/ 14990/search/ReversePhone?phone=${NUMBER} and falls back on http://canada411.yellowpages.ca/ search/?src=&stype=re&pac=${NUMBER:0:3}...
Since the script parses the HTML returned by http://findaperson.canada-411.ca or http://canada411.yellowpages.ca it may stop working if the format of the HTML sent by those sites changes. It is nevertheless trivial to replace the lines in the script calling these web sites and substitute them with your own database calls to lookup for the caller name. Here the logic : 1) Asterisk sends the caller number and name to the script. 2) if a valid number is provided, the script does a lookup to find a matching name. 3) if no name is found by the script, the script just returns the name that Asterisk sent to the script in the first place if any. How to install: In FreePBX go to CallerID Lookup Sources and define your own source as following: Source type: HTTP cache results: yes ( populates PhoneBook automatically and saves bandwidth) Host: localhost
Port: 8071
Path: /
Query: [NUMBER]&${CALLERID(name)} In FreePBX go to Inboud Routes: Set the CID Lookup Source to your own source in all Inbound Routes Make an entry in /etc/inetd.conf to map port 8071 to the lookup script: 8071 stream tcp nowait asterisk /usr/local/bin/callerid.sh and restart inetd Alternatively, if you are using xinetd, put the following in your /etc/services: asterisklookup 8071/tcp # asterisk lookup and put the following in xinetd.conf: service asterisklookup { socket_type = stream protocol = tcp wait = no user = asterisk group = asterisk server = /usr/local/bin/callerid.sh disable = no } and restart xinetd Download and install script: Download from this link Rename callerid.sh, copy into /usr/local/bin and make it executable by issuing the command : chmod 755 /usr/local/bin/callerid.sh
|