Tropo Hackathon at DrupalCon Munich-No Lederhosen Necessary

Get your DrupalCon on with Tropo at our hackathon Monday August 20th.  Come learn some new API’s, meet some new friends, win prizes and hack on some Drupal projects.  It doesn’t matter if you are a coder, designer or just have an idea simply bring your laptop and desire to build something awesome!

We’ll be providing pizzas and beers for dinner but space is limited so be sure to RSVP for our free event and bring your Lederhosen if you have it…just for fun!

Tropo DrupalCon Hackathon

When: Monday, August 20th 2012

Where: In the Cuvillies I conference room at the Sheraton München Arabellapark Hotel

(Next to the Grand Westin – official hotel of DrupalCon Munich)

Cost: FREE!

Agenda:

  • 3-3:15pm – Introductions
  • 3:15-3:45 – API Sponsor presenations
  • 3:45-4:00 – Team formation/signups
  • 4:00-7:00 – Hacking!
  • 7:00-8:00 – Dinner Break
  • 8:00-9:00 – Team Presentations & Prize Awards!

We’ll see you in Munich!

©2012 The Tropo Blog. All Rights Reserved.

.

No related posts.

Beta closed

SMSified is no longer accepting new signups to the beta program. We’ve gotta give the carrier pigeons some time off, they’re squawking about unionizing. Thanks to everyone who signed up during the beta for your assistance. Your existing SMSified accounts and phone numbers will continue to work, and we’ll email you prior to launch to let you know how to set up billing so your accounts continue operating.

Expect to see SMSified’s production offering launch soon.

©2012 SMSified. All Rights Reserved.

.

Tropo sprouts up in Deutsche Telekom’s Developer Garden

Since we initially launched Tropo back in 2009, we’ve always held the view that mobile carriers hold a unique position in the developer ecosystem.   Beyond the obvious massive technology infrastructure that carriers employ that makes it so Grandma can easily pick up the phone and call you to say “happy birthday”, carriers also have other advantages like millions of subscribers, frictionless billing, and strong partnerships with mobile device manufacturers.

Now, I know what you’re saying…”But, Diggz, I want my app exposed to millions of subscribers!  I want to offer my customers frictionless billing!  I need access to unique features on the latest mobile devices!”

Well, wait no longer, my friend!

Today we’re pleased to announce a new unique partnership with Deutsche Telekom’s Developer Garden with the launch of the Telekom Tropo API beta at DeveloperGarden.com.  For the first time, new and existing Developer Garden and Tropo developers will have access to both the full suite of Developer Garden API’s and Tropo’s simple-yet-powerful voice and SMS API’s including voice recognition, text-to-speech, conference calling and call recording.

This means that in the coming months, Tropo developers in Europe and around the globe will have access to a new breed of carrier network features; complete with rich media and deep device integration.  Put on your peril-sensitive sunglasses, geeks…this is just the beginning!

Existing and new developers can immediately register for the Tropo Telekom API Beta here:  Tropo Telekom API Beta

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Join the Tropo developer community – via Forums, IRC or Skype
  2. London Calling: Tropo’s Drupalcon London Developer Contest

Tropo and Tethr at Google IO 2012

Tropo has teamed up with Tethr to demonstrate a great new disaster relief communications platform at Google I/O in San Francisco today.

Tethr lets people get connected to each other and the Internet after a disaster. It’s a unique platform that lets people and organizations work together in difficult circumstances anywhere in the world whether they are online or offline.

Tropo adds voice to the Tethr platform and allows you to take your tropo.com applications on the road with you. When you add Phono with WebRTC into the mix, you get a system that allows calls into applications on Tethr or between users connected to the WiFi.

Today at Google I/O we’re showing Tethr, Tropo and Phono together with another capability. Using OpenBTS from Range Networks we are creating a small GSM mobile phone network inside of Moscone Center. You can make a phone call from Google Chrome to a regular mobile phone without any plugins or even configuration.

We think this has major implications for crisis response. Imagine a neighborhood of folks beset by a natural disaster that has destroyed the infrastructure around them. They plug Tethr into a car battery and are instantly connected to the people around them. They are no longer victims, but in control of their own destiny and are able to self-organize in a 20 mile radius.

For more information on Tethr, visit their website and sign up to be notified when you can get your own Tethr Box. If you’re at Google I/O today, come up to the Chrome Sandbox and play around with our revolutionary new tools.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Skype Journal interviews Tropo at Google I/O
  2. Tropo Helps Women 2.0 Pick Winners for Pitch Competition 2012
  3. Tracking calls with Google Analytics

Using Tropo WebAPI with ColdFusion

Tropo makes it excruciatingly easy to build voice and text applications in just about any programming language.  In fact, every time I do a live coding demo at an event or hackathon, I pick a new language to build a sample app…I try my best not to pick favorites.  But I’ve always had a dark skeleton in my closet that generates snickers and scorn anytime it’s revealed.

I started building E-commerce websites in 1996.  Back then there were only a few options if you wanted to build dynamic web pages that integrated with a database.  Microsoft’s ASP was still years away from being released. PHP was starting to gain popularity but was still very much in its infancy.  Many developers were still writing custom CGI or Perl scripts.  But there was one other option…

In 1995, brothers Jeremy and J.J. Allaire invented a new programming language called ColdFusion (CFML).  By the end of 1996, ColdFusion had already graduated to version 2.0 and had become a full platform that included an IDE in addition to a full scripting language.  I was instantly attracted to CFML because the tag syntax was very similar to HTML (which I already knew), and it integrated seamlessly into Microsoft Access and SQL Server databases (which I already knew as well).  And the ColdFusion Server application ran on Windows, which was my preferred OS.

In very short order, I was spitting out ecommerce sites and dynamically generated content.  Allaire kept adding features and built a very robust community of CFML developers.  When we launched Voxeo in 1999, the very first account management tool, the one that allowed the very first web developers to map phone numbers to a URL, I wrote in ColdFusion.   Jeremy Allaire found the idea of making phones ring with CFML so intriguing that not only did he demo a Voxeo phone app during his keynote at the ColdFusion Developer’s Conference in 2000, he was one of  Voxeo’s earliest Angel investors…along with Eric Schmidt (of Google fame) and  Jeff Pulver (of Voice on the Net, Vonage and 140 Characters Conference)…among others.

As you can see from the above chart, after PHP, ASP.NET and Java, ColdFusion still beats out Perl, Ruby and Python in global server-side programming language usage.  And, despite its historical ties to the ColdFusion community, Tropo has never had any documentation or examples showing how to build Tropo apps using ColdFusion…until now :)

I’m pleased to present the first ColdFusion tools and sample app for building Tropo WebAPI applications.  The first is a CFTropoJSON parser that takes Tropo JSON and converts it to something easily digestible by ColdFusion Code.  You can download the source here:  ColdFusion Tropo JSON

The second is a sample app complete with debugging logger.  The sample app uses CFTropoJSON to play a prompt asking for the caller’s year of birth.   The caller can either say or type the response, and then the code will simply play back the response.  It uses the Tropo “ask” and “say” methods, and also has the ability to capture and store the JSON that your ColdFusion app receives from Tropo (especially helpful when building and debugging apps).   The sample app is located here:  Tropo WebAPI ColdFusion Sample.

Both of these are located in this Tropo WebAPI ColdFusion Github repository.  If you’re a ColdFusion developer and like this kind of stuff I encourage you to test it, fork it, commit new things and make it CFAwesome.

My name is Diggz, and I’m a ColdFusion Developer.  ;)

Special thanks to Shane Smith, who coded the excellent CFTropoJSON parser and pretty much did all the heavy lifting here.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. How-To: Sending an SMS using WebAPI
  2. Over 140 sample Tropo applications and growing strong…
  3. WebAPI Tips & Tricks

Win Tix to the Silicon Valley Startup Mansion Crawl from Tropo

One of the biggest trends in Silicon Valley right now is startup mansions; entrepreneurs living, sleeping, working and breathing startups in shared living spaces.

Why? Because one of the unique attributes of silicon Valley is being surrounded by like-minded people who are all trying to change the world and drive innovation. Being around some of the most intelligent people on the planet ups your game and keeps you lean. Space is also important in the creative process and sharing the cost of an open environment can lead to a though process without bounds.

We are offering you the chance to experience a fun night of networking and tour of three of San Francisco’s startup mansions; Factory Zero, The Glint and The Villa.

You will start at The Villa in Noe Valley for a BBQ and pool party then be bussed to The Glint for drinks and dessert , then onto Factory Zero for wine and cheese.

  • 4 – 6pm Pool Party, BBQ and networking at The Villa
  • 6 – 8pm Networking, dessert at The Glint
  • 8pm – 11pm Cheese, wine and networking at the Factory Zero

Tickets include food, drink and transportation are are STRICTLY limited to 100 people.  You can register for the Silicon Valley Startup Mansion Crawl here.

Because we love startups, Tropo is giving away 5 free tickets to the first 5 people who get 10 friends to “Like” the Tropo Facebook page . Just send us an email with the list of 10 friends to diggz@tropo.com

About the startup mansions:

Factory Zero: Factory Zero is the first location of Memento (m3m3n70.com), a seed stage venture capital fund for start-ups focused on raising the level of human consciousness.http://dolivelove.com is the first project.

The Glint: The Glint is a live-work community that accelerates the creation and creators of value. It aspires to shift the conception of heroism from historical warrior ideals to a new paradigm of creativity, collaboration and innovation.

The Villa: Startups events space and home to Diggz of Geeks Without Bounds, Chris Saad of EchoMarcus Lovingood of FutureLeapRichard Cambridge of Chargeplay, and Ben and Hermione Way of The Next Web and their new stealth startup.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Tropo Sponsors Startup Weekend Phoenix!
  2. Tropo joins Startup World in 36 cities
  3. Philadelphia Startup Drinkup

Drupal Hackathon winner in Haiti

At the API hackathon at Drupalcon Denver in March, Chris Teitzel led a team working on Hope One Source, a Drupal-based tool for organizing humanitarian aid workers. Using Hope One Source, aid workers can mark their location and classify themselves across a variety of categories. Then an aid organization can post messages to those categories. This way, an aid organization in northern Haiti can deliver a message to all doctors near Cap Haitien.

Electricity and internet access in aid zones can be scarce unreliable, but mobile phones often work just fine. Chris and team saw an opportunity. They created Tropo Rules a plugin for Drupal’s rules engine that allows site administrators to build voice and SMS into their workflow. Events within Drupal can trigger a call or deliver an SMS. Now, when someone posts a message to Hope One Source, everyone who should see it gets a text message.

Photo from Hope With Love

We thought it was a pretty nifty tool and awarded our hackathon prize of a Kindle Fire to the team. Chris told us he was teaming up with nonprofit humanitarian organization Hope with Love and heading to Haiti to test his tools with over 70 relief workers in northern Haiti at the clinics run by the Cap Haitien Health Network. He planned on taking the Kindle with him, where a grad student running the program would use it as a tablet to help with the organization.

Hope With Love is a 100% volunteer effort, and they’ve created Hope One Source with a team of three dedicated developers and the support of eight more during various phases of the project. The goal is to improve collaboration between aid workers, making sure that information is distributed in a timely manner. By doing so, Hope With Love aims to build more sustainable development and reduce the one-off efforts that are often seen in humanitarian work.

If you want to get involved with Hope With Love, contact founder Tim Underwood through their web site. To get involved with the development of Hope One Source, contact Chris Teitzel.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Tropo Gnomedex OpenGov Hackathon Winner named 2011 CFA Fellow
  2. Drupal Camp Toronto Features Tropo-Powered VoIP Drupal
  3. Tropo Powers PennApps Mobile Winner

Random Hacks of Kindness June 2-3 San Francisco

Twice a year we like to get together with some friends and give back to the world. Over the past two years, Tropo has been an active sponsor of Random Hacks of Kindness events in Seattle, Philadelphia, Boston, Milwaukee, Portland, and San Francisco and, through our unique ongoing partnership with Geeks Without Bounds, we are now in a position to help even more.

What is Random Hacks of Kindness?

RHoK is unique in the space of “apps competitions”, “hackathons” and “technology for social good”. RHoK’s model is to start from identifying, defining and refining problem definitions provided by subject matter experts and local stakeholders. This ensures that volunteer time is focused on solving real problems for real people.

Why does Tropo RHoK?

Many times applications that help humanitarian efforts have a communications aspect…whether that be text messaging or voice applications.  It is critical for people in vulnerable situations to have access to accurate information but often don’t have easy access to a computer or WiFi.  Often a telephone (not even a smart phone) is their only source to get this information.  Tropo makes it easy to rapidly build and test these types of applications.  In addition, Tropo offers text-to-speech and speech recognition in 24 different languages, local phone numbers in 46 countries and is completely free for developers to try.   Plus you can take Tropo out of the cloud and run it in the harshest of environments, like the middle of the desert.

The Tropo developer community is filled with people who care about the world around them:

  • The Geoloqi team, who are now recognized leaders in real-time location, messaging and analytics, have been a huge supporter of the RHoK community.   Geolocation was a huge factor in the race to save lives in Haiti as there were few accurate maps available and rescue workers wasted valuable minutes just trying to figure out what was where.
  • Babelverse, which provides real-time interpretation and translation of spoken word with thousands of crowd-sourced interpreters, sprung into action after the Japanese Tsunami to provide translation services to first responders and on-the-ground reporters to give the rest of the world and their families access to up-to-the-minute information in their native languages.
  • Tethr has built the world’s first “emergency network in a box”, putting Tropo in a low-powered, hand-held server that provides wireless and 3G services and a webserver to be able to collect data when traditional telco and Internet services are out (or in regions they don’t yet reach).

How can you help?

Whether you’re a Tropo developer, designer, or even just interested in helping volunteer to make coffee, tweet, blog or offer some kind words, we need your help.   The weekend of June 2-3 we’ll be joining 24 RHoK Cities around the globe to solve some big problems.   In San Francisco we’ll be joined by folks from:

In addition, the San Francisco RHoK will have representatives from both newly announced sustainability partners:  Geeks Without Bounds and Benetech.  Developers of real-time translation platform Babelverse will be onsite providing expertise into the power of real-time interpretation for humanitarian solutions as well developers from Code for America‘s open gov & open data teams as well.  Register for San Francisco RHoK here!

Register for other RHoK Locations:  AtlantaAustin, TX, U.S.A.Bangalore, IndiaBelgiumBerlin, GermanyBurlington, VT, U.S.A.Dar es Salaam, Tanzania: RHoK East AfricaHamburg, GermanyHamilton, CanadaHyderabad, IndiaKigali, Rwanda: RHoK East AfricaLos Angeles, CA, U.S.A.Melbourne, AustraliaMontréal, CanadaNairobi, Kenya: RHoK East AfricaPhiladelphia, PA, U.S.A.Prague, Czech RepublicPretoria, South AfricaSan Francisco, CA, U.S.A.Santo Domingo, Dominican RepublicSeattle, WA, U.S.A.Southampton, United KingdomToronto, CanadaTrento, ItalyWashington, DC, U.S.A.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. Drop2Drink wins Random Hacks of Kindness San Fran
  2. Random Hacks of Kindness and International Open Data Hackathon
  3. Tropo joins Google, Microsoft, Yahoo!, NASA & The World Bank for Random Hacks of Kindness

Posting & Accessing Tropo Recordings using WebAPI & MySQL

Many applications need a connection to a database to function – cloud databases like couchDB are one option (which we discuss in more detail here), but often a local database is more practical.  In this blog, we’ll be using the Tropo WebAPI with a local MySQL database via MAMP, a personal webserver with both Apache and MySQL built in.  We’re going to connect them in order to save important data provided by Tropo about a call, in this case specifically the callerID, timestamp of the call, and a recording of the call.  MAMP isn’t the only option – any webserver will work.

To start, open up MAMP – once it launches, you should be directed to a welcome page like the following:

Take note of your User and Password - these credentials will be used in our actual Tropo application.  Example code is mentioned at the very bottom of the screenshot, we’ll be using that same basic function later.

The next step is to click the phpMyAdmin link as shown by the top arrow; this is where we’ll access and create our database.  As displayed in the screen shot that follows, click the SQL tab towards the top of the phpMyAdmin window; this redirects us to a page where we need to run a SQL script in order to create our database structure:

Inside the box which says ‘Run SQL query/queries on server “localhost”:’, you will copy and paste the SQL script below (note the database name is Tropo and the two table names are calls and recordings):

CREATE DATABASE `Tropo`;

USE `Tropo`;

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE IF NOT EXISTS `calls` (
`callId` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
`number` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
`channel` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
`network` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY `callId` (`callId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `recordings` (
`callId` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`recording_url` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
UNIQUE KEY `callId` (`callId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

After pasting in that code, hit the Go button at the bottom right and you should be redirected to the page below. If you see Tropo, as indicated by the arrow, the script worked. You can go ahead and click Tropo(2) to view your two tables.

The tables should look like this:

To summarize, you’re connecting through localhost to access the database Tropo,  which contains two tables – calls and recordings.

Now that our database is ready, we can start coding the app.  This app will be initiated an inbound call; it initially greets the user and prompts them to record a message. After the message is recorded, the Tropo thread will either be directed to a continue route if the message was recorded successfully or sent to the error route if an error occurred.

Since this is a WebAPI application, the first bit of code you should include is the Tropo PHP library – it’s not an absolute necessity, but it makes generating accurate JSON immensely easier.

//First we include the Tropo WebAPI classes.
require('tropo.class.php');

The next piece of code will retrieve the URI of the defined route (when you define the URL for your Tropo WebAPI app, be sure to declare this variable in the query string; an example would look like this – http://www.yourwebsite.com/voice.php?uri=start) for the thread and a function which will access our database – the function is the section of code you’ll need to modify with your actual MySQL credentials:

//The next step is to determin the URI (or position) within the script the caller is at.
//To do this we use a GET method to find the URI from the url which Tropo is requesting in the background.
$uri = $_GET['uri'];

function connectToMySQL(){
  $db_user = "UserName";
  $db_pass = "Password";
  $db_db = "Database_Name";
  mysql_connect("localhost", $db_user, $db_pass) or die("ERROR: MySQL cannot connect.");
  mysql_select_db($db_db) or die("ERROR: MySQL cannot select database.");
}

Now we will use the $uri variable in a switch statement to decipher which route to go to. This app is setup to have three independent routes – start, continue and error.

The start route defines the section of code where the caller is greeted and asked to submit a recording.  As shown in the following code, the app uses the Tropo session to extract important data (e.g. callID, callerID, channel, network) to save to the database – this data is stored in the calls table. If the recording portion works, the app will move on to the continue route; if it fails, it moves on to the error route – this is handled by the on event.

Below is the start route code:

//Now we want to be able to execute different lines of code when different URI's are called (when the caller is at different stages in the call).
//This can be done by using IF and ELSEIF statements but we're going to keep things simple and use SWITCH, CASE, BREAK and DEFAULT.
switch ($uri){

  //Everything between case "start": and the break; commands will be run when Tropo initially requests the script using voice.php?uri=startinthe URL.
  case "start":

  //We are going to need a connection to MySQL in this section so we include the function we created to deal with the MySQL connection.
  connectToMySQL();

  //We also need to know various details about the caller, we can create an instance of the Session() object which deals with retreiving these
  //details from the initial JSON data request which is sent to this script from Tropo when a new call is received.
  $tropoSession = new Session();

  //Below demonstrates how we can retreive data from our new Session() object and store those details (or in some cases arrays) intolocalvariables,
  //which I've given names that are easier to understand.
  $call_id = $tropoSession->getCallId();

  //The below line sets $caller_from as an array which has all of the FROM data passed accross in the JSON request.
  $caller_from = $tropoSession->getFrom();

  //Below we can see how that information stored in $caller_from can be accessed and pulled out into other variables.
  $caller_number = $caller_from['id'];
  $caller_channel = $caller_from['channel'];
  $caller_network = $caller_from['network'];

  //This is a very basic MySQL query which can be used to insert data into the MySQL database table called 'calls' which stores
  //the call id, the callers phone number (or skype username etc), the channel used (voice or text) as well as the network which could be
  //SIP, SKYPE, etc.
  mysql_query("INSERT INTO `calls` (callId, number, channel, network) VALUES ('".$call_id."', '".$caller_number."', '".$caller_channel."', '".$caller_network."')");

  //We create a new instance of the Tropo() object which we use to process commands on the Tropo service.
  $tropo = new Tropo();

  //This line of code simply sets up Tropo to speak the string data which is inbetween the quote marks.
  $tropo->say("Welcome to the PHP code sample system.");

  //The below record function speaks out to the user asking them to record their message and then asks them to press the hash key
  //to continue and save their message. The record is sending the recording to another php file which extracts the recording and the
  //name variable and saves the recording in that same folder as this app on your server
  $tropo->record(array(
    'name' => 'recording',
    'say' => 'Please leave your message after the beep. Press the hash key when you are finished recording your message.',
    'url' => 'http://yourWebsite/recordings/recording.php?name='.$call_id,
    'terminator' => '#',
    'bargein' => 'false',
    'beep' => 'true',
    'timeout' => 10,
    'maxSilence' => 7,
    'maxTime' => 180,
    'format' => 'audio/wav',
  ));

  //Now we need to set some events and commands to be run when they are executed.
  //The first on event we will be executed if the recording (or prior) command is completed successfully.
  //This simply says to Tropo that we need to go to the voice.php?uri=continue URL (and run the code for that section) as well as speaking out the
  //text from the say command so the caller knows everything has gone well.
  $tropo->on(array("event" => "continue", "next" => "voice.php?uri=continue", "say" => "Thank you, here is the message you have just recorded."));

  //We also needd to know what to do in the case of an error. Instead of getting Tropo to start executing the success (?uri=continue) code we instead  
  //ask Tropo to access the incomplete URI instead.  
  $tropo->on(array("event" => "incomplete", "next" => "voice.php?uri=error"));

  //Now we have told the Tropo object what we want to do we need to get the object to render our the JSON code which will be outputted onto the page   
  //for the Tropo service to read and execute. It is crucial that you remember to render your JSON as this step makes the "instructions" you've just   
  //created readable by Tropo.
  $tropo->renderJSON();

  //We also want to close the MySQL database connection.
  mysql_close();

  //The break command simply signals that we are at the end of the code which will be executed for the "start" URI.
  break;

If the recording from the section of code above was successful, then the on event will register continue and send the thread to the continue route. In this route, the script will do two things – first, it makes a call to the database and sends the recordURL and the callerID to the recordings table. Second, it replays the caller’s recording back to them, says goodbye and hangs up the call – which effectively ends the Tropo app.  Below is the actual continue route code:


case "continue":

  //As with the start case we need MySQL access so lets add that in by calling the function we created earlier.  
  connectToMySQL();

  //As we are expecting to have received JSON data back from the Tropo service we need to initiate an instance of the Result() object.
  $result = new Result();

  //Now we have read in the resulting JSON data we can access it through the Result() object we have just created. We need the calls id so that we
  //know what data to store along side the recording the caller has just created and to track the call in general.
  $call_id = $result->getCallId();

  //Insert the new recording into the MySQL database table called 'recordings', make sure you change the URL so that it corosponds to your
  //own server/hosting or this wont work.
  mysql_query("INSERT INTO `recordings` (callId, recording_url) VALUES ('".$call_id."', 'http://yourWebsite/recordings/".$call_id.".wav')");

  //Create a new Tropo object.
  $tropo = new Tropo();

  //Replay the recording back to the caller and speak out "Good bye" after the recording has finished. Make sure you change the URL to work properly with
  //your own server/hosting.
  $tropo->say("http://yourWebsite/recordings/".$call_id.".wav Good bye.");

  //Hang up the call.
  $tropo->hangup();

  //Render the JSON to be read back by the Tropo service.
  $tropo->renderJSON();

  //Close the MySQL database connection.
  mysql_close();

  //Signal the end of the continue case section.
  break;

Now, if there was an error with the recording (such as no detected audio) the error route will be invoked. The only objective of this route is to alert the user that an error occurred and to try again later:

case "error":

  //The code in between case "error": and break; is used when our error event is called which we set up in the start case.
  //First we create a new instance of the Tropo object.
  $tropo = new Tropo();

  //Next we use the say method to tell the user that an error has occured and that they should call back to try again.
  $tropo->say("Sorry I can't hear anything. Check your microphone isn't on mute and call back to try again. Good Bye.");

  //Hangup the call.
  $tropo->hangup();

  //Render the JSON which will be used to 
  $tropo->renderJSON();

  break;

default:

  //The default case is used in the event that the URI in the URL (?uri=) is left blank or doesn't match one of the above cases we have identified.
  //We simply want to die() the script in the case that this is called for security as it is most likely a security threat.  
  die("An error has occured.");

  break;
}
?>

That actually finishes up the Tropo portion; now we can really see the benefit of the MySQL database.  Below you’ll find the code that extracts the information from your database and publishes it to your browser in a readable format:

<?php

//First we need to create a connection to our MySQL database and also set up some details into variables for the database connection.  
$db_user = "User_Name";
$db_pass = "Password";
$db_db = "Database_Name";

//We use the details we've stored into our variables to connect to the database.
mysql_connect("localhost", $db_user, $db_pass) or die("ERROR: MySQL cannot connect.");

//Next we need to select the database which we wish to work with.
mysql_select_db($db_db) or die("ERROR: MySQL cannot select database.");

//Next we get all of the data from our calls table of the database.
$calls_sql = mysql_query("SELECT * FROM `calls`");

//We then want to set up a while loop which will allow us to output the details for each individual row of the table as it loops.
while($call = mysql_fetch_object($calls_sql)){

  //The below 7 lines of code are used to simply obscure the telephone numbers and skype usernames to only display the last 4 characters for privacy reasons.
  $length = strlen($call->number);
  $starlength = $length - 4;
  $number = "";
  for ($i = 1; $i <= $starlength; $i++){
    $number .= "*";
  }
  $number .= substr($call->number , $starlength ,4);

  //We then use the echo command to construct the HTML markup which will be used to create the page the user will see when they are viewing the calls and
  //recordings. Notice how we close and open quote marks so we can join in the PHP variables which are then printed out to the page HTML source.
  echo "<strong>CALL ID:</strong> ".$call->callId." <strong>CALL FROM:</strong> ".$number." <strong>CALL CHANNEL:</strong> ".$call->channel." <strong>CALL NETWORK:</strong> ".$call->network." <strong>TIMESTAMP:</strong> ".$call->timestamp."<br />";

  //While we are printing out the details for a call we also want to print out any recordings which corrospond to the call. I've opted to use
  //a while loop for this incase you wish to change the script slightly so that it can allow for multiple recordings per call. This is also the best way
  //to output calls which might not actually have a recording at all due to hanging up or an error when they record their message.
  $recordings_sql = mysql_query("SELECT * FROM `recordings` WHERE `callId` = '".$call->callId."'");

  //So this basically echos out a link to the audio file we have stored into the database.
  while($recording = mysql_fetch_object($recordings_sql)){
    echo "<strong>@ RECORDING URL</strong> <a href='".$recording->recording_url."'>Listen</a><br />";
  }
  //After every call we want to have 2 line breaks to make it a little easier to read our index.
  echo "<br /><br />";
}
?>

Launch the app in browser using a URL that looks something like this:

http://www.yourServer.com/index.php

You should see something like this:

The app is accessing the database to pull in the CALL ID, the last four digits of the callerID defined as CALL FROM, the CALL CHANNEL and CALL NETWORK, the TIMESTAMP of the call and finally, the RECORDING URL with link to hear the recording labeled Listen. This, while basic, is the starting point to a more fully realized (and prettified) website that could provide a variety of uses – management for a customer service company able to listen to call recordings, cloud based access to personal voicemail, spot for callers to be able to review their own recordings (provide independent filtering so a user can only view their calls), etc and so on.

While that covers the app as a whole, if you go to github you can view a couple of extra apps that help in other areas – debugging (KLogger.php), saving an audio file (recording.php), and checking if your php is compatible (compatibility.php).

Big shout out to Jamie Street for both the idea and the application code – if you’re interested in learning more about Jamie, check out his website: http://jamiestreet.co.uk

Hope you find this example useful, thanks for reading and enjoy!

©2012 The Tropo Blog. All Rights Reserved.

.

No related posts.

Outbound Apps – How They Work in Scripting vs WebAPI

Sending texts or making calls with Tropo can be a little counter intuitive if you’re accustomed to the pure REST implementations common to SMS APIs – POST the destination phone number and the message content to a specific URL, text goes out, end of story. With Tropo, you need a “launcher” app that handles the REST bits and a “catcher” app that actually sends the text, which adds a bit of complexity but also an immense amount of features.

The first app, the “launcher”, will create a REST request, either a GET or POST, that contains one of your application tokens and any parameters to pass over (such as the number to call). The token is your authentication, so no need for a user/pass or BASIC auth, and they’re found underneath the URLs for the actual Tropo app, a.k.a. the second “catcher” app. You’ll have two options:

Each token corresponds to one of the app URLs, so the Voice URL is linked to the Voice token, Messaging to Messaging. If your app has the same URL for both, either token will work fine.

The launcher app can be a plain URL dropped in a browser, like this:

https://api.tropo.com/1.0/sessions?action=create&token=TOKEN&numbertodial=14075551212&msg=test+Tropo+message

which is essentially a GET, or it can be a fully realized app using various languages and REST clients, like curl for PHP:

<?php
$token = 'TOKEN';
$numbertodial = '14075551212';
$msg = 'test+Tropo+message';

$curl_handle = curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://api.tropo.com/1.0/sessions?action=create&token='.$token.'&numbertodial='.$numbertodial.'&msg='.$msg);
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_exec($curl_handle);
curl_close($curl_handle);

?>

That app uses POST, though you could use a GET with the app just as easily. The launcher app would reside on your server, tied to be triggered by some criteria, potentially when someone clicks a button on a webpage.

Note that the message needs to have all spaces encoded, which is why the + sign is shown. You can also use:

curl_setopt($curl_handle,CURLOPT_URL,'http://api.tropo.com/1.0/sessions?action=create&token='.$token.'&numbertodial='.$numbertodial.'&msg='.urlencode($msg));

Ruby has a library called net/http that would work, Python has the urllib and urllib2 libraries, whatever you want to use would be fine as long as it can send a GET or a POST.

Your second app would look like the apps in one of these examples:

Scripting:

https://www.tropo.com/docs/scripting/passing_in_parameters_voice.htm

https://www.tropo.com/docs/scripting/passing_in_parameters_text.htm

WebAPI:

https://www.tropo.com/docs/webapi/passing_in_parameters_voice.htm

https://www.tropo.com/docs/webapi/passing_in_parameters_text.htm

The first set of examples are for apps created for the Scripting API – a Scripting app uses a script hosted on our servers (conveniently called “Hosted File” when creating a Scripting app); your launcher app would trigger it to run using the token, and everything else happens on our side. The sequence of events would look like this, if your launcher app was tied to a webpage:

  1. User loads your webpage, clicks a “send text” button or something similar
  2. Your serverside launcher app is triggered and sends the REST request to our servers
  3. Your Tropo app launches and sends the text message

The second set of examples is an app using the WebAPI; this API communicates with an app that’s actually running on your server, but sends instructions to our servers using back and forth JSON. This sequence of events for this one would look like this:

  1. User loads your webpage, clicks a “send text” button or something similar
  2. Your launcher app is triggered and sends the REST request to our servers
  3. The Tropo app launches and sends session JSON to your catcher app, also hosted on your server, asking for instructions
  4. Your second app replies with JSON that tells Tropo to send the text message
  5. Tropo sends the text message

Many developers using the WebAPI get stuck at this spot – it seems overly complex, and for a very basic SMS app that’s a legitimate thought. If all you want to do is send plain texts without any need to process responses, capture input, anything except deliver the text, then the Scripting option is often easier. Copy one of the examples from the docs, add a Scripting app and then build the launcher app in whatever language you want.

Hope that helps clarify the different processes; as always, if you get stuck, please don’t hesitate to post in our forums and ask for help.

©2012 The Tropo Blog. All Rights Reserved.

.

Related posts:

  1. WebAPI: Now with outbound and transcription
  2. Sending outbound SMS with Java
  3. New Java based WebApi implementation