Skip to main content

Twilio Integration

This guide walks you through integrating Kallglot with Twilio for real-time voice translation on phone calls.

Prerequisites

  • A Twilio account with a phone number
  • A Kallglot API key
  • A web server to receive webhooks

Architecture

Setup Steps

1. Configure Your Twilio Number

In the Twilio Console:
  1. Go to Phone Numbers > Manage > Active Numbers
  2. Select your number
  3. Under Voice & Fax, set:
    • A Call Comes In: Webhook
    • URL: https://your-app.com/webhooks/twilio/voice
    • Method: POST

2. Create the Webhook Handler

Kallglot does not currently provide official SDKs. The helper functions in these examples, such as createKallglotSession(...), represent ordinary HTTPS calls to the API.

3. Handle Session Events

Set up a webhook to receive session events:

Advanced Configurations

Outbound Calls

For outbound calls, create the session first, then initiate the call:

Conference Calls

For multi-party calls, use Twilio Conferences:

Dynamic Language Detection

Let Kallglot auto-detect the customer’s language:

Error Handling

Handle Session Creation Failures

Handle Stream Disconnections

Twilio sends a status callback when the stream disconnects:

Best Practices

Always use track: 'both_tracks' to send both inbound and outbound audio to Kallglot. This ensures proper speaker separation.
The Twilio webhook must respond quickly (within 15 seconds). Create the session and respond immediately:
End Kallglot sessions when calls complete to stop billing:

Troubleshooting

No audio in translation

  1. Verify the stream URL is correct
  2. Check that track: 'both_tracks' is set
  3. Verify the WebSocket connection is established

High latency

  1. Ensure your server is geographically close to Twilio’s region
  2. Check network latency between your server and Kallglot
  3. Consider using Twilio’s edge locations

Echo or feedback

  1. Ensure you’re not playing translated audio back to the source
  2. Check that speaker identification is working correctly