Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Analytics API

The Analytics API provides endpoints for tracking, analyzing, and reporting on bot usage and performance metrics.

Status: Roadmap

This API is on the development roadmap. The endpoints documented below represent the planned interface design.

Base URL

http://localhost:9000/api/v1/analytics

Authentication

Uses the standard botserver authentication mechanism with appropriate role-based permissions.

Endpoints

Usage Statistics

MethodEndpointDescription
GET/api/v1/analytics/usageGet overall usage statistics
GET/api/v1/analytics/usage/dailyGet daily usage breakdown
GET/api/v1/analytics/usage/monthlyGet monthly usage summary

Conversation Metrics

MethodEndpointDescription
GET/api/v1/analytics/conversationsGet conversation metrics
GET/api/v1/analytics/conversations/volumeGet conversation volume over time
GET/api/v1/analytics/conversations/durationGet average conversation duration
GET/api/v1/analytics/conversations/resolutionGet resolution rate metrics

User Engagement

MethodEndpointDescription
GET/api/v1/analytics/engagementGet user engagement metrics
GET/api/v1/analytics/engagement/retentionGet user retention data
GET/api/v1/analytics/engagement/satisfactionGet satisfaction scores

Reports

MethodEndpointDescription
POST/api/v1/analytics/reportsGenerate a custom report
GET/api/v1/analytics/reports/{report_id}Get report by ID
GET/api/v1/analytics/reportsList all reports

Real-time Metrics

MethodEndpointDescription
GET/api/v1/analytics/realtimeGet real-time metrics
GET/api/v1/analytics/realtime/activeGet active sessions count

Request Examples

Get Usage Statistics

stats = GET "/api/v1/analytics/usage"
TALK "Total conversations: " + stats.total_conversations
TALK "Active users: " + stats.active_users

Get Daily Usage

daily = GET "/api/v1/analytics/usage/daily?days=7"
FOR EACH day IN daily.data
    TALK day.date + ": " + day.conversations + " conversations"
NEXT

Generate Custom Report

report_config = NEW OBJECT
report_config.type = "engagement"
report_config.start_date = "2025-01-01"
report_config.end_date = "2025-01-31"
report_config.format = "pdf"

report = POST "/api/v1/analytics/reports", report_config
TALK "Report ID: " + report.id

Get Real-time Metrics

realtime = GET "/api/v1/analytics/realtime"
TALK "Active sessions: " + realtime.active_sessions
TALK "Messages per minute: " + realtime.messages_per_minute

Response Codes

CodeDescription
200Success
400Bad Request (invalid parameters)
401Unauthorized
403Forbidden (insufficient permissions)
404Not Found
500Internal Server Error

Query Parameters

Time Range Filters

ParameterTypeDescription
start_dateStringStart date (ISO 8601 format)
end_dateStringEnd date (ISO 8601 format)
daysIntegerNumber of days to include
periodStringPredefined period (today, week, month, year)

Grouping Options

ParameterTypeDescription
group_byStringGroup results by (hour, day, week, month)
bot_idUUIDFilter by specific bot
user_idUUIDFilter by specific user

Required Permissions

Endpoint CategoryRequired Role
Usage Statisticsanalytics_viewer or admin
Conversation Metricsanalytics_viewer or admin
User Engagementanalytics_viewer or admin
Reportsanalytics_admin or admin
Real-time Metricsanalytics_viewer or admin