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

Node.JS Magic 8 Ball Voice App

Friday, December 23rd, 2011

Remember the Magic 8 Ball game from yesteryear?

How would you like to have the game with you in your pocket when difficult answers are required.

I built this Magic 8 Ball game using Node.JS and the Tropo WebAPI. If you roll the array up to a single line of code, you’re only looking at a 25-line Node.JS application!

You can call this application at 415-889-8684!

Here is the Node.JS source code that runs the application.

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

// http://en.wikipedia.org/wiki/Magic_8-ball
var answers = [
"It is certain",
"It is decidedly so",
"Without a doubt",
"Yes – definitely",
"You may rely on it",
"As I see it, yes",
"Most likely",
"Outlook good",
"Signs point to yes",
"Yes",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful"
];

http.createServer(function (req, res) {

	// Create a new instance of the TropoWebAPI object.
	var tropo = new tropowebapi.TropoWebAPI(); 	
	var answer = answers[Math.floor(Math.random()*answers.length)];

	tropo.say("Welcome to the tropo node J S magic 8 ball.");

	var say = new Say("Ask your question now after the beep.");
    var choices = new Choices(null, null, "#");

    // Action classes can be passed as parameters to TropoWebAPI class methods.
    // use the record method https://www.tropo.com/docs/webapi/record.htm
    tropo.record(3, false, null, choices, "audio/wav", 5, 60, null, null, "recording", null, say, 5, null, "http://example.com/tropo", null, null);

    tropo.say(answer);

	tropo.say("Please call back to play again!");

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

}).listen(13188);

Be careful what you ask for…

Voice Texting With Tropo Speech & SMS Technology

Wednesday, December 21st, 2011

We all agree that texting while driving is very dangerous, right? Fred Wilson, VC and principal of Union Square Ventures thinks so too. He recently wrote a blog post that starts like this:

“As a parent of two young adult drivers and a third soon to hit the road, nothing scares me more than texting while driving.”

Fred continued his blog post envisioning a Voice Texting application as follows:

“Being an engineer at heart and by training, I’ve been looking for a solution to the problem. I know that the buzz of the phone and the unread/unresponded message is like a drug to many and that the best solution would be a “hands free” way to read and respond. And the bluetooth/hands free voice solution works so well on most cars and most phones now, so why can’t we do the same with texting?”

Having two kids of my own (1 already driving and 1 studying for a drivers permit) and having access to the Tropo API and platform, I felt compelled to build a quick Voice Texting application to share with Fred Wilson! Here is what Fred had to say upon me sharing it with him…

Here is how it works:

To send a text, call (415) 349-3120 and using Tropo speech recognition say the phone number that you would like to text and then speak your message. Tropo then transcribes the message and sends your text message to phone number you spoke without taking your eyes or hands off the road.

Disclaimer: We are not promoting texting while driving even with the proper tools that would keep your eyes on the road such as a bluetooth earpiece and autodial features.

The source code for this project is written in Ruby and open sourced on GitHub in case anyone would like to extend it or perhaps even create a new business around this idea and have a head start! Here’s a video of me demonstrating the technology in action:

Drive safely!

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

New Fax Library for Pythonistas

Thursday, September 22nd, 2011

Remember the post we did earlier this year with the Ruby gem written by Jason Goecke called pamfaxr for sending and receiving faxes? Well we are excited to announce that there is a new Python library by Jonathan Sweemer to do the same thing! Here’s the source code on GitHub too!

Jailbreaking OpenVBX

Wednesday, September 21st, 2011

Remember when the iPhone was only available on AT&T?   That was true until October 11, 2009 when a young coder named geohot (and friends) released the first iPhone/iPod jailbreak.  Suddenly iPhones weren’t tied to to just AT&T…now you could give AT&T the boot and choose Verizon or T-Mobile as your service provider.  Score!

In the spirit of geohot’s jailbreaking efforts, the rapscallions at Disruptive Technologies took on the the task of “jailbreaking” OpenVBX.

OpenVBX is a web-based open source phone system. It’s essentially a virtual PHP/MySQL PBX  and it’s available for download from GitHub.   Users of OpenVBX can make phone calls, send text messages…all very cool.

The catch is…you’re locked into one service provider: Twilio.  There’s no way to choose to use another cloud telephony provider…until now.

Today we’re pleased to announce a new fork of OpenVBX that adds support for Tropo.  For the first time, users of OpenVBX will have a choice of multiple platforms on which to run it, making it REALLY OpenVBX.

The coders at Disruptive Technologies added full support for the the Tropo API and Phono SIP-based VoIP web phone to the communications layer of the OpenVBX project. Of course, when selecting the Tropo API, users will now get access to all of the more advanced features of the Tropo network: speech recognition and text-to-speech in 24 languages, phone numbers in over 40 countries, international SMS, in/outbound SIP VoIP support, inbound Skype support, multiple phone numbers per callflow script, improved conferencing.

Disruptive Technologies also extended OpenVBX with the VoiceVault API to support Voice Biometrics in password resets. After adding VoiceVault credentials on the API Accounts Tab, the password reset dialog will provide an option to request a phone call to reset your OpenVBX account password.

The OpenVBX fork with Tropo can be found on GitHub.  We have sent the maintainer of the OpenVBX project a pull request to merge these updates into the project. The following features and bugfixes have been added to the OpenVBX package:

  • Fixed a redirect bug. OpenVBX no longer incorrectly redirects users to 404 pages.
  • Fixed bug in Twilio client. 60 seconds after the user has been “inactive”, the client is no longer able to be called for that user. This prevents calling the client if the user has closed their browser. (This also works for the Phono Client)
  • Added support for the Tropo API. You can now add a “Tropo API account” on the system settings page, and from the installer. Either a Tropo or Twilio account is required. Included in the new Tropo API additions are:
    1. Support for Tropo domestic and international phone numbers, on the “numbers” page.
    2. All applets in the “flows” page now support Tropo JSON as well as TwiML. Any number can be assigned any flow – so a tropo number and a twilio number can both be assigned the same flow.
    3. Support for existing Tropo numbers & applications. If the user prefers to set up their numbers initially in Tropo.com, the application will see these numbers and they can be assigned a flow within the application.
    4. Recordings, and Voicemail, as well as outbound dialing with Tropo.
  • Several theme changes. The OpenVBX logo has been modified to include both the Tropo and Twilio logo. If only one of the accounts is active, only that logo will show in the VBX logo – so if a user only has a Twilio account, only the Twilio logo will show, and vice versa. Other minor theme changes:
    1. Several pages in the System Settings tabs have been reworked.  Notibly the API accounts page, which now has each API accounts logos.
    2. Step 3 of the installation has been reworked.
    3. Several Twilio-specific content has been changed to be more ambiguous.
  • Added support for “Phono” browser phone, in addition to the Twilio Client. Any non-Twilio based numbers will use the new Phono browser phone.

This project has since been renamed to TropoVBX. Please refer to the updated blog post and new source code repository on GitHub.

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!