I’m building a custom reporting dashboard in C# using the Genesys Cloud .NET SDK to show real-time service levels. The built-in reports are too slow for our ops team, so we need to query the raw interval data and calculate the percentage ourselves.
I’m POSTing to the analytics ICD query endpoint with this request body:
{
"queries": [
{
"id": "q1",
"type": "icd",
"groupBy": ["interval"],
"select": [
{"name": "offered", "type": "sum"},
{"name": "answered", "type": "sum"}
],
"filter": {
"type": "and",
"filters": [
{"name": "routingQueueId", "type": "in", "values": ["my-queue-id"]},
{"name": "dateInterval", "type": "interval", "value": {"start": "2024-05-01T00:00:00Z", "end": "2024-05-01T23:59:59Z"}}
]
}
}
],
"size": 100
}
The API returns the offered and answered counts per interval correctly. I’m calculating Service Level as (answered / offered) * 100. But the numbers don’t match the Service Level metric in the Genesys Cloud UI. The UI shows 85% for the day, but my calculation gives 92%.
I know Service Level usually implies a speed of answer threshold (like 20 seconds). The interval data doesn’t seem to have a specific field for “answered within SLA”. I tried adding "name": "answerWithinServiceLevel", "type": "sum" to the select array, but the API returns a 400 Bad Request saying that metric isn’t valid for this query type.
Is there a different metric name I should use? Or do I need to pull the answerTime for each interaction and compare it against the offered count manually? That would require a massive number of API calls.
Also, the timezone handling is tricky. My queue is set to America/Sao_Paulo, but the API expects UTC in the filter. I’m converting the start/end times using TimeZoneInfo.ConvertTimeFromUtc(), but I’m not sure if the interval boundaries align perfectly with the UI’s daily reports.
Here’s the relevant C# snippet for the calculation:
csharp
var slPercentage = queryResult.Results[0].Rows
.Select(r => (r["answered"] as double?) / (r["offered"] as double?))
.Where(sl => sl.HasValue)
.Average();
What am I missing here? The docs mention “serviceLevel” in some contexts but don’t give a clear example for interval queries.