I’m trying to build a custom reporting dashboard for our UK support queue, and I need to calculate the Service Level percentage (calls answered within 20 seconds) using raw data from the Analytics API. The standard reports give me a pre-calculated SL, but I need the raw numbers to reconcile against our internal CRM logs.
I’ve been using the /api/v2/analytics/details/queries endpoint with a detailType of call. I’m grouping by interval with a 60-second bucket to keep the payload size manageable. Here is the request body I’m sending:
{
"dateFrom": "2023-10-25T00:00:00.000Z",
"dateTo": "2023-10-26T00:00:00.000Z",
"groupBy": ["interval"],
"intervalSize": 60,
"viewId": "my-queue-view-id",
"metrics": [
"offeredCalls",
"answeredCalls",
"abandonedCalls",
"handleTime",
"waitTime"
]
}
The response returns a list of intervals. For each interval, I get offeredCalls and answeredCalls. The problem is figuring out which of those answeredCalls were actually answered within the 20-second threshold. The waitTime metric is an average, not a distribution, so I can’t just check if avgWaitTime < 20.
I tried adding waitTime to the groupBy, but that splits the data into too many rows (one for every unique wait time fraction), making the JSON response huge and slow to parse. I also looked at the threshold metrics, but those seem to be for specific SL goals defined in Admin, and I need a generic calculation.
Is there a way to get a count of calls where waitTime <= 20000 directly from this API? Or do I need to pull every single call record using detailType: call and filter client-side? That seems incredibly inefficient for a high-volume queue.
Here is a sample of what I’m getting back for one interval:
{
"interval": "2023-10-25T09:00:00.000Z",
"metrics": {
"offeredCalls": { "count": 150 },
"answeredCalls": { "count": 145 },
"waitTime": { "average": 12.4 }
}
}
If 145 calls were answered and the average wait was 12.4s, I can’t assume all 145 are within SL. Some might have waited 60s while others waited 0.5s, balancing the average. I need the actual count of calls that hit the 20s mark.
I’ve checked the documentation for analyticsDetailsQueries but it doesn’t mention a way to filter by metric value in the request body. Am I missing a parameter like filter: { waitTime: { lte: 20000 } }? I tried adding that to the body and got a 400 Bad Request saying filter is not a valid property.
Any ideas on how to structure this query correctly? I don’t want to download the entire day’s call detail records if I can avoid it.