Vaja Telephony Integration

FreeSWITCH WebSocket Integration Guide

Quick Start

Connect your FreeSWITCH to Vaja by updating your WebSocket URL:

# Change this line in your FreeSWITCH configuration: WS_URL = "wss://vaja.ai/ws?apiKey=YOUR_API_KEY&protocol=json&encoding=mulaw"
That's it! No other code changes needed.

1. WebSocket Connection

URL Format

wss://vaja.ai/ws?apiKey=YOUR_API_KEY&protocol=json&encoding=mulaw

Required Parameters

Parameter Value Description
apiKey Your API key Provided by Vaja team
protocol json Enables telephony mode
encoding mulaw Audio codec (use mulaw for North America)

2. Message Protocol

1Start Call

Send when call begins:

{ "event": "start", "streamSid": "unique-call-id" }

2Send Audio

Send audio chunks (recommended: 20ms chunks):

{ "event": "media", "media": { "payload": "base64_encoded_mulaw_audio" }, "streamSid": "unique-call-id" }
Audio Format: 8kHz sample rate, μ-law encoded, Base64-encoded

3Receive Response

Vaja sends AI responses in the same format:

{ "event": "media", "media": { "payload": "base64_encoded_mulaw_audio" } }

Decode the base64 payload and play to caller.

4End Call

Send when call ends:

{ "event": "stop", "streamSid": "unique-call-id" }

3. Audio Requirements

Setting Value
Sample Rate 8000 Hz (8kHz)
Encoding μ-law (PCMU)
Format Base64-encoded
Chunk Size 160 bytes (20ms) recommended

4. Testing Your Integration

  1. Update your FreeSWITCH WebSocket URL with the Vaja endpoint
  2. Make a test call to your DID number
  3. Verify audio is being sent/received
  4. Confirm AI responses are audible
  5. Test call end scenarios

5. Common Issues

Connection Failed

No Audio Response

Poor Audio Quality

6. Support

Need help? Contact us: