Service Level calc from /api/v2/analytics/details intervals

Trying to calculate Service Level percentages for our queues using the raw interval data from GET /api/v2/analytics/details. I’ve got the interval=5min set up and pulling data for the last hour.

GET /api/v2/analytics/details/queues/{queueId}/intervals?interval=5min&since=2023-10-27T00:00:00Z&until=2023-10-27T01:00:00Z&metric=serviceLevel

The response gives me serviceLevel values in each interval, but they look like averages, not the raw counts I need to compute the percentage manually. How do I get the actual answered vs total calls from this endpoint?

You’re overcomplicating the math. The serviceLevel metric in that endpoint already returns the percentage as a decimal (0.0 to 1.0). You don’t need to calculate it from offered and answered unless you’re doing a deep dive into wait time distributions.

The issue is likely how you’re aggregating the intervals. You can’t just average the interval values. You need a weighted average based on the volume of interactions in each window.

Here’s how I handle it in Python to get the true hourly SL:

total_weighted_sl = 0
total_interactions = 0

for interval in response['entities']:
 # serviceLevel is already a ratio, e.g., 0.85
 sl_ratio = interval['metrics']['serviceLevel']['value'] 
 offered = interval['metrics']['offered']['value']
 
 total_interactions += offered
 total_weighted_sl += (sl_ratio * offered)

final_service_level = (total_weighted_sl / total_interactions) * 100 if total_interactions > 0 else 0

If you just average the serviceLevel values, you’ll skew the results during quiet periods. Stick to the weighted approach. Also, check your since and until timestamps. They need to be inclusive.