Tropo is part of CiscoLearn More

Power Conferences in PHP

Posted on March 8, 2017 by Ralf Schiffert

You have heard it all: Avoid meetings at all costs!” “If you must have meetings do them all on the same weekday and keep your other days free!”, “Always send an agenda and your presentation before the meeting!” “Keep your meetings to 20min or less!”

canstockphoto5516389

I won’t go into a reality check of these recommendations, but here is what we are going build today, a conference with built-in time management so you don’t have to. Yep that’s right, it’s like speed dating. If your users know how much time they have upfront and will be reminded of it via regular announcements they are going to get things done, quickly.

Our power conference will send initial gentle reminders to all participants before ultimately and forcefully ending the conference when the time is up.

If you want to try it out you can call +1 470 238 9092.

This example is the Skippy version of a conference though. Start to end, 45s, done.

We are going to break this effort into 2 parts. In the 1st part, I am going to start with the basic solution illustrating how to play an announcement into a conference and in the 2nd post I will build upon it with some business logic in the backend to maintain the timers and ultimately end the conference for anyone lingering around.

You are in for a bit of a ride. Not only will we learn a lot about Tropo’s advanced features like automatic speech recognition, instant call setup, call-2-call data transfers and application signaling, but will also have to delve a little into the deep end of PHP particularly session management and thread safety. But no worries, it took me a little to figure things out which allows me to safely guide you around the rough edges.

Part 1 Playing audio to a conference

So, let’s get started.

First we need to solve how to play audio into a running conference. There are essentially 3 pieces to this puzzle,

  • An app that that puts people into a conference room
  • An app that plays our announcement
  • And app that calls the app that plays the prompt

Let’s go over these 3. I made them as simple as possible and hardcoded some stuff. No worries, we will make this more flexible as we go along.

1_ app1_basic.php : A Tropo app that places callers into a conference. For simplicity we use an inbound app, but of course outbound dialing to participants would be just as easy with Tropo.

The basic scripting API code looks like this:

<?php
say("Thank you for joining our conference call");
conference("1233");
?>

When someone dials their conference dial-in, the phone number you assigned to this scripting app in either the account portal or via REST API, they will be dropped into the conference 1233 which we hardcoded for simplicity here. Tropo conferences will accommodate up to 100 people in our standard configuration, which would be enough to get a lot of people annoyed about time-wasting meetings. But hold your horses, in the advanced section we will put an end to this.

2_ app2_basic.php : Next we need an app that plays an announcement. Let’s use this

<?php
say("You have five minutes left in the conference");
hangup();
?>

This is pretty self-explanatory. The say() is Tropo’s magical prompter that renders text to audible words or when provided with an audio file URL, will play the same greeting done by your voice talent, albeit likely for a much higher price.

I’ll let you look up all the options you can use for the say but also wanted to remind you that we have two new, great sounding TTS US voices, Zoe and Evelyn. We think they sound pretty darn good and you should give them a spin.

3_ app3_basic.php Lastly we need some magic sauce to connect the conference bridge to the audio playing application. In short we’ll launch an app, which then dials the application in 2_ and joins it to the conference in 1_. The code would look something like this:

<?php
call("sip:9991988936@sip.tropo.com");
conference("1233");
hangup();
?>

When we do this we use Tropo’s instant call setup feature. The launch URL to start this app can be found in your account portal or via the REST API. Mine looks like this

https://api.tropo.com/1.0/sessions?action=create&token=6853444b48634b58566c6e6b4643715a 6f5657646a78596547416b6f6777474e59626362696261decafbad

Executing this launch URL will kickoff app3_basic.php which starts a VoIP call to 9991988936@sip.tropo.com (we’ll get to that in a second) and places that app into the conference, resulting in the announcement being played to the conference bridge. The hangup() after the conference is not strictly necessary as we do a hangup already on the callee (app2) side after we are done playing the announcement.

So really this call only lasts for as long as it takes to play the announcement to the conference bridge.

The end result here will be that people in the conference will hear the announcement (“You have five minutes left….”) whenever the launch URL is executed. You can post the URL into your browser to try it out or use cURL if you want to play with it. Later we’ll call that URL programmatically from our business backend.

Let’s quickly chew on the SIP Uri sip:9991988936@sip.tropo.com. Tropo automatically assigns every app a SIP URI, which enables you to call your new app from any SIP capable equipment like a CISCO phone or a SIP Softphone like Blink. Calling a SIP number is also the fastest and easiest way to call from one Tropo app to another, a feature we will be making good use here.

Tropo assigned to my announcement app the following SIP URI. Recognize that number?

sip-php-conf

We could also assign a real PSTN number to that app and while Tropo’s phone numbers are available in more than 50 countries and generally inexpensive, there really would be little use. Call setup times in PSTN networks are much slower than VoIP. Hence the term I used earlier: Tropo’s instant-call-setup. Come to think of it, it should really be Instant-Call-Setup™ ©Tropo.

We are done with the basic solution. That was a little whirlwind. To try it out create 3 applications in the Tropo.com portal with the scripting code I showed you and then use your very own launch URL to play the announcement to your conference.

Before we stop, let’s introduce a little flexibility to the app. This will help us later. We are going to get rid of the hardcoded conference ID and instead we will ask the caller for the meeting ID when they dial in. That’s just how Webex and other commercial systems behave. Since Tropo provides advanced speech recognition in over 60 languages we leave it to the caller if they want to speak their meeting ID or rather press touchtones.

Back in 2011, we published a tutorial featuring the conference app code that we used as our company conference line at the time. Let’s use the code from that tutorial here.

An enhanced app1_enhanced.php looks like this:

<?php
answer();
$voice = 'Eva';
while ($currentCall->isActive()) {
  $response = ask('Enter your conference eye d. Press the pound key when finished.', array(
      'choices' => '[4 DIGITS]',
      'terminator' => '#',
      'mode' => 'keypad',
      'timeout' => 8
    ));
  switch($response->name) {
    case 'choice':
      say('<speak>Conference i d <say-as interpret-as="vxml:digits">' . $response->value . '</say-as> accepted. You will now be placed into the conference. Press pound to exit without disconnecting. Please announce yourself.</speak>');
      conference($response->value, array('terminator' => '#'));
      // Pause a moment before asking for another conference.
      sleep(1);
      break;
    case 'badChoice':
      say('Sorry, that is not a valid conference eye dee.', array('voice' => $voice));
    break;
      case 'silenceTimeout':
      case 'timeout':
      say('Sorry, I didn\'t hear anything.', array('voice' => $voice));
    break;
  }
}
?>

We are using Tropo’s ask verb to solicit input from the caller. Here they get prompted for a 4 digit number. The input result can be found in result->value and will be used to inform the caller about the conference they are joining, as well as kick them right into it. If you want to talk to your friends, of course they have to specify the same meeting ID as you did.

You do see me playing with the Text To Speech engine here when I used eye d, i d, and previously eye id. It didn’t make any difference for the default Tropo voice but some TTS engines and voices are reacting to these chances with minor changes in pronunciations. Of course Tropo is pretty unique in that you can fine tune pronunciations with the standards based SSML markup.

You can always read up the linked docs to get more background info or better signup for a free Tropo account and give it a spin.

This is it for part 1. Next week we will introduce a couple more Tropo features like call-2-call data transfers and enhanced signaling to Tropo scripts.

Releasing Unused Numbers

Posted on March 6, 2017 by JP Shipherd

At Tropo we love to make it free and easy to sign up and start developing. It’s time for a bit of spring cleaning though and we found that there are almost 100, 000 numbers assigned to Tropo developer apps, the majority of which have not been used in the last few months. Going forward we will be implementing a policy where numbers associated with development apps that are not used in 90 days will automatically be returned to our number pools. These unused numbers do cost us money and could be reused in the larger production pool.  If you have a strong affection for your number and worry that it might be impacted the easiest thing to do is simply move your application to production. With prices as low as 1$ per month it’s a simple and cost effective way to guarantee you’ll keep your number even if you aren’t using it.

For now, we will release every number that wasn’t used for more than 90 days coming April 30. I.e. every number that didn’t make or receive a call or SMS since Feb 1st will be released back into the common phone numbers pool.

Announcing the availability of phone numbers in four new countries.

Posted on February 27, 2017 by JP Shipherd

We are happy to announce that we’re able to make numbers in Denmark, Finland, Sweden and Portugal available to Tropo.eu developers. We now provide both local and toll-free numbers that support inbound voice in all four of these countries as well as inbound SMS numbers in Denmark Finland, and Sweden.

The purchase of these numbers can be done through our portal and you can find pricing on the pricing page.  Contact support@tropo.eu if you can’t find a number you are looking for.

Skål!  Saúde!