Caller ID Lookup (cidlookup) from Contacts.

Status
Not open for further replies.

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
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:

yukon

Member
Oct 3, 2016
138
14
18
Isn't this already part of the dialplan? You should have just have to enable it in the dialplan, right?
 

EasyBB

Active Member
Oct 23, 2016
240
33
28
Australia
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.
 

Daniele

Member
Feb 1, 2017
45
0
6
43
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
 

DigitalDaz

Administrator
Staff member
Sep 29, 2016
3,070
577
113
Without more info, we cannot help, how exactly are you pulling the number?
 

Daniele

Member
Feb 1, 2017
45
0
6
43
I solved. The problem si the the condition on caller_if_number. I removed the "|0" to avoid that the initial zero is removed.

Thanks
 

tahiralgan

New Member
Mar 24, 2019
1
0
1
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
 

aschear1

New Member
Jan 21, 2019
6
0
1
30
A side effect I am noticing of enabling this is that all other CID besides what is listed in the contact book only show as UNKNOWN - any advice? TIA.
 

breschi

New Member
Sep 12, 2019
2
0
1
33
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.
 

Andrew Byrd

Member
Feb 16, 2018
309
10
18
54
I am trying to get all incoming calls to reference the Contacts for the Caller ID before displaying a caller ID

I believe I have everything as above but I must be off somewhere as it displays "UNKNOWN" on the sip device. Where did I go wrong?



<configuration name="cidlookup.conf" description="cidlookup Configuration">
<settings>
<!-- comment out url to not setup a url based lookup -->
<!--<param name="url" value="http://query.voipcnam.com/query.php?api_key=MYAPIKEY&number=${caller_id_number}"/>-->

<!-- comment out whitepages-apikey to not use whitepages.com, you must
get an API key from http://developer.whitepages.com/ -->
<!-- <param name="whitepages-apikey" value="MYAPIKEY"/>-->

<!-- set to false to not cache (in memcache) results from the url query -->
<param name="cache" value="true"/>
<!-- expire is in seconds -->
<param name="cache-expire" value="86400"/>

<param name="odbc-dsn" value="$${dsn_system}"/>
<!--<param name="odbc-dsn" value="/var/www/fusionpbx/secure/fusionpbx.db"/>-->

<!-- comment out sql to not setup a database (directory) lookup -->
<param name="sql" value="pgsql://hostaddr=127.0.0.1 dbname=fusionpbx user=fusionpbx password=iputdatabasepwhere"/>
<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
<!-- comment out citystate-sql to not setup a database (city/state)
lookup -->
<!--
<param name="citystate-sql" value="
SELECT ratecenter||' '||state as name
FROM npa_nxx_company_ocn
WHERE npa = ${caller_id_number:1:3} AND nxx = ${caller_id_number:4:3}
LIMIT 1
"/>
-->
</settings>
</configuration>
 

Attachments

  • 5094024061648896.png
    5094024061648896.png
    99.1 KB · Views: 90
  • 6684321065467904.png
    6684321065467904.png
    127.1 KB · Views: 83
  • 6667677060562944.png
    6667677060562944.png
    167 KB · Views: 80

ad5ou

Active Member
Jun 12, 2018
892
204
43
There were changes recently to cidlookup in master branch. The script as well as dial plan changed.
You might want to try upgrading, deleting the existing cidlookup dial plan then run app defaults to restore new “improved” dial plan.
 

ad5ou

Active Member
Jun 12, 2018
892
204
43
For contact lookup, yes. If you have an external lookup provider, it needs to be configured
 

Andrew Byrd

Member
Feb 16, 2018
309
10
18
54
I tried your suggestion and I thank you for it. Still no luck - It just passes the DID through as the Caller ID name and does not seem to reference the contact (Donald Duck for example in my attachment). Any guidance would be greatly appreciated. I attached 3 screenshots
 

Attachments

  • 4804244899889152.png
    4804244899889152.png
    129.2 KB · Views: 80
  • 5915075511320576.png
    5915075511320576.png
    127 KB · Views: 79
  • 5079621157257216.png
    5079621157257216.png
    111.6 KB · Views: 77

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
@Andrew Byrd I think the cidlookup method you are using uses the mod_cidlookup Freeswitch module. I have no experience with that.

I use the cidlookup.lua script provided by the FusionPBX distribution. This also had a small bug, have a look at:
https://github.com/fusionpbx/fusionpbx/pull/5134

I use cidlookup.lua in the inbound route, see the screenshot below, I'm not saying this is the correct way to do it but it works for me:
Screenshot from 2020-02-07 10-14-49.png
 

1hvoip

New Member
Dec 15, 2019
3
0
1
30
A side effect I am noticing of enabling this is that all other CID besides what is listed in the contact book only show as UNKNOWN - any advice? TIA.
delete cidloockup in the dialplan manager than upgrade to download it again this issue has been fixed
 

1hvoip

New Member
Dec 15, 2019
3
0
1
30
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.
move the cidlookup in the dialplan manager to order 100
 
Status
Not open for further replies.