This is the API V2 documentation. To switch out of beta revert back to our API V1.

Open SidemenuDocs
Close Sidemenu

Twilio TwiML Conference on Telnyxtwilio-twiml-conference-on-telnyx

15 minutes build time

Swap to Telnyx with your existing TwiML code and Twilio SDK. By using Telnyx to execute your TwiML code, you will get the same great customer experience at a significantly lower cost.

In this tutorial, we'll show you how to use the Telnyx Call Control voice APITelnyx Developers to create and manage conference calls with your ASP.NET web application.

The code snippets in this guide are written using modern C# language features and require the .NET Framework version 4.5 or higher. We're going to use the Twilio C# SDK to create code than can be interpreted by Telnyx, but we'll show you that later.

Ready to begin? Let's get started!

Simple C# Conference Callsimple-c--conference-call

 <!-- A simple conference -->
<?xml version="1.0" encoding="UTF-8"?>
    <Conference>My conference</Conference>

Buy and configure a Phone Number and TeXML Application (C Sharp)buy-and-configure-a-phone-number-and-texml-application--c-sharp-

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

Buy a Telnyx phone number

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 webhookTelnyx Developers. You will need to create a TeXML ApplicationPORTAL and point that to your web application so that Telnyx can make a HTTP request when you receive a call. For the URL enter in your current TwiML application URL. If you don't have an application URL yet, we will create one at a later step using ngrokTelnyx Developers.

Set Up Your C# Web Applicationset-up-your-c--web-application

TwiML Twilio Telnyx Conference Flow

Telnyx makes answering a phone call as easy as responding to an HTTP request. When a phone number you have 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. 1Buy and configure a Telnyx-powered phone number capable of making and receiving phone calls, link it to a TeXML ApplicationPORTAL and point it at your web application
  2. 2Write a web application to tell Telnyx how to handle the incoming call using TwiML
  3. 3Make your web application accessible on the Internet so Telnyx can make an HTTP request when you receive a call

Dynamic C# conference calls with moderatorsdynamic-c--conference-calls-with-moderators

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

In this example we'll use ASP.NET MVC to respond to Telnyx's request and we'll use the existing Twilio (not Telnyx!) C# / .NET SDK to generate our TwiML.

Create a C# moderated conference callcreate-a-c--moderated-conference-call

// In Package Manager, run:
// Install-Package Twilio.AspNet.Mvc -DependencyVersion HighestMinor

using System.Web.Mvc;
using Twilio.AspNet.Mvc;
using Twilio.TwiML;

public class VoiceController : TwilioController
    private const string Conference_Moderator = "+13129457420";

    public ActionResult Index(string from)
        var response = new VoiceResponse();
        var dial = new Dial();

        // If the caller is our CONFERENCE_MODERATOR, start conference on join and end when they leave
        if (from == Conference_Moderator)
            dial.Conference("My superior Telnyx conference",
                            startConferenceOnEnter: true,
                            endConferenceOnExit: true);
            // Else join as a regular participant
            dial.Conference("My superior Telnyx conference",
                            startConferenceOnEnter: false);


        return TwiML(response);

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 all 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" argument 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 ngrokTelnyx Developers 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.

ngrok http 3000

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 PortalTelnyx Developers.

Migrate from Twilio TwiML to Telnyx

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! ("" for example)

Telnyx Twilio conferencing

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

Where to next? We just scratched the surface of what you can do with conference calls and your ASP.NET application. Check out the full <Conference>Telnyx Developers reference documentation to complete your migration from Twilio.

Make sure you check out the most common SIP Response CodesTelnyx Developers and Meanings.

Was this page helpful?was-this-page-helpful