Calculating Service Level % from raw Analytics API interval data

Trying to calculate Service Level percentage using the raw interval data from the Genesys Cloud Analytics API. The endpoint is GET /api/v2/analytics/queues/summary. I pull the data for a 24-hour window with a 15-minute interval. The response gives me answeredCount, abandonedCount, and handledCount. It also provides serviceLevel as a boolean in each interval.

The problem is aggregating this correctly. If I just sum the answeredCount where serviceLevel is true and divide by the total answeredCount, the number feels off compared to the UI. I suspect I need to weight by the interval duration or handle partial intervals differently. Here is the snippet I am using in C# to process the response:

csharp
var totalAnswered = intervals.Sum(i => i.answeredCount);
var answeredInSL = intervals.Sum(i => i.serviceLevel ? i.answeredCount : 0);
var slPercent = totalAnswered > 0 ? (answeredInSL / (double)totalAnswered) * 100 : 0;

The UI shows 82% but my code calculates 78%. Is the API returning truncated counts? Or am I missing a field like waitTime to calculate the actual time in queue? I checked the docs but they do not explain the weighting logic for interval aggregation. The timezone is US/Pacific so daylight saving might be shifting the intervals too. Any ideas on the correct formula?

Hey,

The trap here is treating serviceLevel as a metric you can sum. It’s just a boolean flag per interval, so summing it tells you nothing about the actual percentage. You need to calculate the weighted average based on the volume of conversations in each interval.

Here’s how I handle this in Python. You pull the intervals, loop through them, and track the total answered calls and the total answered calls that met the SLA. The API gives you serviceLevel (true/false) alongside answeredCount. If serviceLevel is true, those answeredCount calls contributed to the SLA.

total_answered = 0
total_sla_met = 0

for interval in response['items']:
 answered = interval['metrics']['answered']['count']
 # Check if the majority of calls in this interval met the threshold
 # Note: The API returns true if the interval's SLA % >= target
 # But for precise calc, we often rely on the boolean flag provided
 if interval['metrics']['serviceLevel']['value']:
 # This is a simplification. The boolean indicates if the interval 
 # as a whole met the SLA threshold defined in the query.
 # For a precise "percentage of calls answered in time", 
 # you actually need the raw 'answerSpeed' histogram or 
 # use the 'serviceLevel' metric's 'count' if available in newer endpoints.
 # However, using the boolean flag on answered count is the common quick hack.
 total_sla_met += answered
 total_answered += answered

if total_answered > 0:
 overall_sl = (total_sla_met / total_answered) * 100
 print(f"Calculated SL: {overall_sl}%")

Wait, that logic above is slightly flawed if the boolean represents the interval average, not every single call. The boolean serviceLevel.value tells you if the interval’s performance met the target, not that 100% of calls were answered in time.

The correct way is to use the serviceLevel metric’s count if you query with metric: serviceLevel. But if you only have answeredCount and the boolean, you’re stuck estimating.

Better approach: Query specifically for metric: serviceLevel and metric: answered. The serviceLevel metric in the response will have a count field representing the number of conversations that met the SLA threshold.

# In your query params:
params = {
 "interval": "PT15M",
 "from": start_time,
 "to": end_time,
 "metrics": "serviceLevel,answered" # Crucial
}

# Then in processing:
total_sla_met = sum(i['metrics']['serviceLevel']['count'] for i in response['items'])
total_answered = sum(i['metrics']['answered']['count'] for i in response['items'])
overall_sl = (total_sla_met / total_answered) * 100

This gives you the exact percentage. Don’t rely on the boolean flag for aggregation.

is spot on. Summing booleans is useless. You need the weighted average. In Kotlin, I map the intervals and sum answeredCount alongside serviceLevelCount (when true). Divide the SLA hits by total answered. Simple math, but easy to mess up if you ignore the interval volume.