Archive for the ‘SourceCode’ 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 :)

Dial and SMS your APIs with Tropo

Thursday, December 22nd, 2011

The number of APIs available are increasing by the day and so is the popularity of Node.JS, the server-side event-driven javascript framework. This got me thinking… How cool would it be to be able to call or sms an API with your phone using Node.JS?

This is a pretty simple thing to do with Tropo and Nodester. Tropo has an NPM module available for adding Voice, SMS, and Instant Messaging to Node.JS applications and Nodester has REST APIs available to report on the status of the platform. 25 lines of Node.JS code later, we now have an Node.JS application using the Tropo API to dial and sms the API to retrieve the status of the platform.

Here’s the phone number: (480) 428-8723 to call or SMS.

Install the Tropo WebAPI and Mikeal Rogers’ Request NPM modules:

npm install tropo-webapi -g
npm install request -g

Run this code on localhost or deploy it to a Node.JS hosting service like Nodester.

var http = require('http');
var tropowebapi = require('tropo-webapi');
var request = require('request');

http.createServer(function (req, res) {

	// Create a new instance of the TropoWebAPI object.
	var tropo = new tropowebapi.TropoWebAPI(); 	

	// Fetch Nodester status -> http://api.nodester.com/status
	// returns {"status":"up","appshosted":2878,"appsrunning":1759}
	request('http://api.nodester.com/status', function (error, response, body) {
	     if (!error && response.statusCode == 200) {

	       // console.log(body) // Print status
	       var statusreq = JSON.parse(body);

	       tropo.say('nodester is ' + statusreq["status"] + ' and hosting ' + statusreq["appshosted"] + ' applications with '+ statusreq["appsrunning"] + ' running at the moment ');

	       res.writeHead(200, {'Content-Type': 'application/json'}); 
           res.end(tropowebapi.TropoJSON(tropo));
	     }
	   })

}).listen(13151);

One of the really cool things about the Tropo API is that you can write your app one time and it automatically runs on multiple communications channels such as: Voice, SMS, and Instant Message.

Tropo Jambox Megaphone

Monday, December 19th, 2011

After rocking out to a little White Stripes’ Icky Thump, Chris Matthieu shows you how to build a megaphone using a Jawbone Jambox, an iPhone, and the Tropo Scripting API!

Here’s the Ruby script used in the video:

say "Welcome to the Tropo megaphone app! Please turn on and pair your Jam box now."

while $currentCall.isActive do

record "Record your message at the beep and then switch audio to jam box.", {
        :beep => true,
        :timeout => 10,
        :silenceTimeout => 7,
        :maxTime => 60,
        :onRecord => lambda { |event|
            log "Recording result = " + event.recordURI
            say event.recordURI}
        }

end

Rock on!

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.

The People’s Skype for the #Occupy Movement

Monday, December 5th, 2011

This is a guest blog post by Jonathan Baldwin showcasing an application that he wrote using Tropo called The People’s Skype. It’s phone-powered, distributed voice and voting system for the #Occupy Movement!

As the Occupy Wall Street movement grew in popularity at Zucotti Park in NYC, and other occupations in North America, Jonathan noticed a problem with the primary method occupiers used to communicate in large groups. The People’s Mic, a method of augmenting a speaker’s voice by having listeners repeat their words, didn’t scale up when huge numbers of people attended rallies and General Assemblies. In these cases, the audience had to repeat the speaker’s words multiple times before it reached the far edges of the crowd – it became gradually harder to understand the original speaker’s words the further you are from the inner circle.

Motivated by this, Jonathan was determined to find a simple solution that anyone had access to. There were similar talks amongst the OWS Tech groups about ways to solve this problem, but those ideas never panned out (they included handheld radios and VoIP systems). He also wanted to address another problem of General Assemblies – hand signals are used to communicate consensus with ideas. In a massive crowd, it is hard to express opinion through visual cues, so he wanted to integrate this problem into a one package solution.

Thus, Jonathan created a one-way conference call solution, called The People’s Skype, through the Tropo phone system. Using PHP, MongoDB and Tropo, he created a simple interface that anyone with any kind of phone, no matter how old, could dial in and create a unique mic with. Upon mic creation, the speaker is given a 4 digit PIN to distribute to others that want to listen in (by holding up a sign or word of mouth). Anyone can call to the original number and listen by typing the unique PIN. Only the speaker is able to talk, while listeners can vote on issues by using their dial-tone, phone keypad (1 for Yes, 0 for No, etc.).

As the Tropo conference call system is able to support hundreds of people, audience members can either turn their speakerphones on to create a distributed PA system, or listen directly on their handsets. Due to the applications flexibility, it could potentially help fragmented occupiers communicate across police barriers or kettled areas.

Try out The People’s Skype yourself: http://www.peoplesskype.org! You can also download a copy of Jonathan’s source code from Github.

Introducing TropoVBX

Wednesday, November 16th, 2011

As you may recall, Disruptive Technologies recently extended the capabilities of OpenVBX (the open source cloud PBX software) to run on our Tropo cloud communications platform. The original blog post announcing this project was entitled, “Jailbreaking OpenVBX“. This title was chosen carefully because at the time of the post, OpenVBX only ran on a single cloud platform. Disruptive Technologies was able to extend the communications layer of this application to not only add support for Tropo but also simplify future efforts involved in adding support for other platforms such as Asterisk, FreeSwitch, and others.

As it turns out, the original repository maintainers declined to accept Disruptive Technologies’ GitHub pull request to merge the code bases and asked that the name of the new project be changed, effectively requesting a formal fork of the open source project. Here is the new GitHub repository for TropoVBX.

The TropoVBX fork still provides support for multiple platforms – including the platform of the original repository maintainer. Disruptive Technologies will also be merging updates from the original fork where possible and continuing to add new features to TropoVBX as time permits. Because TropoVBX now runs on the Tropo platform, there are many new and advanced features only supported Tropo which include:

  1. Speech Recognition in 24 languages
  2. Text-to-Speech in 24 languages with male and females voices for each
  3. Support for biometrics on password resets
  4. Ability to route Skype calls into TropoVBX
  5. Ability to support true SIP VoIP in and out of the platform
  6. Phono web phone integration
  7. International SMS
  8. Phone numbers in 41 countries
  9. Multiple phone numbers supported per callflow
  10. Large conference calls

Please feel free to clone, contribute, and fork the new TropoVBX project and use our logo as you see fit. Our version of this project will remain truly open in every sense of the word and spirit of open source.

Voice Board and Group SMS for Burning Man

Thursday, August 25th, 2011

This is a true testimonial to the power of running Tropo in a Private Cloud using generators for disaster relief or business continuity or for handling communications for events like Burning Man!

This rack includes Tropo and OpenBTS communications equipment for powering Burning Man’s Tropo Voice Board and Group SMS apps!

Once a year, tens of thousands of BurningMan participants gather in Nevada’s Black Rock Desert to create Black Rock City, dedicated to community, art, self-expression, and self-reliance. They depart one week later, having left no trace whatsoever.  Black Rock Desert (or the Playa as Burners refer to it) is an isolated region with no electricity, running water, or communications.

Tropo has partnered with Range Networks and GWOB to setup a local OpenBTS-powered cell tower to provide both Tropo-powered Voice and SMS communications services to the Burners on the Playa.

Custom Private Cloud Tropo applications have been developed to deliver a social voice mail solution – or better yet – an asynchronous voice board messaging platform as well as a Group SMS solution like Facebook’s new messaging app but for local Burners only.

This is what the Voice Board application looks like if you were to connect to the Tropo server using a local IP address!  It’s basically a Ruby on Rails 3.1 application utilizing Tropo’s Scripting API and small Ruby script.  The website is designed to allow the outside world to interface with the Burners, provided we can establish a good satellite data uplink (more details to follow). The website grabs the latest BurningMan-tagged Flickr image and associates it with a voice memo being streamed while enjoying photos from the event.

Burners can call into our Voice Board application to record social voice memos and listen to public messages left by other Burners on the voice board. If a recording is in progress when a new call comes in, it automagically  becomes a conference room party line and continues recording the chat from the participants.

The conference room recording simply becomes another voice memo like the others – presented in descending order to new callers. As you listen to voice memos, they automagically get marked as read and disappear from your list. The Voice Board application loops through options (record memo or listen to memos) while the call isActive and lets you leave multiple voice memos or join the conference after listening to memos (if one is in progress)!

The Voice Board application also includes a Group SMS application which is available only for the local Burners. Any one who has called the Voice Board or texted a message to the Tropo Group SMS app will automagically be added to the Group SMS distribution list for the duration of the event.  They will receive text messages from other Burners any time the Voice Board is sent a text message!

The source code for our the Tropo-powered Voice Board and Group SMS application can be found at https://github.com/chrismatthieu/voiceboard

We are also in the process of establishing a satellite data connection to allow for VoIP connectivity of these communications applications to the outside world allowing the Burners to actually make real phone calls to anyone in North America.  This is powered byt the Tropo.com Public Cloud service.  If communications with the outside world can be established, Tropo will be sponsoring an unlimited number of 5 minute phone calls from the Playa to any phone number in North America to allow Burners to stay in touch with loved ones and to provide an additional route for emergency communications.

We are proudly embracing the BurningMan experience and we hope to gain more experience in using Tropo to deliver real-time communications services in times of disaster and business continuity programs as well as allowing our customers and telcos/carriers to run Tropo’s cloud communications API and platform in their own data centers and private voice clouds.

For more information on about Tropo’s involvement and applications used in the BurningMan event, please refer to our blog post below or contact Chris Matthieu at chris [at] tropo.com

http://blog.tropo.com/2011/08/23/tropo-openbts-burning-man-awesome/

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 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

Speech Enabling Open311

Tuesday, August 9th, 2011

Since SpeechTEK is this week, I thought it was a good time to update a post I did several months ago on using speech recognition to capture a street address.

There are lots of reasons why you might want to collect a caller’s address over the phone.

In open government circles, there has been a lot of interest lately in using automated IVR systems to help gather non-emergency service requests for municipalities. This makes a lot of sense – many municipalities enable non-emergency service reporting through the use of a designated abbreviated dialing number – 3-1-1 – so there is a long history of reporting these issues using the telephone.

Address collection is used quite often in IVR systems, but typically relies on expensive proprietary or “black box” components that might not be suitable for all use cases. This is particularly true for municipalities and local governments who are under financial pressure and who need to do more with less.

In this post, I’ll show how to build a sophisticated address collection system that can be used for almost any city or town, large or small. All of the code for this example is on GitHub (and under active development) and many of the components I will use are free or open source.

Here is a screen cast demonstrating the system running on the Tropo platform.

How it works

The application demonstrated here relies on three primary ingredients:

  • A data source with all of the street names in a city (in this case, I used the San Francisco Basemap Street Centerlines file from DataSF.org)
  • A database that can store the data on street names and zip codes, and which can be queried to render a speech grammar. In this instance, I use CouchDB.
  • A telephony platform that supports speech recognition – in this case, Tropo.

The application is structured to ask the caller for a zip code – obtaining a zip code will help us constrain the number of choices in our speech grammar and help ensure a better recognition.

The application then builds an SRGS grammar in XML format using CouchDB’s view and list functions. This grammar contains a list of all of the streets in a particular zip code and allows a caller to add additional details, like house number and street direction (if applicable).

In the event that a successful match can’t be made (this is inevitable in some small percentage of calls), we ask the caller to say their full address and make a recording.

This recording can be transcribed after the call has ended to gather the caller’s address – this might be a manual step, or it could be automated using functionality provided by Tropo.

Building for the cloud

The example shown here is built to run on the Tropo cloud communication platform, and uses a cloud-based instance of CouchDB.

This same basic approach could be replicated with a more conventional architecture, and could also use a standard relational database (as I did in my previous post on this subject).

But using cloud-based components has a number of advantages that might be attractive to smaller governments that want to employ this approach, or even larger governments that face fiscal constraints or challenges.

Using a cloud-based platform like Tropo makes deployment and scaling easy. It also means that you get access to the latest and greatest technology to support the open specification for speech recognition grammars. The folks that work at Voxeo (the company behind Tropo) help write these standards.

Using CouchDB has a number of advantages too. Populating a CouchDB instance with street data is extremely easy with tools like shp2geocouch by Max Ogden. In addition, it’s actually pretty straightforward to write view and list functions to generate a speech grammar – after all it’s just JavaScript.

If you found this post and screen cast useful, head on over to the GitHub repo for this solution and sign on as a watcher – I’m going to be actively developing this with the goal of deploying it for a municipality in the near future.

Stay tuned!