Caller ID Lookup (cidlookup) from Contacts.

EasyBB

Active Member
Time and time again those who are new to FusionPBX find it difficult to get cidlookup working from their contact list.

Inbound Route:
upload_2016-10-24_17-44-5.png



upload_2016-10-24_17-55-48.png

Now navigate to Advanced > XML Editor > autoload_configs > cidlookup.conf.xml and modify existing lines with these:

HTML:
<!--<param name="odbc-dsn" value="$${dsn_system}"/>-->
    <param name="odbc-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=fusionpbx user=fusionpbx password=your_db_password"/>
Code:
<param name="sql" value="
SELECT concat_ws(' ',v_contacts.contact_name_given,v_contacts.contact_name_family) AS name, v_contact_phones.phone_number AS number
FROM v_contacts, v_contact_phones
WHERE v_contact_phones.contact_uuid = v_contacts.contact_uuid AND (v_contact_phones.phone_number LIKE '%' || '${caller_id_number}')
LIMIT 1
      "/>
Once you've finished the edits, goto Status > SIP Status and hit 'Reload XML' and 'Flush Memcache'.
 
Last edited:

EasyBB

Active Member
Isn't this already part of the dialplan? You should have just have to enable it in the dialplan, right?
Yes and No :)

The cidlookup in the default dialplan is only good if your entry in the contact db matches exactly with the incoming caller id. I use multiple providers and the caller id formatting is all over the place. I store numbers in international format, e.g. 0061312341234 and using my method all below caller id formats will give you a positive match:
0061312341234
+61312341234
61312341234
0312341234
12341234

I've also seen different formats with the same provider as well; I think this happens when they accept calls from different upstream providers.
 
Hi, I've a strange behaviour. I created my own rest api to reply to fusionbx and it works great! The problem is when I receive calls from number starting with 0 (the number arrive without international prefix), it is striped when it is sent to my API.

So if the number is 02123456, fusionpbx try to make a cid of 2123456. I don't understand where the leading zero is striped!

Thanks a lot
 
If you have problems with imports use COALESCE and if you have spaces in phone number use regexp_replace and right in sql

You can play with this sql

SELECT trim( COALESCE(v_contacts.contact_name_given, ' ' ) || ' ' || COALESCE(v_contacts.contact_name_family, ' ' ) || ' (' || COALESCE(v_contacts.contact_organization, ' ' ) || ')') AS name, v_contact_phones.phone_number AS number
FROM v_contacts, v_contact_phones
WHERE v_contact_phones.contact_uuid = v_contacts.contact_uuid AND RIGHT(regexp_replace(v_contact_phones.phone_number , '[^0-9]*', '', 'g'), 9) LIKE RIGHT('%' || '${caller_id_number}',9)
LIMIT 1
 
Hi, I used this method for lookup the incoming number and all works well if I transfer the number directly to a telephone.
If i transfer the call to a call center and then to a telephone I lose the name of the caller and I see only the number.
How can I pass also the name to a call center?
Thank you.