Roll Call! Roger Stringer Shows You How to Take a Headcount During A Twilio Conference Call

September 04, 2014
Written by

kid-megaphone

In an ideal world, the start of every conference call would be seamless. Everyone is on the line and everyone knows who is on the call. But, things don’t always work that well. The start of a conference call can leave people talking over each other in an effort to introduce themselves and leave others pretty peeved about the whole process.

Roger Stringer, Twilio-ninja and author of the Twilio Cookbook, put together a roll call feature that allows you to take a headcount of your conference call programmatically.

Check out Roger’s original post on GitHub here.

How to Make a Roll Call During a Twilio Conference Call

Twilio’s conference calling functionality is great in that it is simple to set up, but powerful with just a few tweaks.

In this post, we’re going to set up a moderated conference system with a twist, we’re going to build a roll call system, so that when a moderator presses the * button, they will redirect to a page which will read back a list of participants, then the moderator back into the conference.

I know, that sounds like a useful feature when you’ve got a scheduled conference call and want to make sure everyone has called in before starting.

So, today, we’re going to show you how to set up a roll call system. To do this, we need a bit of setup.

First, let’s set up the non-moderated caller TwiML when participants call in:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Say>The conference will begin when the moderator joins</Say>
    <Dial>
        <Conference startConferenceOnEnter="false">Room1234</Conference>
    </Dial>
</Response>

Let’s call this file conference.xml.

Callers who call into this number will be met with a message that the conference will begin when the moderator joins.

Second, we need the TwiML for moderators. So that when a moderator joins, we could append an action on to the that would trigger a call to a file which would then announce the end of the conference.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Dial action="rollcall.php" method="POST" hangupOnStar="true" timeLimit="1800">
    <Conference startConferenceOnEnter="true" endConferenceOnExit="false">Room1234</Conference>
  </Dial>
</Response>

Let’s call this file conferencemod.xml.

Finally, we want to add the code to handle when a moderator presses the * button on their phone.

This will call a file called rollcall.php, which will present the moderator with a list of participants as a roll call, then forward the moderator back into the conference.

Notice, we set the endConferenceOnExit to false? This is because we don’t want to end the conference at this time, we just want the moderator to hear a list of participants, then get forwarded back into the conference. In this case, the conference would end when everyone hung up their calls.

First, we would get a count of particpants still on the conference.

Second, we would cycle through each participant and that participant’s phone number to the moderator.

Finally, we Redirect the moderator back into the Conference .

Let’s create rollcall.php:

<?php
    // Get the PHP helper library from twilio.com/docs/php/install
    require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

    // Your Account Sid and Auth Token from twilio.com/user/account
    $sid = "ACXXXXX"; 
    $token = "YYYYY"; 
    $client = new Services_Twilio($sid, $token);

    $response = new Services_Twilio_Twiml();

    if( isset($_REQUEST['ConferenceSid']) ){
        $participants = $client->account->conferences->get( $_REQUEST['ConferenceSid'] )->participants;
        $cnt = count( $participants );
        $response->Say(  "There are ".$cnt." callers in this conference" );
        foreach ($participants as $participant) {
            $call = $client->account->calls->get( $participant->callsid );
            $response->Say( $call->from );
        }
    }

    $response->Redirect("conferencemod.xml");
    print $response;
?>

 

Interested In Learning More?

Then you should check out Twilio <Skills>, a self-paced, e-learning platform that was created for developers looking to build and expand their Twilio knowledge.

Built to enhance Twilio’s current documentation, Twilio <Skills> focuses on writing actual code and provides developers with hands-on learning through four levels of training.

The first two levels, which provide a guided path to help partners get started with Twilio, are available now. The next two levels, scheduled for release later this year, will dive deeper into designing and building communications-enabled applications for specific use cases, such as mobile marketing or customer service call centers.

For each of these levels, you can earn badges to highlight your Twilio skills and differentiate yourself from other developers. You can earn your Explorer and Doer badges by completing one quick project.

So what are you waiting for? Get started today.

Image via indiemusic.com