Create conference calls
Learn to create and manage multi-party conference calls with Twilio Programmable Voice by using the <Conference> TwiML noun within a <Dial> verb response. You can use this guide to create inbound contact centers, create outbound contact centers, implement call tracking, and perform AI or ML transcription.
To learn more about the conference and participant resources used in this guide, see Related reference documentation.
- Create a Twilio account.
- In the Twilio Console, create a compliance profile, then buy a voice-enabled phone number.
- In the legacy Console, buy a voice-enabled phone number. Only Messaging-enabled phone numbers need a compliance profile.
Select your programming language and complete the prerequisites:
- Install Python 3.3 or later.
- Install Flask and the Twilio Python Helper Library. Using pip, run the following command:
pip install flask twilio
- Install and set up ngrok.
Extract your credentials from your Twilio account then save these credentials as environment variables.
-
Go to the Twilio Console. The Let's get building page appears.
-
Click API keys and Auth tokens. The API keys & auth tokens page appears with the Auth Tokens tab selected.
-
Scroll to your Account SID.
-
Click the copy button next to your Account SID.
-
Run the following command, replacing
YOUR_ACCOUNT_SIDwith your Account SID.macOS TerminalWindows command linePowerShellexport TWILIO_ACCOUNT_SID=YOUR_ACCOUNT_SIDThis command creates an environment variable on your development system for your account SID.
-
To display the Auth Token, click the eye button in the Primary auth token box.
-
Highlight and copy the Auth Token.
-
Run the following command, replacing
YOUR_AUTH_TOKENwith your Authentication Token.macOS TerminalWindows command linePowerShellexport TWILIO_AUTH_TOKEN=YOUR_AUTH_TOKENThis command creates an environment variable on your development system for your auth token.
To allow the moderator to control the call, this example uses two advanced <Conference> features:
startConferenceOnEnterputs all other participants on hold until the moderator joinsendConferenceOnExitends the call for everyone as soon as the moderator leaves
To identify the moderator, use the From parameter on Twilio's webhook request.
Python only requires the Twilio Python helper library as noted in the prerequisites.
1"""Demonstration of setting up a conference call in Flask with Twilio."""2from flask import Flask, request3from twilio.twiml.voice_response import VoiceResponse, Dial45app = Flask(__name__)67# Update with your own phone number in E.164 format8MODERATOR = '+18005551212'91011@app.route("/voice", methods=['GET', 'POST'])12def call():13"""Return TwiML for a moderated conference call."""14# Start our TwiML response15response = VoiceResponse()1617# Start with a <Dial> verb18with Dial() as dial:19# If the caller is our MODERATOR, then start the conference when they20# join and end the conference when they leave21if request.values.get('From') == MODERATOR:22dial.conference(23'My conference',24start_conference_on_enter=True,25end_conference_on_exit=True)26else:27# Otherwise have the caller join as a regular participant28dial.conference('My conference', start_conference_on_enter=False)2930response.append(dial)31return str(response)3233if __name__ == "__main__":34app.run(debug=True)
To use the webhooks in this code sample, Twilio must communicate with your web app. These communications consist of HTTP requests sent between URLs accessible over the internet. Twilio requires access to Internet-addressable, or public, URLs.
Protect your webhooks
Twilio supports HTTP Basic and Digest Authentication. This type of authentication protects your TwiML URLs on your web server with an Auth Token. This limits access to the URLs to you and Twilio. Protect your auth tokens as you would your passwords. To learn more, see HTTP authentication.
Most production systems have a public URL, but development systems might not. To permit Twilio to access your local dev app, use ngrok. To create a public URL for your app, run ngrok at the command line:
ngrok http 3000 --url https://<your-app-name>.ngrok.dev
This command creates a public URL https://<your-app-name>.ngrok.dev. that forwards HTTP requests to your web app listening on localhost:3000.
With your public URL created, configure its connection to Twilio using a webhook.
After following this guide, you can successfully host and manage a conference call using Twilio Programmable Voice in your application. You can dial into a specific conference room name dynamically and control participant behaviors, such as assigning a moderator to start and end the call.
This guide teaches the basics required for the following use cases:
You can use this guide to route incoming customer calls into a shared conference room where agents can join and assist them. To learn more advanced features that you can use with inbound contact centers, see Voice inbound contact center.
You can use this guide to programmatically spin up conference rooms and dial out to multiple agents and customers simultaneously for outbound campaigns. To learn more advanced features that you can use with outbound contact centers, see Voice outbound contact center.
You can use this guide to connect callers to specific destinations through a tracked conference line, allowing you to measure engagement and call metrics. To learn more advanced features that you can use with call tracking, see Voice call tracking.
You can use this guide to perform AI or ML transcription on your conference calls by connecting to the Media Streams API and streaming the audio in real-time to your application for processing. To learn more advanced features that you can use with the AI and ML transcription, see Voice AI or ML transcription.
After following this guide, you can successfully host and manage a conference call using Twilio Programmable Voice in your application. You can dial into a specific conference room name dynamically and control participant behaviors, such as assigning a moderator to start and end the call.
Explore the following guides to build on what you've learned in this guide:
- Record phone calls: Capture and store the audio recordings of your multi-party conference calls.
- Respond to incoming phone calls: Handle incoming webhooks from Twilio to dynamically direct callers to your conference endpoints.