Skip to main content

Dashboard Quality

Returns aggregate call quality metrics and a daily trend breakdown. Covers talk-to-listen ratio, script adherence, sentiment distribution, interruptions, objection handling, and duration stats.

Endpoint

PropertyValue
Function Namedashboard-quality
HTTP MethodGET
AuthenticationSupabase JWT (Bearer token)

Request

Headers

Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json

Query Parameters

ParameterTypeRequiredDefaultDescription
periodstringNo7dtoday, 7d, 30d, 90d, or custom
start_datestring (ISO date)If period=custom--Start date YYYY-MM-DD
end_datestring (ISO date)If period=custom--End date YYYY-MM-DD
campaign_idstring (UUID)No--Filter to a specific campaign
client_idstring (UUID)No--Filter to a specific client

Response

Success (200)

{
"period": { "start_date": "2026-02-10", "end_date": "2026-02-16" },
"quality": {
"avg_duration_seconds": 180,
"avg_talk_ratio": 0.5500, // 0-1
"avg_listen_ratio": 0.4500, // 0-1
"avg_script_adherence": 0.7200, // 0-1
"total_interruptions": 45,
"avg_interruptions_per_call": 0.38,
"objection_handling_rate": 60.0, // %
"total_buying_signals": 40,
"sentiment_distribution": {
"positive": 72,
"neutral": 36,
"negative": 11,
"positive_pct": 60.5, // %
"neutral_pct": 30.3, // %
"negative_pct": 9.2 // %
}
},
"trend": [
{
"date": "2026-02-10",
"avg_duration_seconds": 165,
"avg_talk_ratio": 0.5800,
"avg_script_adherence": 0.7000,
"sentiment_positive_pct": 55.0,
"interruptions": 8,
"completed_calls": 18
}
// ... one entry per day
]
}

Error Responses

StatusCondition
401Missing or invalid authorization header
403User exists but has no agency_id
405HTTP method is not GET
500Failed to query call_stats_daily

Behavior

  • Authenticates the user via Supabase JWT and resolves their agency_id.
  • Queries call_stats_daily selecting quality-specific columns, ordered by stat_date ascending.
  • Computes aggregate quality metrics using weighted averages (weighted by completed_calls) for ratio fields and sums for count fields.
  • Builds a daily trend array by aggregating multiple rows per date into one. Each trend entry includes averaged metrics for that day plus raw completed_calls count.
  • Sentiment distribution includes both raw counts and computed percentages.

Database Tables

TableOperationDescription
usersReadFetches user profile to determine agency_id
call_stats_dailyReadPre-aggregated daily stats with quality metrics

External APIs

None.