Hey everyone. I am working on a script to pull conversation details for our WEM adherence tracking. We are in the US/Pacific timezone so timing is a bit strict for us. The goal is to get the exact start and end times of interactions for agents who are marked as adherent.
I have been using the standard /api/v2/conversations endpoint. It works fine for getting the status and basic metadata. But when I try to get the detailed analytics data like talk time, hold time, and wrap-up time, I am hitting a wall. The conversations endpoint returns a duration field, but it is just a single number. It does not break down the components I need for the adherence report.
So I looked at the /api/v2/analytics/conversations/queries endpoint. This one seems to have all the detail I need. I can build a JSON query body with the specific metrics. But the response format is different. It returns an array of entities with metrics inside. It is more complex to parse. Also, the documentation says this endpoint is for aggregated data or historical queries, not necessarily real-time state.
Here is the query body I am using for the analytics endpoint:
{
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-01T23:59:59.999Z",
"entities": [
{
"id": "agent-id-123",
"type": "agent"
}
],
"metrics": [
"talkTime",
"holdTime",
"wrapupTime"
],
"groupings": [
{
"type": "conversationId"
}
]
}
The issue is that sometimes the analytics data is delayed. For real-time adherence checks, I need the data immediately. The /api/v2/conversations endpoint is faster but lacks the breakdown. The analytics endpoint has the breakdown but feels slower and more cumbersome for a simple lookup.
Is there a best practice here? Should I just stick with /api/v2/conversations and calculate the times myself from the events? Or is there a way to get the detailed metrics from the standard conversations endpoint? I don’t want to build two different data pipelines for the same report. It feels like overkill.