Learn how to use Twilio's conference features and REST API to build a conference line with advanced controls. Additionally learn how to build a voice broadcast system as part of this Rapid Response application.Start Tutorial
Aid workers can use the tools in this app to communicate immediately with a large group of volunteers. In situations where all parties need to talk at once the organizer can quickly spin up a conference line. In other situations she can broadcast a spoken message to a list of volunteer phone numbers.
To run this sample app yourself, download the code and follow the instructions on GitHub. You might also want to click around the views for this app, since in this tutorial we will only be covering the Twilio pieces.
Let's get started! Click the right arrow above to move to the next step of the tutorial.
Before we can call our conference line we need to configure one of our Twilio numbers to send our web application an HTTP request when we get an incoming call.
Click on one of
your numbers and
configure the Voice URL to point to our app. In our code the route will
We use the Twilio PHP library to generate some TwiML that tells
Dial into a
"RapidResponseRoom". This means that anyone who calls
your Twilio number will automatically join this conference.
Next we'll turn this into a moderated conference line, with a moderator and listeners.
In this scenario we ask for the caller's role before we connect them to the conference. These roles are:
The gather verb from the previous step included an
that took an absolute or relative URL as a value — in our case, the
When the caller finishes entering digits Twilio makes a GET
request to this URL including a
Digits parameter with the number our caller chose.
In addition to hosting conference calls, an organizer can use our application to broadcast a voice message to a list of phone numbers. She can do this by choosing a recording from a dropdown, entering a list of phone numbers and clicking 'Submit'.
To power this feature, we'll use Twilio's REST API to fetch all of the recordings associated with our account. If our organizer wants to record a new message, we'll call her phone and record her response.
Let's take a look at the code.
This route fetches all of the
associated with our Twilio account. We could filter these
results by date or call sid using Twilio's API, but for this example
we just pull all recordings.
In order to use Twilio's handy API we need to first create our Twilio client, which we can easily do by passing our credentials.
If the organizer needs to make a new recording, we simply call her
and record the call. Twilio makes this simple with the
Say something to the caller and then
Record her message.
There are many more options we can pass to Record, but here we simply
tell it to stop recording when '*' is pressed and to redirect to
so the call drops when the recording is finished.
This controller processes our voice broadcast webform, starting with the phone numbers our organizer provided.
Next we initiate a phone call to each number using Twilio's REST API.
When Twilio connects this call it will make a request to the
parameter to get further instructions. We include a
recording_url parameter in that URL so that our
controller will know which recording to use.
That makes the work for our
broadcast/play route simple — we just
Play the recording.
That's it! We've just implemented two major features of a Rapid Response Kit! Maybe in the future we can tackle some of the other features and build a full-fledge kit!
If you're a PHP developer working with Twilio, you might enjoy these other tutorials:
Put a button on your web page that connects visitors to live support or sales people via telephone.
Instantly collect structured data from your users with a survey conducted over a voice call or SMS text messages.
Thanks for checking out this tutorial! If you have any feedback to share with us, we'd love to hear it. Tweet @twilio to let us know what you think.