Trying to pull live queue stats into a Studio flow so we can route calls based on actual wait times instead of static thresholds. We’ve wired up a SNIPPET action that fires a POST to /api/v2/analytics/queues/realtime/query. The idea is straightforward. Assign the queue IDs to a variable, build the query JSON, and pass it through the REST Proxy.
Here’s how we’re constructing the payload inside the SNIPPET:
{
"dateFrom": "2023-10-25T14:00:00Z",
"dateTo": "2023-10-25T15:00:00Z",
"interval": "PT1M",
"groupings": ["queue"],
"select": ["queue.name", "metrics.wait.count", "metrics.wait.avg"],
"where": "queue.id IN ('abc-123', 'def-456')"
}
Step one involves generating the time window. Step two formats the query structure. Step three routes it through the proxy. The timestamps get generated in ASSIGN blocks. Studio handles the formatting just fine. REST Proxy hits the endpoint with Content-Type: application/json and a fresh bearer token. A 400 Bad Request keeps popping up, complaining about invalid interval values. Bumping interval to PT5M just yields an empty array. Documentation claims real-time queries ignore dateFrom and dateTo entirely. SDK examples still include them though. It doesn’t make much sense.
Dropping the where clause works. Pulling every single queue floods the response payload past the 50KB limit we set on the flow variable. Truncation breaks the downstream logic. metrics.wait.avg also returns null even when agents are actively holding calls. Maybe the groupings array needs a different key. Or perhaps the select syntax requires a prefix we’re missing. The Studio flow times out after three retry attempts.