I’ve been pulling raw interval data from the Analytics API to build a custom dashboard for queue performance. I’m using the query for summary aggregates. I’m trying to calculate the Service Level percentage (calls answered within 20 seconds) based on the returned metrics.
The response includes offerCount and answerCount, but I don’t see a direct field for answeredWithinThreshold. I’ve tried summing offerCount and answerCount across all intervals, but the math doesn’t match the native report. Here’s the snippet I’m using to process the payload:
const serviceLevel = (data.intervals.reduce((acc, curr) => {
return acc + (curr.metrics.answerCount.value / curr.metrics.offerCount.value);
}, 0)) / data.intervals.length * 100;
This returns a value way higher than 100% because I’m averaging ratios instead of summing numerators and denominators separately. I need the total answered within 20s divided by total offered. Does the metrics object contain a specific property for threshold-based answers, or am I missing a query parameter in the request body to filter by answeredWithin?