Summarize Blog With:

Why Migrate?

Developers building voice AI agents are increasingly moving away from Twilio due to high costs, regional restrictions and latency. Twilio calls to Indian numbers can cost ₹1.20–1.50 per minute (outbound) and ₹0.50–0.80 per minute (inbound), whereas Exotel’s pricing is typically ₹0.80–1.00 for outbound and ₹0.30–0.50 for inbound calls[1]. Exotel bills in INR, offers local support and TRAI‑compliant numbers, and provides low‑latency streaming via AgentStream (<50 ms media latency)[2]. This guide shows how to port a simple Twilio Voice application to Exotel with minimal code changes.

Mapping Twilio Concepts to Exotel

Twilio conceptExotel equivalentNotes
Twilio Account SID / Auth TokenExotel API key & tokenObtain from the Exotel dashboard after creating your account. Exotel uses API keys instead of user credentials and supports regional subdomains (e.g., api.exotel.com for Singapore, api.in.exotel.com for Mumbai)[3].
Phone numbersExophones (virtual numbers)Purchase an Exophone (DID) to use as your CallerId. Exotel numbers are compliant with Indian regulations and route calls via local carriers[4].
Outbound call via client.calls.create()POST /Calls/connect APIExotel’s Connect API connects two numbers by dialling the From number first, then bridging the To number[5].
Twilio callbacks & TwiMLExotel Call Flow & AppletsInstead of generating TwiML, Exotel uses visual call flows and applets (Greeting, Connect, Passthru). You define a call flow in the Exotel dashboard and assign it to your number.
Media streams / Twilio <Stream>Exotel AgentStreamFor AI agents requiring streaming audio, Exotel’s AgentStream provides real‑time RTP/WebSocket streaming with <50 ms latency[2].

Migrating Outbound Calls

Twilio (Node.js)

The typical Twilio call code looks like this:

const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken  = process.env.TWILIO_AUTH_TOKEN;
const client     = require('twilio')(accountSid, authToken);

client.calls
  .create({
    from: '+15017122661',        // your Twilio number
    to:   '+918000123456',       // customer phone number
    url:  'https://example.com/twiml'  // TwiML instructions
  })
  .then(call => console.log(call.sid));

The url points to a TwiML document (XML) that instructs Twilio how to handle the call. If you stream audio for a voice agent, you would use the <Stream> verb.

Exotel Equivalent (Node.js)

With Exotel you call the Connect API to bridge two numbers. Instead of TwiML, call flows are configured in the Exotel dashboard; the CallerId parameter defines which Exophone is displayed to the customer. The API endpoint is https://<API_KEY>:<API_TOKEN>@api.exotel.com/v1/Accounts/<ACCOUNT_SID>/Calls/connect. Here is a minimal Node example using the axios library:

const axios = require('axios');
async function makeCall() {
  const API_KEY   = process.env.EXOTEL_API_KEY;
  const API_TOKEN = process.env.EXOTEL_API_TOKEN;
  const ACCOUNT_SID = process.env.EXOTEL_ACCOUNT_SID;
  const payload = new URLSearchParams();

  payload.append('From', '+918000123456');   // number dialled first
  payload.append('To',   '+918888654321');   // customer number dialled second
  payload.append('CallerId', '+911234567890'); // your Exophone
  payload.append('CallType', 'trans');         // optional: transactional call

  const url = `https://${API_KEY}:${API_TOKEN}@api.in.exotel.com/v1/Accounts/${ACCOUNT_SID}/Calls/connect`;
  try {
    const response = await axios.post(url, payload);
    console.log('Call initiated, SID:', response.data.Call.Sid);
  } catch (err) {
    console.error('Error initiating call', err.response?.data || err.message);
  }
}
makeCall();

Notes:

  • Use the .json suffix on the endpoint to get a JSON response rather than XML.
  • Exotel dials the From number first; swap the numbers if you wish to call the agent second.
  • The API parameters are defined in the Connect API documentation[6].
  • For AI agents, replace the From number with the phone number of your streaming service or SIP trunk (e.g., LiveKit). Use Exotel AgentStream when you need real‑time audio.

Migrating Inbound Calls

In Twilio, incoming calls are handled by associating a webhook URL with your phone number. The webhook returns TwiML instructions. Exotel uses call flows instead. To migrate:

  1. Create a Call Flow in Exotel. Navigate to the Applets section and design your flow using Greeting, Passthru, Connect or SMS applets. For AI voice agents using AgentStream, use a Passthru applet that forwards audio to your streaming URL.
  2. Assign the call flow to your Exophone. This is equivalent to setting a webhook on a Twilio number.
  3. Integrate Webhooks. Exotel sends call status callbacks via HTTP POST to your application. Configure your callback URLs in the dashboard if you need to update CRM systems or analytics.

Migrating Media Streaming

Twilio’s <Stream> verb can stream audio via WebSocket for AI agents. Exotel provides AgentStream, a WebSocket/RTP streaming API with <20 ms media latency[2]. To migrate:

  1. Request access to AgentStream. Contact Exotel support to enable AgentStream on your account. You will receive a streaming URL and API key.
  2. Modify your AI agent to use the Exotel streaming protocol. The streaming contract sends base64‑encoded audio frames (~100 ms frames) and expects TTS audio in return[7]. Exotel’s developer site provides sample Node and Python clients.
  3. Update your voice pipeline. Replace Twilio <Stream> event handlers with the Exotel AgentStream WebSocket; maintain the same STT → LLM → TTS logic. Because Exotel’s media latency is <20 ms, you can achieve faster response times.

Operational Considerations

  • Authentication & Regions: Twilio uses global endpoints; Exotel uses regional subdomains (api.in.exotel.com for India). Ensure you select the correct region for your account[8].
  • Pricing: Evaluate call cost differences based on your volume. Exotel’s local carrier relationships generally yield 30–40 % savings for Indian and APAC traffic[1].
  • Compliance: Exotel is compliant with TRAI regulations. For Indian PSTN traffic, you must use an approved provider. If your Twilio application previously used international DID numbers, you may need to port numbers to Exotel.
  • Feature gaps: Twilio offers advanced features, including pre-built Conversational Intelligence. Exotel focuses on telephony and streaming; you may need third‑party services for advanced analytics.

Summary

Migrating from Twilio to Exotel involves replacing TwiML‑based call handling with Exotel’s Connect API and call flows. The change is straightforward: update your code to invoke Exotel’s Calls/connect endpoint, purchase an Exophone as your caller ID, and reconfigure your media streaming to use AgentStream if needed. With these changes, you can achieve lower latency and 30–40 % cost savings in APAC markets while maintaining similar functionality.


References:

[1][4] Twilio vs Exotel 2025: Which is Better for India? (Pricing + Features) | edesy.in

Twilio vs Exotel 2025: Complete India Comparison | edesy.in

[2] Exotel introduces real-time voice streaming API for AI developers

Exotel introduces real-time voice streaming API for AI developers

[3][5][6][8] Exotel Developer Portal 

Outgoing call to connect two numbers API

[7] Build a Real-Time Speech-to-Speech AI Voice Assistant on Exotel AgentStream (Bidirectional) with OpenAI Realtime & Python | Exotel

Build a Real-Time Speech-to-Speech AI Voice Assistant on Exotel AgentStream (Bidirectional) with OpenAI Realtime & Python

Shiva is Head of Digital Marketing & Developer Network at Exotel, a growing community of builders working with voice, messaging, and AI-powered communication APIs. He has spent 13+ years helping B2B SaaS companies grow through data-driven marketing, and today he's equally focused on helping developers discover, adopt, and get more out of Exotel's platform. He writes about developer ecosystems, voice AI trends, and what it takes to build great CX infrastructure.