Archive for January, 2011

Command Line SMS

Sunday, January 30th, 2011

Ever have the desire to send an SMS message from the command line?  We’ll with bash functions its quite simple, and I’ll show you how!

First lets deploy the Tropo code, we’ll use Ruby for this example:

message($messageToSend, { 
    :to => $numberToMessage, 
    :network=>'SMS',
    :callerID=>$callerID.to_s
    }) 

Please note that you will want to ensure that you have an SMS enable number associated with the application, as this is a requirement in order to send an SMS on Tropo. You will also want to make note of the messaging token once you create the application, as this will be important for the next part:

Below you’ll see an easy function you can add to your .bash_profile. (non *nix based operating systems need not apply). You will need to set the callerID and the TOKEN_ID variables to the correct values specific to the application you created in the previous step. Setting the callerID to the number is critical, as the app will not function without it!

function sms(){  
    TOKEN_ID='your_token_id_goes_here'
    APP_CALLER_ID='4075551234'      #This needs to be a valid callerID associated with your application
    ENCODED=$(echo -n ${*:2:100} | \
    perl -pe's/([^-_.~A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg');
    curl "http://api.tropo.com/1.0/sessions?action=create\
          &token=$TOKEN_ID&numberToMessage=$1\
          &messageToSend=$ENCODED&callerID=$APP_CALLER_ID\
          " > /dev/null 2>&1
}     

The function takes two sets of parameters, the first is your 10 digit phone number, and second is the message to send. Since we are doing a HTTP get request we will need to make sure we property URL encode the data, which I have used Perl here to take care of for us! This URL encoded value is placed into the messageToSend parameter in our resulting HTTP request.

So all we have to do now is drop to Terminal, and then issue our command:

Then check out your phone:

Pretty cool, huh? -John

$40,000 in prizes up for grabs. Win with your source code.

Saturday, January 29th, 2011

Binpress is a new startup that’s built a marketplace for code. Sell your code, buy code from others. Whether you have a content management system, a plugin for WordPress or Drupal, or a great new UI widget built with jQuery, Binpress helps you market and sell your code. They take care of the license agreements, the ecommerce, and all the hassles associated with selling software.

To kick off their marketplace, they’re running a developer contest with $40,000 in prizes. They came to Tropo, wondering if we might be interested in providing a prize for the best code in one of the languages they support: PHP, Ruby, Javascript, Java, Python, or ASP.net.

Hmm, that list of languages looks pretty familiar. Tropo lets you host your code in PHP, Ruby, Javascript, Groovy (a Java-based scripting language), or Python. We have code libraries for our REST and WebAPI platforms using .Net, PHP, Ruby, Python, and Node.js.

We jumped right in and offered to sponsor not one language, but all of them. While we’re at it, we’re kicking in prizes for the rest of the contest, too.

Build the best app in one of Binpress’s languages and Binpress will give you $350 and a $100 Tropo credit for production usage. Win the Grand Prize — the best of show, as it were — and they’ll give you $1000 in Tropo credit. The second and third place winners will get $500 and $250 in Tropo credit, respectively.

There’s a whole lot of prizes totaling over $40,000, including service vouchers from Amazon Web Services, Media Temple, Sendgrid, Github, and Zencoder, cash from Conduit and Microsoft, and books from O’Reilly and Wrox.

Go jump in and build something awesome. You’ve got a month to create your masterpiece and win.

Pitching to Win at Philly Startup Weekend

Saturday, January 29th, 2011

At Startup Weekend, making a pitch is a core part of the event.

We at Tropo thought it would be a great way to underscore the importance of making a pitch to fund a startup by helping Startup Weekend participants see some great pitching of another kind.

Tropo will award the top three teams at Startup Weekend Philadelphia with the most innovative use of the Tropo platform with tickets to see the Philadelphia Phillies at home in Citizens Bank Park during the 2011 season.

This season, the Phillies will field one of the most talented (and feared) pitching rotations in all of baseball when the “big three” of 2010 National League Cy Young Award Winner Roy Halliday, Roy Oswalt, and Cole Hamles are joined by Cliff Lee. The return of Lee to the rotation will make 2011 a Phillies season that is not to be missed.

Before you make your pitch at Startup Weekend Philadelphia, find out how you can see one of the best pitching rotations ever assembled.

Find Mark Headd at the Startup Weekend event. Hell be around all weekend, including at our Startup Drinkup on Friday night.

Good luck to all the Startup Weekend participants!

Tropo Powers PennApps Mobile Winner

Friday, January 28th, 2011

The recent PennApps Mobile competition, held at the University of Pennsylvania on January 14th through the 16th, brought together teams of students to work on the next generation of mobile applications.

Tropo was proud to be a sponsor of this event, and equally proud to see one of the event standouts use the Tropo platform.

A team of four Penn Computer Science Students (Lu Chen, Matt Croop, Gary Menezes and Ryan Menezes) used Tropo to build the Decider, one of the winners of the PennApps event with an interesting take on the contest theme – Serendipity.

We talked with the team to find out more about their project, and why they selected Tropo.

Briefly describe your project – what is it, what does it do?

What should we do tonight: watch a movie or play board games? Should I pull an all-nighter or get some sleep? These five desserts on the menu all look delicious… Which one should I order?

Instead of flipping a coin, why not let a stranger decide?

We used Tropo to build the Decider, which anonymously sends your question to a randomly chosen stranger who decides for you. You can send questions over SMS and IM, or with our Android app.

What technologies does your project use?

Decider is written in Python, hosted on Google App Engine, and reliant on Tropo’s WebAPI library for all of its SMS and IM needs. The Android app is built with Java.

Explain your decision to use the Tropo platform. Why did you choose Tropo?

We first considered Tropo because the demo given at the event convinced us that using it would be simple and free. A big bonus was the ability to seamlessly tie in IM: our original intent was to just handle SMS, but adding IM support was effortless.

Finally, Tropo’s scripting made it easy to quickly debug and test, while WebAPI gave us a lot of flexibility in choosing a backend.

What did you like best about using Tropo?

Tropo made it terrifically easy to get started. Even though we had no experience with messaging technologies, it took our team of four less than 6 hours to sign up, learn WebAPI, deploy an app, and test it over chat and sms. The docs and sample code were excellent.

What are your future plans? Any plans to take the project to a wider audience?

Right now, we still think of the Decider as a fun experiment — we aren’t actively searching for users, but we’ll definitely keep it up to speed as more people join.

This smart, talented bunch has a bright future.

We at Tropo wish them the best of luck in all their future endeavors and hope that our paths cross again soon.

Simple tips for better text to speech

Thursday, January 27th, 2011

Are you looking for a way for your text to speech to sound more natural? Here’s a couple of quick tips.

First, make sure you’re using the right voice. Trying to pronounce Spanish words with an English or German text to speech voice will give poor results. The text to speech engine will phonetically say words it doesn’t know, leading to some odd-sounding vocalizations if you use the wrong language’s voice. See the voice parameter on the say() function for details on how to set the right language. You can also set the voice on ask() and record().

For English speakers, try using a different accent. Tropo provides both US and UK accents. Users in the US find that the British accented voices sound more natural. UK users tend to like the US voices better. Hearing a different accent helps mask the robotic sound of the automated voices.

Play around with our different voices for your application and see what sounds best to you.

Philadelphia Startup Drinkup

Thursday, January 27th, 2011

Tropo will be on hand at Startup Weekend Philadelphia, taking place this weekend in Hamilton Hall at the University of The Arts in Center City.

To help kick things off, we’ll be throwing a “Startup Drinkup” at the Fox and Hound on Spruce Street – just two short blocks from Hamilton Hall – on Friday, January 28th.

Come on over and join Tropo for some complimentary beverages on Friday starting at around 10:00 PM (or whenever teams finish up their work on Friday evening). We’d love to meet you and chat about the projects you have planned for the weekend.

A Philadelphia sports bar is also the ideal venue for announcing some special prizes that we’ll be offering Startup Weekend participants that make use of the Tropo platform.

The top three teams with the most innovative use of the Tropo platform will be getting an awesome prize from us. (Teaser for Philly sports fans – you’re going to love it!)

Come on by the Fox and Hound around 10:00 PM on Friday and find out what we’re giving to some lucky (and innovative) Startup Weekend participants.

Hope to see you there!

Three Free tickets for StartupCamp this weekend (and 25% off code for everyone else)

Tuesday, January 25th, 2011

If you’re in San Jose, Miami, or Los Angeles this weekend, we invite you to join us at StartupCamp and learn how to launch. We’re giving away one ticket for each city. Follow us on Twitter and tweet “Hey @tropo, send me to StartupCamp LA. http://bit.ly/fDV09t” (or Miami, or Silicon Valley) and on Wednesday morning we’ll randomly choose one winner from each city.

Not a winner? Use the coupon code TROPO at signup and get 25% off your tickets.

Control Your Tropo Scripts with External Events

Thursday, January 20th, 2011

A few weeks back, Adam Kalsey introduced an exciting new piece of functionality on the Tropo platform – the ability to control a Tropo script by injecting events into a running session.

This type of functionality has lots of very cool applications – you can break a caller out of a long running process, or stop an executing action like a conference or a transfer. And what’s even cooler, now you can have access to all of this functionality through the existing Tropo WebAPI library for PHP.

Here is a quick example to demonstrate how to use external events to interrupt an executing action – in this case, an inbound call to a Tropo script that performs a transfer to another number.

Say, for example, that you wanted to limit the amount of time that a caller could stay on the transfer. With external events, it’s a snap.

Consider the follow sample script.

// Include required classes.
require 'classes/tropo.class.php';
require 'classes/sag/sag.php';

// Grab the raw JSON sent from Tropo.
$json = file_get_contents("php://input");

// Create a new Session object and obtain the session ID value.
$session = new Session($json);
$session_id = $session->getId();

// Insert the Session object into a CouchDB database called sessions.
try {
	$sag = new Sag();
	$sag->setDatabase("sessions");
	$sag->put($session_id, $json);	
}
catch (SagCouchException $ex) {
	die("*** ".$ex->getMessage()." ***");
}

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

$tropo->say("Please hold while your call is transferred.");
$tropo->transfer("5551112222", array("from" => "7861112233", "allowSignals" => "transferOver"));

// Set event handlers
$tropo->on(array("event" => "continue", "next" => "hangup.php?uri=end&timeout=false"));
$tropo->on(array("event" => "transferOver", "next" => "hangup.php?uri=end&timeout=true", "say" => "You have reached the time limit. Transfer over"));

// Render JSON for Tropo to consume.
$tropo->renderJSON();

As you can see, I’m using a property of the WebAPI Transfer object called “allowSignals” and giving it a value of transferOver. This is the name of the external event we want to send to our script. When it is received, our Tropo script will end execution of the transfer and invoke the handler set up for the transferOver event.

In order to control a Tropo script with external events, we need to know the unique ID for the session the Tropo script is executing in. We can get this from the Session object which is sent to our script at the inception of the call.

$session = new Session($json);
$session_id = $session->getId();

We want to store this session ID somewhere so that we can access it when we want to end an outbound transfer that has gone on longer than some set time interval. For the purposes of this example, I’m just going to stick it into a running instance of CouchDB. Since the session ID for our Tropo script is globally unique, we can use it as the document ID for our CouchDB document.

In this example, I’ using the very handy Sag CouchDB library for PHP. It’s dead simple, and makes working with CouchDB from PHP a snap.

For this example, I’m using a fresh CouchDB database named “sessions.” Because we want to insert a CouchDB document with a specific document ID, we’re going to do an HTTP PUT – we do this by simply invoking the put() method of the sag object:

$sag = new Sag();
$sag->setDatabase("sessions");
$sag->put($session_id, $json);	

Now we can send a transferOver event to the session running our Tropo script. This is easy to do with the new sendEvent() method of the Tropo class.

Here is a simple script that uses this method to send an event to a running script:

#! /usr/bin/php
<?php

if(empty($argv[1])) {
	die("*** You must use a Session ID with this script ***\n");
}

$session_id = $argv[1];
$event_name = $argv[2];
$path_to_classes = $argv[3];

require $path_to_classes.'/tropo.class.php';
$tropo = new Tropo();

try{

	if($tropo->sendEvent($session_id, $event_name)) {
		echo "Event { $event_name } successfully queued.\n";
	}
	else {
		echo "ERROR: Could not queue event { $event_name }.\n";
	}

}

catch(TropoException $ex) {
	die("*** There is big trouble in River City: ".$ex->getMessage()." ***");
}

After you make this script executable, you simply invoke it by:

  • Giving it the id of the session to send an event to;
  • The name of the event to send, and;
  • The path to the Tropo WebAPI library files.

When invoked, it will generate a response like this:

{"status": "QUEUED"}

This means that the event is queued and will be delivered to the session that is running our script.

When the event is delivered to the script, it interrupts the ongoing transfer and causes a Result object to be sent to the URL specified in the transferOver event handler. The JSON for the Result object looks like this:

{
    "result": {
        "sessionId": "bc9fe7edf356cfa045cf6d814ff07bf1",
        "callId": "b7feb41c8e50768733a8875713d5541e",
        "state": "ANSWERED",
        "sessionDuration": 94,
        "sequence": 1,
        "complete": true,
        "error": null,
        "actions": {
            "disposition": "EXTERNAL_EVENT"
        }
    }
}

Note the disposition value in this object – EXTERNAL_EVENT – this lets your application know that the result was caused by an external event being injected into the Tropo session.

This functionality opens up a host of new avenues for Tropo developers to build sophisticated applications.

We’ll be adding this functionality to other Tropo libraries in the days ahead, and if you use Tropo scripting it’s already available to you.

Have fun!

Join Tropo at MagicRuby 11 Orlando Feb 4-5

Thursday, January 20th, 2011

Ruby Developers take note:  Tropo is sponsoring  MagicRuby 11!   MagicRuby is a free Ruby conference produced by Jeremy McAnally taking place February 4th and 5th at the Contemporary Resort in Disney World in Orlando, Florida.

Conference organizers have assembled an amazing lineup of speakers including keynoter and Ruby luminary Chad Fowler of InfoEther. Other speakers include guys from GithubRed HatEngine YardEnvy Labs and Intridea.

One example of the amazing talks scheduled at MagicRuby 2011: our friends at Envy Labs are giving a talk about lessons they don’t teach in programming classes. It takes more than just technical skills to succeed at being a software developer. You may also need to communicate effectively, manage projects, train your clients, and mainly just play well with others. We developers are an anti-social breed who enjoy being left to our own devices, so many of these skills don’t come naturally.

Gregg Pollack and Caike Souza will give some tips to help software developers improve their craft and increase the odds of succeeding at our chosen field. They’ll also share some of the core principles that they hold dear at Envy Labs, and show how they implement them on a daily basis.

Build Node.js apps for Tropo that use voice, SMS, IM and Twitter and host them at NodeFu

Tuesday, January 18th, 2011

NodeFu-1.jpgHave you been itching to try out Node.JS for a real-time communication app? Perhaps a voice application? Or a SMS or IM agent? Or a Twitter-bot? Did you read about our Node.js library for the Tropo Web API released back in October and think “That would be a cool way to learn Node.js!” But have been put off by not having a server on the Internet where you could run your Node.JS apps?

You don’t have to wait any longer… our own Chris Matthieu of Voxeo Labs today launched a project he’s been working on in his spare time called “NodeFu that offers free hosting of Node.JS applications at:

http://nodefu.com

The beautiful thing is that NodeFu is an excellent platform to build Tropo apps that interact with users via voice, SMS, IM or Twitter.

How to Get Started with NodeFu

First, take a look at the NodeFu home page where the process is documented. You request an invite via a curl command from the command line:

curl -X POST -d "email=your_address@example.com" http://nodefu.com/coupon

You will get an invite with a link to register a new NodeFu account. After that, all your interaction with your application occurs through curl and git.

You start out by registering a new NodeFu application using another command-line curl command:

curl -X POST -u "testuser:123" -d "appname=myapp&start=hello.js" http://api.nodefu.com/app

Assuming your chosen “appname” is available, NodeFu will send back a bit of JSON that includes the port number your app will run on and the name of the git repo you will push to. (If your appname is not available you will see that in the JSON and will have to try again with a new appname.) As each NodeFu application runs on a different port, you will now need to edit your Node.js code to have your server run on this provided port number.

When you are ready to deploy your code to NodeFu, you then just do two git commands:

git remote add nodefu the_url_returned_by_our_api
git push nodefu master

Your NodeFu app will be live at http://appname.nodefu.com. As you work on your app, you just do more commits to your local git repo and then do

git push nodefu master

when you want to update the live app. Once you push to NodeFu, your app should automatically be updated.

If you are building your Node.js app with the tropo-webapi-node library, which is perhaps the easiest way to get started, you should be able to go to your “http://appname.nodefu.com/” URL and see the JSON that will be sent to Tropo.

Setting Up The Tropo Side

To connect your NodeFu app to the communication services, you need to login to your Tropo account (or create a new free account if you don’t have one). Once logged in, you’ll go to “Your Applications” and click on “Create New Application” and then click the big button above “Tropo WebAPI”, as shown in this image:

tropoaddapp.jpg

Next you’ll enter a name, which only shows up in your list of Tropo apps, so you can use whatever name will help you remember what the app is. Then you will enter the “http://appname.nodefu.com/” URL that corresponds to your app.

tropoappinfo.jpg

After you click the big “Create Application” button, your app is basically ready to go! You’ll see a list of phone numbers come up and you can get started right away calling into the app via Skype or from a SIP softphone. If you want to add a phone number, you just click the link on the right side and add one (or more) of the available phone numbers. You can also use the section under “Instant Messaging Networks” to connect your app to Jabber, AIM, GoogleTalk, MSN or Yahoo!Messenger IM accounts… or to connect your app to a Twitter account:

tropocontactmethods.jpg

Phone numbers are provided for free to developers in a range of states and countries around the world:

tropophonenumbers.jpg

That’s it! Now you can get started calling, SMS’ing, IM’ing or tweeting into your Node.js app hosted over at NodeFu!

You can try out the application above by calling or messaging one of the following numbers or addresses:

Voice & SMS Messaging: +1-860-578-2022
Skype Voice: +990009369991478873
SIP Voice: sip:9991478873@sip.tropo.com
INum Voice: +883510001827349
Jabber/GoogleTalk: nodefuhello@tropo.im

Tropo is providing the voice and SMS connectivity and then communicating with my app running over on NodeFu.com.

Kudos to Chris on the launch of NodeFu and we’re definitely looking forward to seeing what you all build with Tropo and Node.js!


P.S. Note that the process under “Setting Up The Tropo Side” is NOT specific to NodeFu – it’s the same process you would use for any application hosted externally and using the Tropo WebAPI. It could be any of the other Node.js hosting providers, or it could be a hosting provider for any other language out there. The only difference is going to be the URL that you provide as part of the application creation process.