• Choose:

Migrating from Twilio

Are you thinking of switching from Twilio to Telnyx? This document describes some key differences between the platforms as well as implementation details for standard SDK features to make your experience as smooth as possible.

How Twilio’s Voice SDK works

With Twilio, a lot of setup is required before you can get started making calls. because users are required to have their own backend in place, with Telnyx this is not needed.

TwiML is similar to Call Control that Telnyx provides - but it isn’t a requirement when using our Voice SDK.

In short, Twilio’s Voice SDK flow is as follows:

  1. Your browser / mobile device connects to Twilio
  2. Twilio connects to your pre-deployed server node application which can generate a token and receive voice webhooks
  3. Twilio sends you a webhook to get TwiML instructions
  4. Your backend server node responds with a set of TwiML instructions that you have defined for certain use cases (eg. call a number, connect to a conference)
  5. Twilio receives your TwiML instructions and executes them on your behalf. (eg. Dial a number contained in your TwiML instructions)
  6. Twilio creates a VoIP connection between your callee and your application.

Flow looks like this:

Caller > Twillio Voice SDK > Twillio Servers > customer backend (Webhook receiver) > Twillio Servers > Callee

It's much easier with the Telnyx Voice SDK

Telnyx’s Voice SDK has been designed to be as simple as possible to make/receive calls in a matter of minutes. Unlike Twilio, there is no backend setup required.

Simply, implement the Voice SDK library on the platform of your choice, and log in with your Telnyx Connection and you’re all set.

To summarize:

  1. Your browser / mobile device connects to Telnyx
  2. You send an invitation from the client
  3. If accepted, Telnyx creates a VoIP connection between your callee and your application.

Flow looks like this:

Caller > Telnyx WebRTC SDK > Telnyx servers > Callee

Optionally, if you would like to control the call, like you do with TwiML, you can use Call Control.

Pricing

Below is a comparison table for the United States region. (Note regional prices may vary).

ServiceTelnyx TerminationTwilio TerminationTelnyx OriginationTwilio Origination
Local Calls0.0070/ min0.0130/ min0.0055/ min0.0085/ min
Toll-Free Call0.0020/ min0.0130/ min0.0170/ min0.0220/ min
Browser / App Calling0.0020/ min0.0040/ min0.0020/ min0.0040/ min
SIP Interface0.0020/ min0.0040/ min0.0020/ min0.0040/ min
Secure Mediaincludedincludedincludedincluded

Sources: https://telnyx.com/pricing/call-control https://www.twilio.com/voice/pricing/us

Comparative Table (Web SDK)

Telnyx RTC Twilio Voice SDK
Portal and server initial configuration
  • No server setup is required.
  • Create SIP connections
  • Buy a phone number and assign it to a SIP connection.
  • Create a TwiML App and find the TwiML App SID and configure a webhook endpoint to make outbound calls
  • Buy a phone number to make outbound and receive inbound calls and configure a webhook to be able to receive incoming calls.
  • Create an API KEY to be able to generate an Access Token
  • Run a server node application to generate token and to receive the voice webhook to exec dial command.
SDK Installation
  • npm i @telnyx/webrtc
  • npm i twillio (backend)
  • npm i @twilio/voice-sdk (front-end)
To make calls
  • The SDK is connected using a SIP username or JWT Token
  • It calls directly between the browsers with the command call.newCall({...})
  • The SDK is connected using a Token. When connecting it will return a Call object that will send a POST in Twillio Sever to /voice endpoint and in the local backend API it will exec the dial command

Connect

Telnyx

   // Initialize the client
   const client = new TelnyxRTC({
     /* Use a JWT to authenticate (recommended) */
     login_token: login_token,
     /* or use your Connection credentials */
     // login: username,
     // password: password,
   });
   // Connect and login
   client.connect();

Twilio

// Download the helper library from https://www.twilio.com/docs/node/install
// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);

Make a call

Telnyx

   const call = client.newCall({
     // Destination is required and can be a phone number or SIP URI
     destinationNumber: '18004377950',
     callerNumber: '‬155531234567',
   });

Twilio

   client.calls
  .create({
     url: 'https://example.com',
     to: '+15558675310',
     from: '+15017122661'
   })
  .then(call => console.log(call.sid));

Answer an incoming a call

Note: in Twilio’s case, a backend server needs to be setup. We have included a Python flask example as well as the client implementation

Telnyx

   client.on('telnyx.notification', (notification) => {
   const call = notification.call;
   if (notification.type === 'callUpdate' && call.state === 'ringing') {
     call.answer();
   }
 });

Twilio

    // Backend Server, in this case Python with flask
   @app.route('/handle_calls', methods=['POST'])
   def call():
     p.pprint(request.form)
     response = VoiceResponse()
     dial = Dial(callerId=twilio_number)
     if 'To' in request.form and request.form['To'] != twilio_number:
       print('outbound call')
       dial.number(request.form['To'])
     else:
       print('incoming call')
       caller = request.form['Caller']
       dial = Dial(callerId=caller)
       dial.client(twilio_number)
     return str(response.append(dial))
 // Client
device.on("incoming", function (conn) {
conn.accept();
});
Was this page helpful?