Archive for the ‘mashups’ Category

Meet Phono – Tropo’s Web Phone

Monday, January 23rd, 2012

Have you heard about Phono, our open source Javascript Phone API project?

Phono is a free HTML5 jQuery-based web phone that you can add to any web page to place or receive open SIP-based VoIP calls to/from any web browser (or iOS/Android mobile device using Phono Mobile)!

Phono can be connected to Tropo to place or receive phone calls to/from real telephone numbers! Phono can also interact with Tropo voice applications directly from a web page using Tropo’s speech recognition and text-to-speech in 24 languages as well as record and play media such as WAV or MP3 files or conduct conference calls, call transfers, call recording, etc.

To make things even better, Phono and Tropo both support SIP headers which are basically key/value pairs of data that you can sent along with calls. SIP headers are very common in call center applications and enterprise screen-pop implementations. Using SIP headers allows Phono to place a call into a Tropo application and pass along data instructing Tropo to transfer the call to another telephone number. This is how all of the click-to-call demo applications work on phono.com. These demo applications are also limited to 10 minutes in length so that you can experience the quality of a Phono call and write your own Tropo application for longer calls.

Because we have had a few questions lately on this topic, I wanted to provide some sample code for both Phono and Tropo to make this easier for you to apply to your application. This demo application allows you to enter a phone number on a web page and call it using Phono and Tropo. The web page has a simple form that asks for a phone number and has a call button that initiates a SIP VoIP call to Tropo app:9996182316. Reviewing the Phono code below, you will find that it uses jQuery to pass the phone number value in the textbox to Tropo as a SIP header.

<html>
  <head>
    <script src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script src="http://s.phono.com/releases/0.3/jquery.phono.js"></script>
  </head>
  <body>
	<input id="phonenumber" type="text">
    <input id="call" type="button" disabled="true" value="Loading..." />
    <span id="status"></span>
    <script>
    $(document).ready(function(){
      var phono = $.phono({
        apiKey: "your secret key",
        onReady: function() {
          $("#call").attr("disabled", false).val("Call");
        }
      });

      $("#call").click(function() {
        $("#call").attr("disabled", true).val("Busy");
        phono.phone.dial("app:9996182316", {
		  	headers: [
			             {
			               name:"x-numbertodial",
			               value:$('#phonenumber').val()
			             }
			           ],
          onRing: function() {
            $("#status").html("Ringing");
          },
          onAnswer: function() {
            $("#status").html("Answered");
          },
          onHangup: function() {
            $("#call").attr("disabled", false).val("Call");
            $("#status").html("Hungup");
          }
        });
      });
    })
    </script>
  </body>
</html>

You could write a Tropo transfer application using the Scripting API in one line of Ruby code that transfers the call to the phone number in the SIP header like this:

transfer $currentCall.getHeader("x-numbertodial")

What if you wanted to add a timer that ends the call after 10 minutes like we do on phono.com for demo purposes? This feature is also simple but it requires multithreading your Ruby application and using our REST API for sending a signal to interrupt the transfer method once your timer reaches its alarm.

require "net/http"

# Create second thread for timer and announcements
Thread.new do
  sleep 600 # Note: Sleep is in seconds so 600 = 10 minutes

  http = Net::HTTP.new "api.tropo.com"

  request = Net::HTTP::Get.new "/1.0/sessions/#{$currentCall.sessionId}/signals?action=signal&value=limitreached"
  response = http.request request
end

say "hold please while we transfer your call."
transfer $currentCall.getHeader("x-numbertodial"), :allowsignals => "limitreached"
say "your limit has been reached."

That’s cool but what if you wanted to block certain phone numbers or limit the demo calls to North America? You could add area codes or phone numbers to a regex array and check the desired phone number against the list of regexes to see if you should allow the call to transfer or not like this example:

phone = $currentCall.getHeader "x-numbertodial"

# Blocked North American area codes
blocked = [
  /^\+?1?8[024]9/,
  /^\+?1?26[48]/,
  /^\+?1?24[26]/,
  /^\+?1?34[05]/,
  /^\+?1?[62]84/,
  /^\+?1?67[10]/,
  /^\+?1?78[47]/,
  /^\+?1?8[024]9/,
  /^\+?1?86[89]/,
  /^\+?1?441/,
  /^\+?1?473/,
  /^\+?1?664/,
  /^\+?1?649/,
  /^\+?1?721/,
  /^\+?1?758/,
  /^\+?1?767/,
  /^\+?1?876/,
  /^\+?1?939/
]

block_call = blocked.any? { |x| phone =~ x }

You could add this code immediately above your transfer and add a conditional statement that says something like this example:

if block_call
  say "calls to this area code are blocked."
else
  say "hold please while we transfer your call."
  transfer phone, :allowsignals => "limitreached"
  say "your limit has been reached."
end

You could also add billing functionality to the Tropo script by applying a rate based on country code and multiply it times the number of seconds that the call was in progress. To accomplish this goal, you would add a timestamp at the beginning of the script and a timestamp directly following the transfer method. When either party hangs up, the Tropo script will continue running with the line immediately following the blocked method such as transfer in this case.

If necessary, you could also check to see if the Phono caller is still on the call by interrogating the $currentCall.isActive property or by wrapping your entire application in a while loop like this example:

while $currentCall.isActive
  # Do Stuff
end

I think that should get you started! You can now build your next-generation click-to-call application using Phono and Tropo! Please let us know how you are using Phono with your Tropo applications :)

Up in the Air with Tropo and ScraperWiki

Tuesday, December 20th, 2011

ScraperWiki is a powerful cloud-based service that lets you scrape data from online documents and websites.

When you write a scraper – a script to pull information from a web resource and then parse out the bits you want – it will execute inside the ScraperWiki environment.

SMS flight information

You can store the data that is scraped inside a data store and then access the data from outside the ScraperWiki environment using their API. Scrapers can be written in one of several different languages – Ruby, PHP and Python.

ScraperWiki and Tropo operate in a very similar way. The Tropo scripting environment allows you to write scripts in one of several different languages, including Ruby, PHP and Python (Groovy and JavaScript are also supported).

Your script executes inside the Tropo environment, which means you can make direct connections to external resources – like the ScraperWiki API – from within your executing script. There is no need for extra HTTP overhead, and the additional step of posting to a back end server to connect to other APIs or resources.

In the following screencast, I demonstrate how to use Tropo and ScraperWiki to quickly and easily build an airport information system for the Philadelphia International Airport.

All of the code for this example can be found here. If you’d like to view the actual scraper I wrote on ScraperWiki, you can find it here.

This is still a work in progress – I’d like to run this script multiple times per day (ideally, maybe once an hour) to get updates to flight information and ensure that the app has the most up to date flight status. The voice dialog could also use a little tweaking, and I’d like to offer the option of repeating the information.

But even with these refinements aside, it is evident how combining these two powerful cloud resources can generate a pretty useful application in a very short time.

Tropo and ScraperWiki are a powerful combination. Happy flying!

Tropo Powers Apps for Communities Winners

Friday, December 16th, 2011

Yesterday, at the Andreessen Horowitz Offices in Silicon Valley, FCC Chairman Julius Genachowski announced the winners of the Apps for Communities challenge.

The challenge, a several months-long call to developers to build apps that connect people to their communities, culminated with the submission of 75 innovative applications. The idea behind the challenge, which was sponsored by The Knight Foundation and the FCC, was as follows:

“Using hyper-local government and other public data [entrants] should develop an app that enables Americans to benefit from broadband communications — regardless of geography, race, economic status, disability, residence on Tribal land, or degree of digital or English literacy — by providing easy access to relevant content.”

When the winners were announced, three inspiring, innovative applications built with Tropo and SMSified were among the winners, including the Grand Prize winner.

Here is a quick summary of the winning entries that used our platforms:

YAKB.us (Grand Prize Winner)

YAKB.us is a realtime bus notification service that provides information via phone and SMS. The service, which is available in both English and Spanish, provides transit information in three municipalites – Arlington County VA, Charlottesville VA and Santa Clarita CA. This innovative application was built by Code for America fellow Ryan Resella.

PhillySNAP (Honorable Mention)

PhillySNAP makes it easy to get information on retailers in Philadelphia that provide reimbursement for Supplemental Nutrition Assistance Program (SNAP) benefits. The service allows users to send an SMS message with their address and then it provides the addresses of retailers near them where they can use their benefits. This application was initially developed at the Random Hacks of Kindness hackathon in Philadelphia this past June.

PhillySNAP was also featured on the SMSified blog several weeks ago.

Off to Market (Bonus: English Literacy)

Off to Market is another SMS-based app that provides the locations of farmers markets, where users can go to find fresh produce. It’s written in Node.js and uses the Tropo WebAPI. The developer – another Code for America alum, John Mertens – wrote a fantastic post on his blog about how he obtained, refined and staged the farmer’s market data for this app.

Congratulations to everyone who participated in this outstanding challenge, and congratulations to all of the great apps that were honored as winners!

Tropo SMS Wolfram Alpha Mashup

Tuesday, December 13th, 2011

Tim Strimple joined us at the LA Holiday Hackathon to get in on the competition of building Tropo applications for prizes and won a $50 Tropo Production credit for his Tropo SMS and Wolfram Alpha mashup!

You can ask the application virtually any question via SMS using the following phone number 661-206-2681 and it responds to your inquiry via SMS using Wolfram Alpha’s search results. Here’s a video of Tim demonstrating his application in action!

Here’s the code behind Tim’s Tropo SMS Wolfram Alpha mashup! It’s written in PHP and uses the Tropo Scripting API.

<?php  

function CheckForShortcut($request)
{
    if(stripos($request, "siri") !== false)
    {
        return "I don't like to talk about her.";
    }

    if(stripos($request, "remind") !== false)
    {
        return "I am not your personal assistant.";
    }

    if(stripos($request, "tropo") !== false)
    {
        return "Tropo is great, I love it!";
    }

	return false;
}

function ParseResponse($response)
{	
	//	Replace with real XML parsing
	$min = strpos($response, "</plaintext>");    
	$startPos = strpos($response, "<plaintext>", $min) + 11;
    $endPos = strpos($response, "</plaintext>", $startPos);
	$length =  $endPos - $startPos;

	if($min > 0)
	{
		return substr($response, $startPos, $length);	
	}
	else
	{
		return "Go ask Siri...";
	}
}

function GetResults($request)
{
    $shortcut = CheckForShortcut($request);

    if($shortcut)
    {
        return $shortcut;
    }

    $request = str_replace (" ", "%20",$request);
	$wolframApiKey = "XXXXXX-XXXXXXXXXX";
    $url = "http://api.wolframalpha.com/v2/query?appid=" . $wolframApiKey . "&input=" . $request;
    $response = file_get_contents($url);

	return ParseResponse($response);
}

if($currentCall->channel == "TEXT")
{
    $result = GetResults($currentCall->initialText);
    say($result);
}
else
{
    say("I do not support voice currently. Try sending me a text message instead.");
}
?>

Happy Hacking!

Tropo + Ushahidi = Awesome

Friday, December 9th, 2011

Ushahidi is a platform for crowdsourcing information. Members of the public submit reports that are geo-located and then put on a map. The platform is used in disaster relief, election monitoring and just about any other situation where people need to learn things from one another quickly and concisely. Out of the box, Ushahidi allows people to submit reports via the web, mobile applications, Twitter, Facebook with support for a few SMS APIs as well.

We have created an easy-to-use application that lets people use Tropo to input data into Ushahidi via SMS. We’ve put the code up on Github and you’re welcome to submit pull requests if you find bugs or add features.

To use the code, you don’t have to install anything on Ushahidi. Here are the steps:

  1. In Ushahidi, create a user with “Admin” privileges.
  2. check out the code from Github
  3. edit the configuration lines at the top with your Ushahidi credentials and URL
  4. create a new Scripting API Application on Tropo.com.
  5. Once your Tropo app is created, you can add an SMS-enabled number (US and Canada currently) and optionally configure it to talk on any IM networks or Twitter.

Now, when you send a message to any of your configured numbers the application will attempt to geo-locate the message based on its contents. The app then submits a report via the Ushahidi API in an unverified state. Admins of the site can then verify the reports and publish them to the web.

In our example here, we simulated a flood in Milwaukee. The instance pulls in feeds from local media and disaster response community, accepts reports via the web and accepts reports from a Tropo app I created. We sent a message to the number configured in the app with the following content:

 

Columbia St. Mary’s Hospital Milwaukee WI is flooded. Power is out.

This was submitted to Ushahidi in an unverified state. The reviewer then added text to flush out the report based on other incoming data and then published the report:

Columbia hospital has been without power for the past 16 hours. Two of the three emergency diesel generators are operating normally. Generator number 2 is scheduled to be functional within the next 6 hours. Fuel supplies are at nominal levels with an estimated 48 hours remaining. Inundation levels are currently low but may begin rising at high tide.

This sort of crowdsourced data, gathered at the source, is valuable for many reasons. It gets the word to responders and the public more quickly so that people can act appropriately (e.g. by not going to that hospital, go to another one.) First responders become aware of the weight of a problem when more people report the same thing or when the first report comes in of a very big event.

Watervoices.ca, developed this past weekend at RHoK, will be going live with this application soon and we hope to see others using it to help the world soon. Over time, we will be adding support for Voice, PhoneGap within Ushahidi and many other features.

Info Balloon: Multi-language Location-based Tropo Mashup

Monday, October 10th, 2011

In this post I’d like to tell you about the latest project I’ve been working on, which is built using the Tropo API. It’s an elaboration of the “Moveable” series of apps, which I have written about previously here. It’s also supercharged with some ideas lifted directly from Telephony Black Magic, originally presented by  Mark Headd.

My app is called Info Balloon, and you can check it out at www.infoballoon.org. You move a hot air balloon avatar around on a Google map, and get access to a number of location-based services. The app also features a text input field I call the “WormHole”, which allows you to jump directly to another location on the U.S. map. It uses an html5 text input element, so it accepts either typed or spoken text. And for added fun, courtesy of Google, it knows how to deal with colloquial names for places, like “This Big Apple” and “The Windy City”.

This app is all about retrieving location-based data. It calls out to a REST-like API I created, on the backend, so it should be readily extensible to more services. Right now, I’ve got it hooked up to:

  • The National Registry of Historic Places (via NRHP database)
  • Tides (via NOAA data)
  • Google Places (via Google Places API)
  • Weather (via Google Weather API)

For services like the tide and the weather, you get the local information applying to the zip code where your Info Balloon is located. For other services, like the National Registry of Historic Places, and Google places, each time you click the “Next” button you get the next entry, in an ever-expanding perimeter.

Another feature, which I’ll have more to say about later, is that you can get the information delivered to you in any one of 10 languages, from French to Chinese.  Thanks to JQuery, whenever you change a parameter, the app immediately responds by displaying in the appropriate language, with the appropriate data from the appropriate service.

But wait, there’s one more thing, and I’ve been saving the best for last.  You dial a special Tropo access number on your phone, and get all the info window data read to you, by a language -appropriate speaker, over the phone, in real time.

This real time spoken output on your personal voice channel is what make this app fun. You can rapidly switch between services, languages, and locations, and the speech output keeps chugging away. It’s all because of the magic of Node.js, Socket.io, Redis, and of course, Tropo.

Here’s the code, in PHP,  that orchestrates the output of this voice data:

say("OK");

$redis->subscribe($cellnumber);
do {
	$response = $redis->getResponse();
	$json = $response[2];
	if($json == "1") {
	   say("Press the Next button to hear the next entry.");
	}
	else {

           $obj = json_decode($json);
           $lang = $obj->{'lang'};
           $message = $obj->{'message'};
	    $array  = array(1 => "english",
	                    2 => "spanish",
			    3 => "french",
			    4 => "german",
			    5 => "polish",
			    6 => "italian",
			    7 => "dutch",
			    8 => "french",
			    9 => "russian",
			    10 => "chinese",
			    11 => "russian",
			    12 => "portuguese");

            if ($lang == "english")
               $speaker = "allison";
            elseif ($lang == "spanish")
               $speaker = "carlos";
            elseif ($lang == "french")
               $speaker = "bernard";
            elseif ($lang == "german")
               $speaker = "stefan";
            elseif ($lang == "polish")
               $speaker = "zosia";
            elseif ($lang == "italian")
               $speaker = "luca";
            elseif ($lang == "dutch")
               $speaker = "willem";
            elseif ($lang == "russian")
               $speaker = "olga";
            elseif ($lang == "chinese")
               $speaker = "linlin";
            elseif ($lang == "portuguese")
               $speaker = "amalia";

             say($message, array("voice" => $speaker));
	}

} while ($message != 'goodbye');

$redis->disconnect();
say("Thanks for listening.");
hangup();

I’m excited about the notion of a personal voice channel, a number you dial up to to listen to your personalized fire hose of data. Here, it’s data about locations you are visiting on a map, but really, it could be anything. It could be a real time translation of an SMS message, or a feed of your favorite news clipping service. There’s lots of potential here which I hope to explore in future posts.

My Voice is My Password. Verify Me.

Tuesday, August 23rd, 2011

I remember watching the movie Sneakers (probably 20 times) and would always rewind the part where they could unlock doors with their voice.

The technology, known as voice print identification or voice bio authorization, was demonstrated by the geek Werner Brandes when he utters the words, “My voice is my password. Verify me”, to gain entry to his high-tech office.

This has always sounded uber, geeky, cool to me and it’s been on my list of hacks to try out on Tropo but it looks like someone beat me to it!

The guys over at Disruptive Technologies recently wrote a blog post about Voice Biometrics with VoiceVault and Tropo!  To simplify using the VoiceVault API, Disruptive Technologies created a PHP library that can be used with Tropo for both the enrollment and the verification of voices prints. The library is available on Github as part of their sample WordPress Plugin.

Their sample WordPress Plugin was developed to show you how voice biometrics can be used in real life. You can add it to any WordPress site to enhance the user Signup and Password Reset functionality with voice biometrics and Tropo!

If you want to checkout how the plugin works, first browse to this Sign Up Page and sign up for an account. You will receive a phone call asking you, a couple of times, to speak a 4 digit code, this is used to enroll your voice. After enrolling your voice you can call+1(818) 533-9824  to receive a new temporary password to login to WordPress. Make sure to call from the phone number you registered when you signed up for the WordPress account!

Image the communications apps that you could build using this technology!  The future is now so what are you waiting for – add voice bio metrics to your apps today using Tropo and VoiceVault thanks to Disruptive Technologies!

Tropo + OpenBTS + Burning man = Awesome

Tuesday, August 23rd, 2011

One of the cool things about Tropo is that it’s not trapped in the cloud.  Sometimes your cloud provider can go down.  But fortunately as an open source project of Voxeo Labs, pretty much anyone can spin up their own private Tropo cloud.   You can also run a hybrid cloud that leverages the best of both worlds.  Yeah, Tropo is good like that.

We set out to prove that it could be done, so we decided to pick the most unlikely place we could think of to set up a private Tropo cloud: on the Playa at Burning Man (of course).    Is it possible to set up an open-source telephone network in the middle of the desert?   We’re going to find out next week.

Tropo OpenBTS Burning Man

We called up our friend David Burgess at Range Networks about the OpenBTS network he’s been setting up at Burning Man every year for the past 4 years. Along with David, we mapped out the technical details of how to connect Tropo to OpenBTS.   We put together a team to work on integration and build a couple of Tropo apps to test on the Playa.  Over the weekend I got this message:

[8/20/11 5:53:45 PM] Tim Panton: First call from openBTS via vsat  out through tropo to the PSTN _WOOP_

So it looks like we *may* have some connectivity, but what can you DO with it?

Well, first and foremost we have an open source voiceboard app written by Chris Matthieu of Teleku and Nodester fame.  The Voice Board application is an asynchronous voice messaging platform. It allows callers to join in on live conference calls or leave messages for their friends.  Burners can connect to other Burners using the Voice Board app.

The other app was developed by Adam Kalsey (founder of IMIfied).  It’s an SMS Gateway which is providing OpenBTS its first SMS gateway to the outside world.  We didn’t want Burners to get bombarded with text messages from the outside world, so the gateway is set up to only receive messages AFTER someone has sent one FROM a phone connected through the OpenBTS network first.

Jason Goecke (co founder of Adhearsion) delivered the Voxeo PRISM server to Range Networks.  Lincoln Anthony & Tim Gridley (Voxeo Network Operations), Wei Chen & John Dyer (Voxeo Labs), Aaron Huslage (Founder of Tethr) and Tim Panton (PhoneFromHere) all have lent time and expertise to make this project go as well.

Our “man on the ground” this year is Voxeo Labs Chief Architect, Jose De Castro, who volunteered to go to the playa at Burning Man and help set things up.  In addition to the OpenBTS team, Jose will be joined onsite by Willow Brugh of Geeks without Bounds (who has assured me she will be at least “half naked most of the time“).

A parallel team working an app on the same OpenBTS network is being coordinated by the Technology and Infrastructure in Emerging Regions group at UC Berkley.  More information about their project can be found here:  TIER at Burning Man.   Additionally, Aaron Huslage is also working in parallel with Ushahidi‘s open source crisis mapping software to ultimately build a very flexible and portable “crisis communications in a box” system.

The camp where we’ll be testing from is called Papa Legba.  If you are heading to the Playa this year and would like like to participate in this groundbreaking test, I strongly urge you to check out the Papa Legba 2011 FAQ. Details about the kind of services and what kind of GSM phone equipment you need to connect to the OpenBTS network can be found there.

Tropo AR Drone Contest Winner

Tuesday, August 23rd, 2011

Man we had a couple of REALLY cool applications submitted for the AR Drone contest, but like a wise immortal once said “There can be only one..”, and with that immortal bit of wisdom I am happy to annonce the winner of the contest….

Drum roll please………………………………………..

May I have the envelope………………………………

And the winner is……………………………………….

Mattt Thompson from Austin, TX!!!  (applause, the crowd goes wild)

Congrats Matt, we sure hope you enjoy this AR Drone for your Thy-Dungeonman application.

Mattt’s submissions was a speech controlled choose your own adventure RPG style game which was really quite cool.  The team really liked this application for quite a few reasons, and none of them have anything to do with us being RPG nerds :P.

Among other, unnamed reasons, we really like this because it showed off some powerful Tropo technologies & principles:

  • Support for SRGS /GrXML grammars for advanced speech recognition
  • Skype-In numbers on all applications
  • SIP Support for all applications
  • Free phone numbers for developers
  • Using the WebAPI to communicate w/ the Tropo platform
  • General ‘Awesomeness’®

We asked Mattt to tell us what he thought about the Tropo platform after he submitted his application, here is what he said to say:

Tropo is kind of like a manic pixie dream girl in an indie flick, played by Natalie Portman, or Ellen Paige. You know, the kind of girl who can rattle off every The Smiths lyric, and owns the complete works of Coltrane in its original vinyl. Pretty, with insane depth. Tropo takes decades of wisdom about telephony and brings it to the modern context of web APIs. “Thy Dungeonman” would not be possible if it weren’t for Tropo’s support for [SRGS grammars], which opens up a world of possibilities for realtime natural language processing.

You can download his application from our GitHub contest page or go straight to Mattt’s GitHub site if you want to check out some of his other creations as well! Hatt’s off to you Mr. Thompson, and we sure hope you enjoy your Drone!

-John

Tropo giving away a Parrot AR Drone @ LSRC!

Wednesday, August 10th, 2011

I’m leaving in about 30 minutes to head to Austin, TX – the site of LoneStar Ruby Conf 2011 – and boy am I excited. What am I so excited about? For one, I get to check out all the great talks, especially Ben Klang’s talk on Ruby & Adhearsion! I’m also excited to mingle with awesome Rubyists and to give away some really cool stuff, like a Parrot AR Drone! Yeah, that’s right, Tropo is holding a contest for most innovative Tropo app (Phono and SMSified apps will also be accepted, as fellow Voxeo Labs APIs) and will be giving away the AR Drone on the last day to the winner!

Below you will see a Drone fly thru our new offices as they were still under construction – man this is a cool video!

You can find more info on the event by checking out the Rubyology interview Chris Matthieu & I just had with Jim Freeze, the organizer of LSRC. It has tons of great info on what is sure to be a fantastic event!! We hope to see you there!

-John