SIP • Last Updated 9/29/2023

Twilio TwiML Conferencing on Telnyx

Using TeXML Translator, you can switch to Telnyx with your existing TwiML code and the Twilio SDK. Find out how.

By Pete Christianson

Twilio TwiML Conferencing on the Telnyx Programmable Voice API

TeXML Translator already covers a suite of commands so you can switch your programmable voice solution from the Twilio API with ease. Now, we’ve added conferencing to that list. And, by using the Telnyx voice API to execute your TwiML code — you’ll experience better call quality at significantly lower costs.

How to Use Twilio TwiML Conferencing on Telnyx With Your Python App

In this tutorial, we’ll show you how to use the Telnyx Voice API to create and manage conference calls with your Python web application. Take a look at our Developer Center for step by step TwiML tutorials for C#, Node, PHP, Java and Ruby.

A simple conference call

A simple conference call: Python

Buy a phone number and configure your connection

In the Telnyx Mission Control Portal you can search for and buy phone numbers in countries around the world. Numbers that have voice capability can make and receive voice phone calls from just about anywhere.

Once you purchase a number, you'll need to configure that number to send a request to your web application. This callback mechanism is called a webhook. You'll need to create a connection and point that to your web application so that Telnyx can make a HTTP request when you receive a call. Configure the connection for Call Control and select XML as the implementation to configure Telnyx to execute your TwiML code. For the URL enter in your current TwiML application URL. If you don't have an application URL yet, we'll create one at a later step using ngrok.

Set up your web application

Set up your web application: Python

Telnyx makes answering a phone call as easy as responding to an HTTP request. When a phone number you've bought through Telnyx receives an incoming call, Telnyx will send an HTTP request to your web application asking for instructions on how to handle the call.

Your server will respond with an XML document containing TwiML that instructs Telnyx on what to do with the call. Those instructions can direct Telnyx to read out a message, play an MP3 file, make a recording and much more.

To start answering phone calls, you must:

  1. Buy and configure a Telnyx-powered phone number capable of making and receiving phone calls, link it to a connection and point it at your web application.
  2. Write a web application to tell Telnyx how to handle the incoming call using TwiML.
  3. Make your web application accessible on the internet so Telnyx can make an HTTP request when you receive a call.

Create a moderated conference call

Now comes the fun part - writing code that will handle an incoming HTTP request from Telnyx!

In this example we'll use Python to respond to Telnyx's request and we'll use the existing Twilio (not Telnyx!) Python SDK to generate our TwiML.

Create a moderated conference call using the Telnyx voice API: Python

Use the Conference TwiML (TeXML) noun to create a conference that begins only when a moderator joins In this example we use a couple advanced Conference features to allow one participant, our "moderator", to better control the call:

  • startConferenceOnEnter will keep a other callers on hold until the moderator joins.
  • endConferenceOnExit will cause Telnyx to end the call for everyone as soon as the moderator leaves. We use the "From" agrument on Telnyx's webhook request to identify whether the current caller should be the moderator or just a regular participant.

In order for the webhooks in this code sample to work, Telnyx must be able to send your web application an HTTP request over the Internet. Of course, that means your application needs to have a URL or IP address that Telnyx can reach.

In production you probably have a public URL, but you probably don't during development. That's where ngrok comes in. ngrok gives you a public URL for a local port on your development machine, which you can use to configure your Telnyx webhooks as described above.

Once ngrok is installed, you can use it at the command line to create a tunnel to whatever port your web application is running on. For example, this will create a public URL for a web application listening on port 3000.

Telnyx voice API: ngrok code

After executing that command, you will see that ngrok has given your application a public URL that you can use in your webhook connection configuration in the Telnyx Mission Control Portal.

Twilio TwiML Conferencing Using the Telnyx Voice API

Grab your ngrok public URL and head back to the connection number you configured earlier. Now let's set it to use your new ngrok URL. Don't forget to append the URL path to your actual TwiML logic ("http://.ngrok.io/voice" for example).

Using Twilio TwiML with the Telnyx Voice API: Create and Manage Conferences

You're now ready to host dynamic conference calls with your Python app. Grab some friends and give it a try!

Ready to start building your TwiML conference on Telnyx?

Follow our setup guide to get started with the Telnyx voice API in minutes. Remember, there to take a look at our Developer Center for step by step TwiML tutorials for C#, Node, PHP, Java and Ruby.

And, join us on slack with any questions you have — we’re available 24/7.
Telnyx is not associated with, sponsored or endorsed by Twilio.

Share on Social

Sign up for emails of our latest articles and news

Related articles

Sign up and start building.