mikopbx / Core

Main repository! MikoPBX - is free, easy to setup PBX for small business based on Asterisk 16 core
https://www.mikopbx.com
GNU General Public License v3.0
367 stars 61 forks source link

Accessing the Call detail records (CDR) from 3rd party app #809

Closed omiazad closed 1 week ago

omiazad commented 1 month ago

Loved the mikopbx project. 🧡 Now I want your additional help on accessing the Call detail records (CDR) from 3rd party app.

This is how our call centre works. We basically provide free agriculture consultancy to farmers from villages. They call us, we drop the call and then record the number in our CRM and later call them back and talk with them, so that they do not spend any money. This is 100% charity work to develop the farmers.

We have a CRM like app which collects missed call records and then put the numbers in the queue for the agents. At present we use 3cx and as 3cx runs on Debian, we made a way to install some scripts, which exports the log to our CRM database.

With mikopbx everything seems nice, but we do not find a way how to access the CDR. Would really appreciate if you can guide us, how to access the CDR record from our 3rd party CRM. Is there any API we can access or we need to write custom code somewhere to export the CDR or do you suggest we do this through AMI?

We are also not familiar with AMI, so some guidance would be very helpful.

boffart commented 1 week ago

You can install free module "Telephony panel 1.0 for 1C:Enterprise" Use REST API: curl http://PBX_IP/pbxcore/api/cdr/get_data?offset=0&limit=1&

the service allows you to sequentially upload the call history table to the entire crm. this is a GET request.
If you are tied to this API, then keep in mind that it is not documented anywhere yet and may change. In our statistics module, the recommended access time is once every 120 seconds. Do not execute the request too often, it can be harmful.

An example of a REST result

<?xml version="1.0"?>
<cdr-table-askozia>
<cdr-row id="604959" start="2024-04-04%2009%3A18%3A04.647" endtime="2024-04-04%2009%3A22%3A31.291" answer="2024-04-04%2009%3A18%3A15.825" src_chan="PJSIP%2F235-000004c8" src_num="235" dst_chan="PJSIP%2FSIP-PROVIDER-AAA880B194BA809EA72C0FCC4D6363AB-000004c9" dst_num="79296290722" UNIQUEID="mikopbx-1712211481.2452_5d8GIM" linkedid="mikopbx-1712211480.2449" did="" disposition="ANSWERED" recordingfile="%2Fstorage%2Fusbdisk1%2Fmikopbx%2Fastspool%2Fmonitor%2F2024%2F04%2F04%2F09%2Fmikopbx-1712211481.2452_5d8GIM.mp3" from_account="235" to_account="SIP-PROVIDER-AAA880B194BA809EA72C0FCC4D6363AB" dialstatus="ANSWERED" appname="" transfer="0" is_app="" duration="267" billsec="256" work_completed="1" src_call_id="bb4582b3-b53f-43af-83f7-f8c4096c1e49" dst_call_id="210ad7af-2e89-40b8-b2d2-e7316c2ff884" verbose_call_id="%5BC-00000230%5D" a_transfer="0"  />
</cdr-table-askozia>