Calculating Service Level % from /api/v2/analytics/queues/realtime/intervals

Hey everyone,

I’m trying to calculate the real-time Service Level percentage for a specific queue using the Analytics API. I’ve been pulling data from the queue observations query endpoint and trying to do the math in Python.

The observation data gives me offered and answered counts, but I also need the time-to-answer to determine if a call was answered within the 20-second threshold. The observation object has a start and end timestamp, but it doesn’t seem to have a breakdown of how many of those answered calls actually met the service level target within that specific bucket.

Here’s the snippet I’m working with:

response = api_instance.post_analytics_queues_observations_query(
 body={
   "interval": "PT5M",
   "groupBy": ["queue/id"],
   "view": "queue",
   "select": ["offered", "answered", "abandoned"]
 }
)

for observation in response.entities:
 total_offered = observation.accumulated.offered
 total_answered = observation.accumulated.answered
 # How do I filter for answered < 20s?

The accumulated object just gives me totals. If I look at the observation object instead, the numbers are too granular and I can’t seem to sum them up correctly for the last 15 minutes without missing some edge cases where a call spans two observations.

Is there a specific field I’m missing in the observation payload that tells me the count of calls answered within the threshold? Or do I need to switch to a different analytics view and parse the percentAnswered field differently?

The current approach feels hacky because I’m trying to reverse-engineer the percentage from raw counts that don’t explicitly state their adherence to the SLA target.

The intervals endpoint aggregates counts, so you can’t calculate SL% from it directly. You need to query the queue observations to get the raw data required to calculate service level percentages, as the API does not expose a direct serviceLevel field in the realtime analytics endpoints.

1 Like