Skip to main content

Twilio Migration Guide

Introduction

This guide will show you how easy it is to migrate your voice calling services to Bandwidth from Twilio. We're the only Twilio alternative with its own nationwide carrier network, giving you the quality, control, and cost-savings that other providers can't match.

Our Voice API and XML structures (TwiML v BXML) are similar, allowing you to seamlessly migrate with low effort. With our comprehensive APIs, you will have everything you need and more to grow your business.

The differences between Twilio and Bandwidth's voice offerings

Most of the features available on Twilio's Programmable Voice are also available on Bandwidth's Programmable Voice API. Therefore, your migration should be straightforward, as getting started is identical for both.

A side-by-side comparison of our Programmable Voice API capabilities.

FeaturesTwilioBandwidth
Receive Calls from PSTN
Make Calls to PSTN
Own Nationwide Carrier NetworkX
Play Audio
Text-to-Speech
SSML Support
Recording (single/dual channel) and storage
Transcription
Media Streaming✓ (Available via audio)
Real-time transcription
Custom Caller ID
Voicemail Detection
Conferencing
Call Forwarding
DTMF-based IVR
Voice Activated IVRX

Migrating your existing voice application

Migrating from Twilio to Bandwidth will require you to refactor your existing code, but most API call logic will remain the same. For example, Bandwidth's BXML must be used directly, and there is no user interface for constructing call flows visually. We also offer SDKs in your preferred language (Node, Python, Ruby, Java, C#, and PHP) and have put together a few examples to demonstrate how easy it is to move to Bandwidth.

How to make an outbound call

In this example we will show you the process of refactoring your code to migrate your existing application from Twilio to Bandwidth by changing just a few lines of code for placing an outbound call.

Twilio:

Note: Remember to add authentication for your application if needed!

curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Calls.json \
--data-urlencode "Url=http://demo.twilio.com/docs/voice.xml" \
--data-urlencode "To=+15017122661" \
--data-urlencode "From=+15558675310" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

Bandwidth:

Note: Remember to add authentication for your application if needed!

POST https://voice.bandwidth.com/api/v2/accounts/{accountId}
//Make sure an authentication header is added with your BANDWIDTH_USERNAME and BANDWIDTH_PASSWORD
{
"from": "{BW_NUMBER}",
"to": "{$USER_NUMBER}",
"applicationId": "{APPLICATION_ID}",
"answerUrl": "http://example.test/callbacks/answer",
}

These are the two primary ways you may have implemented TwiML into your platform, and based on those options, here's how that pathway would look like to Bandwidth:

  • With Twilio, you can place an outbound call with a URL that contains your TwiML. The same is true for Bandwidth, where the answerUrl expects BXML to continue the call with your chosen action.

  • With Twilio, you can also place an outbound call and directly specify your TwiML. However, this is not possible with Bandwidth, but your answerUrl can contain all your equivalent BXML actions.

How to transfer a call

In this example, we will show you the process of refactoring your code to migrate your existing application from Twilio to Bandwidth. All it takes is changing just a few lines of code to transfer a call.

Twilio:

import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Say;
import com.twilio.twiml.TwiMLException;


public class Example {
public static void main(String[] args) {
Dial dial = new Dial.Builder("415-123-4567").build();
Say say = new Say.Builder("Goodbye").build();
VoiceResponse response = new VoiceResponse.Builder().dial(dial)
.say(say).build();

try {
System.out.println(response.toXml());
} catch (TwiMLException e) {
e.printStackTrace();
}
}
}

Bandwidth:

This shows how to use Bandwidth XML to transfer a phone call with a pre-transfer announcement.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Transfer transferCallerId="+15555555555">
<PhoneNumber transferAnswerUrl="/announcement">+15555555554</PhoneNumber>
</Transfer>
</Response>

> The announcement endpoint response from `/announcement` is:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<SpeakSentence>Hey! There's a customer on the line.</SpeakSentence>
</Response>

Twilio uses the <Dial> verb in TwiML to connect the current caller to another party during an active call. For Bandwidth the equivalent function is <Bridge>.

How to use text-to-speech

In this example, we will show you the process of refactoring your code to migrate your existing application from Twilio to Bandwidth for utilizing text-to-speech for outbound calls.

Twilio:

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Say;
import com.twilio.twiml.TwiMLException;


public class Example {
public static void main(String[] args) {
Say say = new Say.Builder("Chapeau!").voice(Say.Voice.WOMAN)
.language(Say.Language.FR_FR).build();
VoiceResponse response = new VoiceResponse.Builder().say(say).build();

try {
System.out.println(response.toXml());
} catch (TwiMLException e) {
e.printStackTrace();
}
}
}

Bandwidth:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
<SpeakSentence voice="julie">
This is a test.
</SpeakSentence>
</Response>

With Twilio, the <Say> verb in TwiML is used for converting text-to-speech that is then read back to the caller. For Bandwidth the equivalent function is <SpeakSentence>.

Additionally, Bandwidth uses Amazon Polly for text-to-speech services with the support of SSML tags. So if you are using Amazon Polly as your text-to-speech provider in Twilio, you can discover the same speaker voice here.

Where to next?

Now that you have seen how easy and comparable Twilio's API is to Bandwidth, check out our in-depth guides to continue to build out your application:

Need additional help?

Our Bandwidth Signature Support is included for free for every customer. Our support comes with a 24/7 Network Operations Center (NOC), Technical Assistance Center (TAC), and a clear path of escalation. We are here for you when you need actual human support that a forum can't cover.

Porting your numbers from Twilio to Bandwidth

Whether you are purchasing new phone numbers to use with Bandwidth or looking to keep your existing phone numbers purchased from Twilio, the process couldn't be easier.

You can port your numbers from Twilio to Bandwidth without devoting any downtime by following a few simple steps in our Porting Numbers guide.

Other API features

Bandwidth has comparable APIs to Twilio fo`r SMS, WebRTC calling, Video, Multi-factor Authentication, Phone Numbers, and 911 Access, all on our own network, providing you with additional cost savings.

Discover our other services today.