Real-time Voice (WebSocket)
Quick Start
// 1. Connect to WebSocket with authentication
const ws = new WebSocket(
'wss://api.amigo.ai/v1/your-org/conversation/converse_realtime?response_format=voice&audio_format=pcm',
['bearer.authorization.amigo.ai.' + authToken]
);
// 2. Start a conversation when connected
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'client.start-conversation',
service_id: 'your-service-id',
service_version_set_name: 'release'
}));
};
// 3. Handle incoming messages
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === 'server.conversation-created') {
console.log('Ready to chat! Conversation ID:', message.conversation_id);
// Now you can send audio or text messages
}
if (message.type === 'server.new-message' && message.message) {
// Handle audio/text response from agent
handleAgentResponse(message.message);
}
};
// 4. Send a text message
ws.send(JSON.stringify({
type: 'client.new-text-message',
text: 'Hello, how can you help me?',
message_type: 'user-message'
}));What You Can Build
Use Case
Description
Key Features
Feature
Description
Feature
Description
Connection Setup
Endpoint
Regional Endpoints
Region
Endpoint
Query Parameters
Parameter
Type
Required
Description
Example
Authentication
Conversation Flow
Step 1: Connect & Authenticate
Step 2: Initialize Conversation
Option A: Start New Conversation
Option B: Continue Existing Conversation
Step 3: Exchange Messages
Sequence Diagram
Message Reference
Messages You Send (Client → Server)
Send Text
Send Audio
Voice Activity Detection (VAD)
Finish Conversation
Graceful Close
Extend Timeout
Messages You Receive (Server → Client)
Conversation Lifecycle
Agent Responses
Voice Activity Detection (VAD) Mode
How VAD Works
VAD with External Events
VAD Requirements
Audio Configuration
PCM Format (Best for real-time & VAD)
MP3 Format (Bandwidth-efficient)
Language Support
Supported Languages
Language
Code
Error Handling
WebSocket Close Codes
Code
Error
Common Cause
Solution
Error Handling Example
Performance & Limits
Rate Limits
Limit
Value
Notes
Keep Connection Alive
Complete Implementation
Production-Ready WebSocket Client
Common Patterns & Troubleshooting
Connection Flow Diagram
Common Issues & Solutions
Issue
Symptom
Solution
Best Practices
SDK & Framework Support
Current Support
Platform
Status
Notes
Framework Examples
Node.js
Python
Related Documentation
Last updated
Was this helpful?

