(Smart!) way to retrieve history of calls

There is really no reason to be intimidated by the thought of sharing your code. We all have to start somewhere, and getting feedback from sharing code snippets is the fastest way to get up to speed. There are people who publish distros who can barely read code, let alone write it. If they can do it, so can anyone else who genuinely want to learn the process.

6 Likes

If somebody here are able to develop something that actually works, and allows me to consume it as an HTTP REST API, doing queries into the CDR, getting intelligent feedback, Iā€™ll encourage my manager to revoke the purchase for the CRM REST module, and Iā€™ll encourage him to commercially obtain a license for whatever you guys build in these regards. We paid $275 for the CRM HTTP REST API thing, and itā€™s 110% broken!

We donā€™t need ā€œcallbacksā€, only the ability to make queries into the CDR database, and we can set it as a requirement that itā€™s stored in MySQL. However, weā€™ll need intelligent return
values, such as e.g.

{
  "calls": [
    "caller-id":66778899
    "extension":1234
    "started":2018-08-20 14:57:00
    "answered":2018-08-20 15:57:37
    "ended":2018-08-20 15:59:47
  ]
}

You get the idea. Parsing the CDR myself, seems like a nightmare, and being able to consume something that does it for me, and return more structured data, would be worth a lot for me and my employer ā€¦

But see, therein lies the gotcha.

That is the simplest scenarioā€¦ it rang for 37 seconds, the user talked for 2 minutes and 10 seconds, and that was it.

But what if the call was transferred? What if it came into a queue? Was it put on hold? Which line did it come in on?

There is so much more information in the CDR than is being represented there.

When I was writing the CDR reporting system, there were a lot of things that the managers wanted (and were required) to know.

Average ring timesā€¦ graphed ring times (how many calls answered <1 second, <5 seconds, <10 seconds, etc.)

Total time on hold. Maximum lines in use (and for how long). Average weighted call time (and it needs to be weighted, because for example you donā€™t want to include the conference room phone, which may be on a call for hours, because it skews the other users)

Queue wait time, shortest, longest, average. Agent logons and logoffs.

Who was on the phone the most? Who was on the phone the least? Who had the most calls? Who had the least calls? (stuff for call centers or sales centers, etc.)

I guess what Iā€™m trying to say is there are a thousand ways to massage and report on the CDR data, and everyone has different needs, desires and even regulations. A ā€œfull blownā€ reporting system needs to think about ALL those scenarios.

If we were to start the ā€œbe all and end allā€ of reporting systems, we would really need to get a sampling of users together and say ā€œWhat reports do you NEED, and what reports would you LIKEā€, then work backwards from there.

2 Likes

Hmm, I see your point, but what we need isnā€™t as much a ā€œreporting systemā€, but a general way to query, getting structured data back. E.g. a rest API, setting filtering parameters and such ourselves.

From that raw but structured data, we can then (more easily) create our own reports, in everything from JavaScript to WinForms apps to iPhone apps, by using JSON as the transferring mechanism for the data ā€¦

Of course, now if I simply look at the CDR through FreePBX, it gives me headache simply thinking about that Iā€™ll need to figure out an intelligent way to actually parse this, and display it as understandable data in my app. With YALOA (Yet Another Layer Of Abstraction), structuring the data slightly better, exposing it securely through JSON, my job creating my ā€œreportsā€ would be 75% done!

If I knew more about the CDR structure, and had some spare time, Iā€™d create it myself. There simply has to be a market for something like this out there ā€¦

2 Likes

It seems the ā€œGeneric APIā€ part of the paid CRM module is still in BETA (as of July 2017).

When will the stable version be released?

For the record, I have now given completely up on the CRM moduleā€™s HTTP REST API. Getting useful data out of it, or for that matter support, has simply proven to be impossible for me. I am now going over to manually connect to MySQL, and retrieve the CDR data myself. If people here have some advice in these regards, I would appreciate it deeply ā€¦ :slight_smile:

1 Like

If youā€™d like to start a conversation about CDR and CEL data interaction, Iā€™d suggest getting specific questions together and starting another thread. We could, of course, continue here, but making a new topic for some advanced discussion of CDR and CEL would make searches easier (just my opinion).

1 Like

I would second that notionā€¦ @polterguy if you want to have a conversation, send me a message. We can exchange contact info and maybe get something going.

ā€¦ or start the CDR/CEL thread. :smiley:

Hehe, go for it! What I am particularly interested in, is how to extract ā€œincoming callsā€, ā€œoutgoing callsā€, ā€œoriginated callsā€ (which seems to create a ā€œfunnyā€ CDR record, with two records in fact), filtering (logically) by extensions and external number (these two values seems to be ā€œflippedā€ depending upon who makes the call), etc ā€¦

If you want to start a thread, feel free to @reply me (if possible), and if somebody could explain this very carefully to (a simple geek, with high knowledge about MySQL and coding though may I add), maybe Iā€™d get some time to create a FOSS project one of these days, returning this thing as understandable data for others ā€¦ :wink:

Thank you :slight_smile:

.t

Iā€™m looking for the same overview of calls as you are.

If I find the correct queries in the meanwhile, Iā€™ll update the thread.

Has there been any work done to start a call reporting REST API? If not I would be more than happy to start on a project like this because I have been working with the CDR/CEL records quite a bit recently and feel like I have a pretty good grasp on them and could contribute a lot.

My suggestion (Iā€™m nobody, so ignore if appropriate).

FIll out and sign a Code Donation request (unless you have one on file at Sangoma already).

Do your work. Make it happy. Submit a Feature Request and put your code on it.

Theyā€™ll either suck it into the system and give you little to no credit, or theyā€™ll drop it on the donations website and give you credit.

All recent API work is in FreePBX 15 with hooks into the new api module. Iā€™m not aware of anything thatā€™s been done with CDR/CEL, but it may have been started.

https://wiki.freepbx.org/display/FPG/API

Did you and @polterguy ever follow up on this? I am looking for additional information about the CDR/CEL. I believe I have a situation where a single call contains CEL records which do not have a uniqueid nor a linkedid in common with other records for the same call. My main problem is figuring out how to group all CEL rows by the call they belong to.

We didnā€™t really follow upā€¦ tbh I kinda forgot about it.
I think, however, if we were going to write a reporting system (which I have no issue with) we would first need to define exactly WHAT we wanted to report on.
There are so many ways to skin that cat, as it were.

I remember a project that I worked on that showed a lot of cool stuff, including reports of rings before answer, reports of trunk grouping usage, call details (of course), calls by hour, calls by station, all sorts of stuff.

The issue is that there isnā€™t a ā€œone size fits allā€ answer. So the solution would be to get a discussion going and pick out the ā€œmost wantedā€ reports and start there.

On a side note, I just wrote a little service in C# that sits there and monitors the AMI stream, and puts incoming calls into a database. The reason is so that users can hit a button and with a single database call get the caller ID information and so forth populated into our system for customer contacts.

So in other words, an agentā€™s phone rings, they bring up our internal software, hit a button and they have the caller ID information, time stamp, etc. of the person they are talking to on the phone at that moment.

2 Likes

So I am a noob here, but it looks like I am trying to find much of the same info as othersā€™ here. I just simply want to be able to get the number of calls answered by a given agent/extension within a time range, from a web app. It seems that there should be a simple http Get or something through an API where I can pass user credentials and get back some basic call stats. Am I out in left field here?

I also understand that this is a pretty old thread. Hopefully someone is still out there haha. I have been looking at AsterNet.ARI but documentation is pretty sparse.

Is there a reason you canā€™t just query the CDR database? There are lots of hard ways that wonā€™t work right, but the data you are asking for is dumped into a MySQL table in almost real time.

asteriskcdrdb.cdr is the database.table name

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.