How To Route Traffic from Twilio To Hundreds of carriers using TwiML

Ameed Jamous
3 min readNov 15, 2019

--

This tutorial explains how using Twilio’s TwiML bins and TelecomsXChange (TCXC) Platform can save bring on huge cost savings and boost overall call quality. If you’re utilizing Twilio Programmable Voice SDKs or if you have a number hooked to a TwiML App this tutorial is right for you.

By end of this quick tutorial, you will also be able to boost your voice quality, pass significant savings and reroute traffic from one carrier to another with a simple value update in your TwiML code.

Let’s get started.

For this trick to work you will need have the following:

TCXC is a commission-free and open platform that gives you wholesale rate access to many direct tier 1,2,3 carriers around the world. Including TATA, AirTel, Verizon , IDT and hundreds more. By having a buyer account you’ll be able to terminate calls originated from the Twilio network to hundreds of voice carriers already available on the TCXC network.

Use case

Acme Inc, carries 1 million minutes a month to India using Twilio API, it wants to keep using Twilio APIs as their application is built already on it, but they want to route calls going to India via Airtel where the cost for that is $0.0044/minute vs $0.038/minute on Twilio

Dropping costs down from $38,000/mo to $4,400/mo while boosting quality

Let’s do the math, so Acme inc. has 1 million minutes per month to India routing at $0.038/min currently using Twilio’s network, but now they are routing to $0.0044/min, On the next bill, Acme inc. is dropping the cost from $38,000 usd to $4,400.

At the same time Acme Inc. is boosting the call quality by routing the traffic directly to the end carrier (Airtel), TCXC is a SIP signaling platform only so all media travels directly between you and the end carrier (Airtel) in this case.

Configuring Twilio to route calls to Airtel via TCXC

Once thing you have to do before you update your TwiML application code, In TCXC portal under accounts page you’ll simply whitelist Twilio’s signaling IPs for your account.

Now to make this happen and route calls from Twilio to Airtel via TCXC, we will utilize Twilio markup language (TwiML) which allows you to use <dial> and <sip> verbs to forwards calls to another SIP network.

  1. Go to your TwiML settings
  2. Update your TwiML code as shown below
Routing the calls from Twilio to Bharti Airtel

As you can notice, there is a SIP header in the sip url X-carrier-prefix which is used to pass on the unique carrier prefix for Airtel on TCXC platform, in Airtel’s case its 73297#.

To reroute the calls via TATA communications, you simply just change the X-carrier-prefix value to 32270#

Routing from Twilio to TATA communications

Now calls reaching your TwiML bin/app will be routed directly to Airtel or TATA depends on what you choose, you can use hundreds of other direct carriers or bring your own carrier (BYOC) to TCXC.

To reroute calls from one carrier to another you only need to update the X-carrier-prefix value in your TwiML code ongoing, or take it further and build LCR based routing by using the TelecomsXChange Programmable X APIs to get carrier rates in realtime.

I hope you found this quick write up useful, if you have any questions please do not hesitate to reach out or leave a comment.

--

--

Ameed Jamous

Entrepreneur, Open Source Contributor, CPaaS Evangelist - Founder @TelecomsXChange