Quick question about constructing an Analytics API aggregation query that groups by queue and media type. I am building a Rust service using tokio and reqwest to pull real-time queue metrics, but the aggregation logic is failing to return the expected breakdown.
Background
I need to aggregate interaction data to calculate average wait times per queue, segmented by media type (voice vs chat). The goal is to feed this into a dashboard widget. I am using the /api/v2/analytics/interactions/queues/summary endpoint. My Rust struct for the request body uses serde to serialize the JSON payload correctly.
Issue
When I send the request, the API returns a 200 OK, but the data array in the response contains only one row with all media types lumped together. The grouping by mediaType is not being applied. I have verified that the group-by field in the request JSON is set correctly.
Here is the relevant snippet of my Rust code constructing the payload:
let payload = serde_json::json!({
"dateFrom": "2023-10-01T00:00:00.000Z",
"dateTo": "2023-10-01T23:59:59.999Z",
"groupBy": ["queue", "mediaType"],
"metrics": [
{
"name": "queue.waitTime",
"type": "interval"
}
],
"filter": {
"type": "boolean",
"predicates": [
{
"type": "field",
"field": "mediaType",
"operator": "in",
"values": ["voice", "chat"]
}
]
}
});
Troubleshooting
I have checked the following:
- The OAuth token has the
view:analyticsscope. - The
groupByarray explicitly includesmediaType. - The filter predicate allows both voice and chat.
Despite this, the response JSON looks like this:
{
"data": [
{
"queueId": "12345",
"queueName": "Support",
"mediaType": "ALL",
"queue.waitTime": 120.5
}
]
}
I expected separate rows for voice and chat. Is there a specific constraint on the groupBy fields for this endpoint, or is my filter predicate interfering with the aggregation logic? I am using the latest stable version of the API docs.