Developer Guide

Integrating the Voice Agent

Everything you need to connect real-time conversational voice, programmatically ground business knowledge, and initiate automated phone calls in your applications.

Interactive Documentation

The platform provides two interactive API explorers auto-generated from the live OpenAPI schema. Use them to inspect every parameter, verify JSON schemas, and test endpoints directly from your browser:

System Overview

The Voice Agent platform provides a unified interface for conversational speech. Instead of stitching together separate speech-to-text, LLM, and speech-synthesis APIs, your application communicates with a single endpoint that manages the real-time audio loop, phrase streaming, and instant barge-in interruption.

Developers typically interact with the system in three ways:

Authentication & API Keys

Every inbound request to the Voice Agent platform is authenticated using a secure API Key. Your API key identifies your tenant account and attributes usage quotas, minutes, and billing.

Obtaining an API Key: Contact your system administrator to receive a provisioned va_live_... API key, or generate one from the admin console.

HTTP REST Authentication

Pass your API key in the X-API-Key header or standard Authorization: Bearer <key> header:

curl -X POST https://voiceagent.coetara.com/api/v1/chat \
  -H "X-API-Key: va_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello, how can I buy tickets?"}'

WebSocket Audio Stream Authentication

When connecting to the live voice streaming WebSocket, supply your API key as a query parameter or via the X-API-Key handshake header:

const socket = new WebSocket('wss://voiceagent.coetara.com/ws?api_key=va_live_your_api_key_here');

Teaching the Agent (Knowledge Base)

You can programmatically teach the voice agent facts, event schedules, pricing tables, or custom instructions. Anything stored in the Knowledge Base is automatically and immediately incorporated into the agent's memory during live calls and chat turns.

POST /api/v1/knowledge

Add a new fact or instruction to the agent's grounded memory:

curl -X POST https://voiceagent.coetara.com/api/v1/knowledge \
  -H "Content-Type: application/json" \
  -d '{
    "title": "VIP Ticket Access",
    "content": "VIP tickets include fast-track entry, complimentary drinks at the lounge, and backstage access after 9 PM.",
    "tags": ["tickets", "vip", "pricing"]
  }'
GET /api/v1/knowledge

Inspect what the agent knows and view the compiled prompt context:

curl https://voiceagent.coetara.com/api/v1/knowledge

You can also query specific knowledge items by ID, update them with PUT /api/v1/knowledge/{id}, or erase them with DELETE /api/v1/knowledge/{id}.

Telephony Integration (Africa's Talking)

The platform natively supports carrier telephone calls across Africa via Africa's Talking Voice. You can trigger automated outbound phone calls or configure an inbound phone number to act as an automated voice agent.

Triggering an Outbound Phone Call

POST /api/v1/telephony/call

Place a phone call to a recipient's mobile number:

curl -X POST https://voiceagent.coetara.com/api/v1/telephony/call \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+2348012345678",
    "initial_message": "Hello, this is Tickethub calling to confirm your event booking."
  }'

Handling Inbound & Outbound Call Webhooks

Set your Africa's Talking Voice Callback URL to:

https://voiceagent.coetara.com/api/v1/telephony/africastalking/callback

When a call connects, the platform handles the conversation turn loop, processes the caller's spoken response, queries the grounded Knowledge Base, and responds with dynamic Voice XML.

Real-Time Streaming WebSocket

For custom browser interfaces or mobile applications, connect directly to the streaming audio WebSocket at wss://voiceagent.coetara.com/ws.

Audio Format Specification

Direction Encoding Sample Rate Channels
Client ➔ Server (Microphone) Linear 16 PCM (16-bit little endian) 16,000 Hz 1 (Mono)
Server ➔ Client (Speaker) Linear 16 PCM (16-bit little endian) 24,000 Hz 1 (Mono)

Lifecycle & Interruption Events

The server streams binary audio chunks alongside JSON control events:

REST Conversational Endpoints

If you prefer standard HTTP requests rather than persistent WebSockets:

POST /api/v1/chat

Send user text and receive an intelligent response with base64-encoded audio:

curl -X POST https://voiceagent.coetara.com/api/v1/chat \
  -H "Content-Type: application/json" \
  -d '{
    "text": "What are your refund policies?",
    "voice": "female-shaonv",
    "return_audio": true
  }'
POST /api/v1/tts

Direct text-to-speech synthesis returning raw streaming WAV audio.

POST /api/v1/stt

Upload an audio recording to transcribe it into text.

For complete parameter details, response schemas, and interactive test consoles, visit the Swagger UI or ReDoc pages.