Attendance API 🟡 BETA

Queue management, attendant assignment, session handling, webhooks, and LLM-powered assistance


Base URL

/api/attendance

Authentication

All endpoints require a valid session token via Authorization: Bearer <token> header.


Queue & Session Endpoints

Get Queue

GET /api/attendance/queue

Returns all sessions currently waiting in the queue.

ParameterTypeRequiredDescription
statusstringNoFilter: waiting, active, resolved, all (default: waiting)
prioritystringNoFilter: high, medium, low
channelstringNoFilter: chat, voice, email, webhook
limitintegerNoMax results (default: 50)

Response:

{
  "queue": [
    {
      "session_id": "sess_001",
      "user_name": "João Silva",
      "user_email": "joao@example.com",
      "channel": "chat",
      "priority": "high",
      "status": "waiting",
      "wait_time_seconds": 120,
      "queue_position": 1,
      "first_message": "Preciso de ajuda com meu pedido",
      "tags": ["billing", "urgent"]
    }
  ],
  "total_waiting": 8,
  "average_wait_seconds": 95
}

Get Attendants

GET /api/attendance/attendants

Returns all available attendants and their current status.

ParameterTypeRequiredDescription
statusstringNoFilter: available, busy, offline, all
skillstringNoFilter by skill tag

Response:

{
  "attendants": [
    {
      "id": "agent_001",
      "name": "Maria Santos",
      "status": "available",
      "current_sessions": 2,
      "max_sessions": 5,
      "skills": ["billing", "technical"],
      "average_resolution_time_seconds": 300,
      "satisfaction_score": 4.7
    }
  ],
  "total_available": 5,
  "total_busy": 3
}

Assign Session

POST /api/attendance/assign

Manually assigns a waiting session to an available attendant.

ParameterTypeRequiredDescription
session_idstringYesSession to assign
attendant_idstringYesAttendant to receive the session

Response:

{
  "session_id": "sess_001",
  "attendant_id": "agent_001",
  "attendant_name": "Maria Santos",
  "assigned_at": "2026-06-04T10:05:00Z",
  "status": "active"
}

Assign by Skill

POST /api/attendance/assign-by-skill

Assigns a session to the best available attendant based on required skills.

ParameterTypeRequiredDescription
session_idstringYesSession to assign
skillsstring[]YesRequired skills for the session
prioritystringNohigh, medium, low (default: medium)

Response:

{
  "session_id": "sess_001",
  "attendant_id": "agent_001",
  "attendant_name": "Maria Santos",
  "matched_skills": ["billing"],
  "assigned_at": "2026-06-04T10:05:00Z"
}

Transfer Session

POST /api/attendance/transfer

Transfers a session from one attendant to another.

ParameterTypeRequiredDescription
session_idstringYesSession to transfer
to_attendant_idstringYesTarget attendant
reasonstringNoTransfer reason

Response:

{
  "session_id": "sess_001",
  "from_attendant_id": "agent_001",
  "to_attendant_id": "agent_002",
  "transferred_at": "2026-06-04T10:15:00Z",
  "transfer_history": [
    {
      "from": "agent_001",
      "to": "agent_002",
      "reason": "Specialized in billing",
      "at": "2026-06-04T10:15:00Z"
    }
  ]
}

Resolve Session

POST /api/attendance/resolve

Marks a session as resolved with optional resolution notes.

ParameterTypeRequiredDescription
session_idstringYesSession to resolve
resolutionstringNoResolution notes
satisfaction_ratingintegerNoRating 1-5
tagsstring[]NoResolution tags

Response:

{
  "session_id": "sess_001",
  "status": "resolved",
  "resolved_at": "2026-06-04T10:30:00Z",
  "resolution": "Order refunded successfully",
  "satisfaction_rating": 5,
  "resolution_time_seconds": 900
}

Session Insights

GET /api/attendance/insights/:session_id

Returns AI-generated insights and sentiment analysis for a session.

ParameterTypeRequiredDescription
session_idpathYesSession identifier

Response:

{
  "session_id": "sess_001",
  "sentiment": {
    "overall": "neutral",
    "score": 0.6,
    "trend": "improving",
    "detected_emotions": ["frustrated", "hopeful"]
  },
  "key_topics": ["billing", "refund", "order #1234"],
  "urgency_score": 0.7,
  "suggested_actions": [
    "Offer partial refund",
    "Explain billing policy",
    "Escalate to supervisor if not resolved"
  ],
  "conversation_quality": {
    "response_time_avg_seconds": 45,
    "resolution_attempted": true,
    "customer_engagement": "medium"
  }
}

Kanban View

GET /api/attendance/kanban

Returns sessions organized in Kanban columns for visual queue management.

ParameterTypeRequiredDescription
filterstringNoComma-separated status filter

Response:

{
  "columns": {
    "waiting": [
      {
        "session_id": "sess_002",
        "user_name": "Ana Costa",
        "priority": "medium",
        "wait_time_seconds": 60,
        "channel": "chat"
      }
    ],
    "active": [
      {
        "session_id": "sess_001",
        "user_name": "João Silva",
        "attendant_name": "Maria Santos",
        "duration_seconds": 300,
        "channel": "chat"
      }
    ],
    "resolved": [
      {
        "session_id": "sess_000",
        "user_name": "Carlos Lima",
        "resolved_at": "2026-06-04T09:50:00Z",
        "satisfaction_rating": 5,
        "channel": "voice"
      }
    ]
  },
  "summary": {
    "waiting": 3,
    "active": 5,
    "resolved": 12
  }
}

Respond to Session

POST /api/attendance/respond

Sends a message to a session from the attendance system.

ParameterTypeRequiredDescription
session_idstringYesTarget session
messagestringYesMessage content
attendant_idstringNoAttendant sending (auto-detected if omitted)

Response:

{
  "session_id": "sess_001",
  "message_id": "msg_005",
  "sent_at": "2026-06-04T10:10:00Z",
  "delivered": true
}

WebSocket Connection

GET /api/attendance/ws

Establishes a WebSocket connection for real-time queue updates.

ParameterTypeRequiredDescription
tokenqueryYesAuthentication token

WebSocket Messages (Server → Client):

{
  "event": "session_queued",
  "data": {
    "session_id": "sess_002",
    "user_name": "Ana Costa",
    "priority": "medium",
    "queue_position": 2
  }
}
{
  "event": "session_assigned",
  "data": {
    "session_id": "sess_001",
    "attendant_id": "agent_001",
    "attendant_name": "Maria Santos"
  }
}
{
  "event": "queue_stats",
  "data": {
    "waiting": 3,
    "active": 5,
    "available_agents": 2
  }
}

Webhooks

List Webhooks

GET /api/attendance/webhooks

Returns all configured webhooks for the attendance system.

ParameterTypeRequiredDescription
activebooleanNoFilter by active status

Response:

{
  "webhooks": [
    {
      "id": "wh_001",
      "name": "Slack Notification",
      "url": "https://hooks.slack.com/services/T00/B00/xxx",
      "events": ["session_queued", "session_resolved"],
      "active": true,
      "created_at": "2026-06-01T10:00:00Z"
    }
  ]
}

Create Webhook

POST /api/attendance/webhooks

Creates a new webhook subscription.

ParameterTypeRequiredDescription
namestringYesWebhook name
urlstringYesTarget URL
eventsstring[]YesEvents to subscribe: session_queued, session_assigned, session_resolved, session_transferred
headersobjectNoCustom headers
activebooleanNoEnable immediately (default: true)

Response:

{
  "id": "wh_002",
  "name": "CRM Sync",
  "url": "https://crm.example.com/webhook",
  "events": ["session_resolved"],
  "headers": { "X-API-Key": "secret_key" },
  "active": true,
  "secret": "webhook_secret_abc"
}

Get Webhook

GET /api/attendance/webhooks/:id

Returns details of a specific webhook.

ParameterTypeRequiredDescription
idpathYesWebhook identifier

Response:

{
  "id": "wh_001",
  "name": "Slack Notification",
  "url": "https://hooks.slack.com/services/T00/B00/xxx",
  "events": ["session_queued", "session_resolved"],
  "active": true,
  "last_triggered_at": "2026-06-04T10:30:00Z",
  "total_deliveries": 342,
  "failed_deliveries": 2
}

Update Webhook

PUT /api/attendance/webhooks/:id

Updates an existing webhook configuration.

ParameterTypeRequiredDescription
idpathYesWebhook identifier
namestringNoUpdated name
urlstringNoUpdated URL
eventsstring[]NoUpdated events
activebooleanNoToggle active status

Response:

{
  "id": "wh_001",
  "name": "Slack Notification",
  "updated_at": "2026-06-04T10:45:00Z"
}

Delete Webhook

DELETE /api/attendance/webhooks/:id

Deletes a webhook subscription.

ParameterTypeRequiredDescription
idpathYesWebhook identifier

Response:

{
  "deleted": true,
  "id": "wh_001"
}

Test Webhook

POST /api/attendance/webhooks/:id/test

Sends a test payload to the webhook URL.

ParameterTypeRequiredDescription
idpathYesWebhook identifier

Response:

{
  "webhook_id": "wh_001",
  "test_sent": true,
  "response_status": 200,
  "response_body": "ok",
  "delivered_at": "2026-06-04T10:50:00Z"
}

LLM Assist API

Get Tips

POST /api/attendance/llm-assist/tips

Returns AI-generated response tips for the current conversation context.

ParameterTypeRequiredDescription
session_idstringYesSession identifier
contextstringNoAdditional context about the conversation

Response:

{
  "session_id": "sess_001",
  "tips": [
    {
      "type": "suggestion",
      "text": "Mentione que o reembolso será processado em até 3 dias úteis",
      "confidence": 0.85,
      "category": "billing"
    },
    {
      "type": "warning",
      "text": "Cliente demonstra frustração. Considere oferecer desconto de 10%",
      "confidence": 0.72,
      "category": "escalation"
    }
  ],
  "generated_at": "2026-06-04T10:05:00Z"
}

Polish Response

POST /api/attendance/llm-assist/polish

Refines a draft response for better clarity and professionalism.

ParameterTypeRequiredDescription
textstringYesDraft response to polish
tonestringNoformal, friendly, empathetic (default: formal)
languagestringNoTarget language (default: pt-BR)

Response:

{
  "original": "Seu pedido foi cancelado. O dinheiro volta em 3 dias.",
  "polished": "Prezado(a) cliente, informamos que seu pedido foi cancelado com sucesso. O valor será estornado em sua conta em até 3 dias úteis.",
  "tone": "formal",
  "changes": [
    {
      "type": "greeting",
      "before": "(none)",
      "after": "Prezado(a) cliente"
    },
    {
      "type": "formality",
      "before": "O dinheiro volta",
      "after": "O valor será estornado"
    }
  ]
}

Suggest Replies

POST /api/attendance/llm-assist/replies

Generates multiple suggested replies for the attendant to choose from.

ParameterTypeRequiredDescription
session_idstringYesSession identifier
countintegerNoNumber of suggestions (default: 3)
contextstringNoAdditional context

Response:

{
  "session_id": "sess_001",
  "replies": [
    {
      "text": "Entendo sua frustração, João. Vou verificar o status do seu pedido agora mesmo.",
      "tone": "empathetic",
      "confidence": 0.91
    },
    {
      "text": "Olá! Peço desculpas pelo inconveniente. Permita-me verificar os detalhes do seu pedido.",
      "tone": "formal",
      "confidence": 0.87
    },
    {
      "text": "Oi João! Vou dar uma olhada no seu pedido. Um momento, por favor.",
      "tone": "friendly",
      "confidence": 0.82
    }
  ],
  "generated_at": "2026-06-04T10:05:00Z"
}

Session Summary

GET /api/attendance/llm-assist/summary/:session_id

Returns an AI-generated summary of the entire session.

ParameterTypeRequiredDescription
session_idpathYesSession identifier

Response:

{
  "session_id": "sess_001",
  "summary": "Cliente João Silva entrou em contato sobre cancelamento do pedido #12345. Motivo: produto com defeito. Atendente Maria Santos processou reembolso de R$ 149,90. Cliente satisfeito com resolução.",
  "key_points": [
    "Pedido #12345 cancelado por defeito",
    "Reembolso de R$ 149,90 processado",
    "Cliente satisfeito com resolução"
  ],
  "resolution_type": "refund",
  "duration_seconds": 600,
  "satisfaction_rating": 5,
  "follow_up_required": false
}

Sentiment Analysis

POST /api/attendance/llm-assist/sentiment

Returns real-time sentiment analysis for a conversation.

ParameterTypeRequiredDescription
session_idstringYesSession identifier
messagesstring[]NoSpecific messages to analyze

Response:

{
  "session_id": "sess_001",
  "overall_sentiment": "neutral",
  "score": 0.6,
  "trend": "improving",
  "timeline": [
    {
      "message_index": 0,
      "sentiment": "negative",
      "score": 0.2
    },
    {
      "message_index": 1,
      "sentiment": "neutral",
      "score": 0.5
    },
    {
      "message_index": 2,
      "sentiment": "positive",
      "score": 0.8
    }
  ],
  "emotions_detected": ["frustration", "relief", "satisfaction"],
  "escalation_risk": "low"
}

See Also