Archive for February, 2011

No More Coworking Lockouts with Tropo and CouchDB

Monday, February 28th, 2011

Has this ever happened to you?

You’re feeling a bit randy so you decide to head over to your local coworking facility or hacker dojo to get some work done. Although it’s a bit of an odd hour, the caffeine is pumping in your veins and you’re raring to code up the next big thing. CloudKnock in action Unfortunately, when you get to your coworking site your realize that the door is locked, and you don’t know who is inside to call or send a message to so they may come and let you in. Bummer!

I’ve create a simple Tropo Scripting application that uses CouchDB that can prevent this from ever happening to you or your coworkers. It’s called CloudKnock. You can get the source code for this application over on GitHub.

The screencast below demonstrates how you can use CloudKnock to get into your coworking site quickly and easily.

Some of the really nice features of CloudKnock:

  • There is no special hardware required to unlock the door at your facility.
  • You don’t need to advertise that you are at your local hacker dojo (and not at home) on a social networking site.
  • Coworking members get notified on the channel they choose to utilize, which makes them more likely to get your message and come let you in. ;-)

I’d love to hear feedback on this application from anyone who ha a chance to test it out.

Happy coworking!

How to Build a Reminder Service Using Tropo and Ruby on Rails

Sunday, February 27th, 2011

Have you ever thought about starting a Reminder Service company and getting millions of dollars in funding all from a weekend project?  Tropo is here to help you with your communications needs in this endeavor!

The Reminder Service source code that I am about to share with you was started on the Nerd Bird (good to have in-flight WiFi) from Orlando to Phoenix, on my way back from the HIMSS conference.  It’s written in Ruby on Rails 3.0.4 and the Tropo Scripting API.

This is Tropo application is designed to demonstrate building a Reminder Service application using both Voice and SMS alerts.  The application will place an outbound reminder call to you 1 week in advance and then 1 day in advance and an SMS message 1 hour in advance of your appointment time.

You can demo the Reminder Service running on Heroku now.  It’s a basic Ruby on Rails scaffolding interface with the ability to create, update, and delete reminders.  All reminders are tracked in UTC time to simplify the demo and there is no authentication because IT’S A DEMO.

The source code is on GitHub.  Simply clone this application from GitHub and run the following statements from your command line:

bundle install
rake db:create
rake db:migrate

Setup an account at Tropo and create a new Scripting API application.  Copy and paste the source code from tropo_scripting_api.rb into separate scripts running under the same application. One for placing outbound voice call reminders and one for sending SMS message reminders.

Here is the source code to place the phone call on Tropo.

message($remindermessage, {
  :to => $phonenumber,
  :channel => "VOICE"
})

Here is the source code to send an SMS message on Tropo.

message($remindermessage, {
  :to => $phonenumber,
  :network => "SMS"
})

Add a phone number to your Tropo application.  SMS messages will not work without one.

The rest of the magic happens in the API controller as shown below:

class ApiController < ApplicationController
  def check
    require 'time'

    @reminders = Reminder.where("(appointment > ?) and (appointment < ?) and ( flag1 IS NULL or flag2 IS NULL or flag3 IS NULL)", Time.now.utc, Time.now.utc+1.week )

    @reminders.each do |reminder|

      if reminder.appointment-1.hour < Time.now.utc && reminder.flag3.nil?

        # Send SMS
        RestClient.get 'https://api.tropo.com/1.0/sessions', {:params => {
          :action => 'create',
          :token => '848b6b17c6229844827847b381...58eaa12683b6ea0a8aa5e166ee7bfcc8',
          :phonenumber => formatphone(reminder.phonenumber),
          :remindermessage => 'dont forget ' + reminder.message.to_s + ' at ' + reminder.appointment.to_s}}

        # Write Flag3
        @reminder = Reminder.find(reminder.id)
        @reminder.flag3 = true
        @reminder.save

      elsif reminder.appointment-1.day < Time.now.utc  && reminder.flag2.nil?

        # Place outbound reminder call
        RestClient.get 'https://api.tropo.com/1.0/sessions', {:params => {
          :action => 'create',
          :token => '3d5eed33429706408efcc0e92307b...d04af908e583112195de9ec7b05b9e',
          :phonenumber => formatphone(reminder.phonenumber),
          :remindermessage => 'dont forget ' + reminder.message.to_s + ' at ' + reminder.appointment.to_s}}

        # Write Flag2
        @reminder = Reminder.find(reminder.id)
        @reminder.flag2 = true
        @reminder.save

      elsif reminder.appointment-1.week < Time.now.utc && reminder.flag1.nil?

        # Place outbound reminder call
        RestClient.get 'https://api.tropo.com/1.0/sessions', {:params => {
          :action => 'create',
          :token => '3d5eed33429706408efcc0e92307b04...908e583112195de9ec7b05b9e',
          :phonenumber => formatphone(reminder.phonenumber),
          :remindermessage => 'dont forget ' + reminder.message.to_s + ' at ' + reminder.appointment.to_s}}

        # Write Flag1
        @reminder = Reminder.find(reminder.id)
        @reminder.flag1 = true
        @reminder.save
      end
    end

    if @reminders
      render :text => "sent " + @reminders.length.to_s + " reminders"
    else
      render :text => "no reminders"
    end
  end

  def formatphone(phone)
    @phone = phone.gsub("(", "").gsub(")", "").gsub("-", "").gsub(".", "").gsub(" ", "")
    if @phone[0..0] != '1'
      @phone = '1' + @phone
    end
    return @phone
  end
end

Now for the drum roll! Setup a cron job to call http://localhost:3000/api/check every 5 minutes, run rails server, and open your web browser to http://localhost:3000!  Oh, one last thing…Go ask one of those “super angels” for some cash-money :)

New Tropo Scripting API Tutorial – The Chance Facilitator

Saturday, February 26th, 2011

Since random number generation is a common “first app” for people learning a new language, we decided to add a new tutorial showing an application that utilizes the math functions of each of the five supported languages (JavaScript, Ruby, PHP, Python & Groovy) to create the Chance Facilitator in Tropo.

It allows you to roll a six sided die, twenty sided die, flip a coin or throw rocks, paper, scissors. It works over voice and SMS, asks a question, allows for multiple bad choices, utilizes grammars and call properties – all around a solid example to get you started on several of the primary capabilities of Tropo. Each of the following code samples can be dropped into a Scripting hosted file and work without any modification – check out the tutorial or grab the code from any the following links:

Just for the record, all five of the samples were created by someone with well under a year coding experience using nothing but the Tropo docs and Google. Tropo really is that easy :)

Questions, comments? Drop us a line via support@tropo.com or open a thread in our public forums.

Civic Hacking in Philadelphia

Saturday, February 26th, 2011

Yesterday in Philadelphia, Tropo had the pleasure of taking part in the Data Camp event sponsored by Code for America.

This event was focused on identifying useful data sources for Philadelphia and building civic applications to use that data – in one day! It was a great event, and several really cool projects were taken on by attendees.

Philadelphia Library Locator

I worked with a group to build out a CouchDB-based API for geographic data. Essentially, a Philly version of Max Ogden’s PDX API project, which I talk about more fully in this post.

In one day, our team was able to stand up Philly API and build a demo app that lets users find library locations near their homes or places of business using SMS or IM.

I wanted to demonstrate the power of Tropo for building powerful, multi-channel communication apps quickly and easily. A screen shot demonstrating how the app works can be seen in this post.

Just send an SMS or IM message to the app with an address, and get back the library locations closest to that address. This is a highly effective way to help people who might face some challenges in accessing technology get to a location in their neighborhood where they can have access to the Internet and online government services.

The code for the app is available on GitHub.

This civic hacking event was so much fun that we’re planning another event in Philadelphia in the near future. This upcoming event is going to be awesome, and details will be announced in the coming week.

Stay tuned!

South Beach Startup Drinkup Tonight!

Friday, February 25th, 2011

Join Voxeo Labs and Tropo for some free tasty beverages at the First South Beach Startup Drinkup on Friday February 25, 2011 from 8pm to 11pm at:

Kill Your Idols 222 Espanola Way Miami Beach, FL 33139

Check it out: South Beach Startup Drinkup on Plancast for more details.

Bonus points for playing songs from Johnny Diggz’ album in the jukebox. :-)

New Java based WebApi implementation

Thursday, February 24th, 2011

I’m happy to announce that Tropo finally has a Java based WebAPI implementation.

This implementation will allow every Java developer to create Tropo based applications with a very simple and lightweight API. This API hides all the communication and protocol details, making it much easier to deploy Tropo applications in a Java environment. It can be used with any Java program, including Application Servers like Tomcat, WebSphere or WebLogic as well as stand-alone applications.

As the other WebAPI implementations do, the Java WebAPI library offers a very simple but comprehensive DSL that can be used to create Tropo applications with syntax very close to natural language. However, in contrast to other implementations, the Java WebAPI is statically typed, which means we can catch errors at compile time. This makes it even easier for developers to create Tropo applications. Previous to this implementation, developers who wanted to use Tropo with Java had to create JSON documents by hand, inherently unfriendly and error-prone.

The sources of the Java WebAPI implementation are available from GitHub as usual, including documentation to help get you started. You can download the latest version of this library from the distribution folder, where you will also find all the required dependencies (of which there are not many). Building the Java WebAPI requires Apache Maven and is just a one line: mvn clean install.

There are plenty of examples on the project’s page at GitHub; I’ll share a couple of them now so you can see how easy it is to create Tropo applications in Java. Let’s start with a simple Java Servlet that will be the entry point to our Tropo application. Tropo sends a POST request to our application server each time a person calls a number, sends an SMS to our app, etc. – we just have to implement the doPost method from our Servlet.

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response) 
                         throws ServletException, IOException {

    Tropo tropo = new Tropo();
    tropo.say("Hello from Tropo. This is our first application.");
    tropo.render(response);
}

How cool is that? No JSON, no response handling, just plain and easy Java code! Let’s look at another example – imagine you have a Tropo hosted application, which sends SMS to a number; this number is passed to Tropo as a parameter. You have a Java standalone application that you want to hook into this hosted app, in order to send an SMS based on a particular criteria (like when a file download is finished). You can simply use this Java implementation to launch your hosted application using the application’s token and pass the phone number at the same time. It would be as simple as this:

public void sendSMS(String number) {

    String token = ...
    Tropo tropo = new Tropo();
    Map params = new HashMap();
    params.put("number", number);
    tropo.launchSession(token, params);
}

Finally, the Java WebAPI also offers classes to deal with all results and incoming information from Tropo. For example, checking Tropo’s session object is very easy:

protected void doGet(HttpServletRequest request,
                     HttpServletResponse response) 
                        throws ServletException, IOException {

	Tropo tropo = new Tropo();
	TropoSession session = tropo.session(request);
	System.out.println("Call id: " + session.getCallId());
}

As you can see, writing Tropo applications in Java has never been that easy. We hope you like this new WebAPI implementation!

Send a Fax with your Voice!

Monday, February 21st, 2011

Tropo just recently partnered with PamFax to deliver faxing capabilities via an API.  Jason Goecke wrapped their API with a very simple Ruby gem called pamfaxr available at GitHub and installable using a “gem install pamfaxr” from your command line.  Using the PamFaxr Ruby gem, I will demonstrate how to send a simple fax as well as how to build a Tropo Voice to Fax transcription application using our Scripting API!

Getting Started

Before you can start sending faxes, you need to head over to the PamFax site and sign up for a PamFax account. After you fill out and submit the form, you’ll get an email with your login credentials and how to get started.

You also need to install the Ruby gem called pamfaxr on to the system where you are going to run the application that will send the fax. The Ruby gem is available at GitHub and should install simply by typing “gem install pamfaxr” from your command line. You will need to edit the code to have your PamFax username and password.

Sending A Fax From The Command Line

Before we involve Tropo, here is the Ruby/Sinatra code for simply sending a fax from the command line using the PamFaxr gem:

require 'rubygems'
require 'pamfaxr'

# Pass user name and password
pamfaxr = PamFaxr.new :username => 'your_username',
                      :password => 'secret'

# Create a new FaxJob
faxjob = pamfaxr.create_fax_job

# Add the cover sheet
covers = pamfaxr.list_available_covers
pamfaxr.set_cover(covers['Covers']['content'][1]['id'], 'Chris was here 2!')

# Add files
# pamfaxr.add_remote_file('https://s3.amazonaws.com/pamfax-test/R-intro.pdf')
# pamfaxr.add_file('examples/R-intro.pdf')

# Add a recipient
pamfaxr.add_recipient('+14802191300')

# Loop until the fax is ready to send
loop do
  fax_state = pamfaxr.get_state
  break if fax_state['FaxContainer']['state'] == 'ready_to_send'
  sleep 5
end

# Send the fax
pamfaxr.send_fax

Just copy that code into a text file, edit it to have your information in it and then run it with ruby from your command line. In a short bit you should have a fax waiting for you.

Sending Faxes From Tropo

Now for the fun Tropo Voice to Fax application code! The first code snippet is written in Ruby runs on the Tropo cloud. It greets the caller, asks for your fax number, records your voice/fax message and sends the transcription via a callback to the Ruby/Sinatra application that sends the actual fax.  Here’s the Tropo code:

say "Welcome to the Tropo fax demo.", :voice => 'dave'

result = ask "What's your fax number? Please include your country code.", {
   :choices => "[11 DIGITS]", :voice => 'dave'}

record "Please say what you would like for me to fax.", {
    :beep => false,
    :voice => 'dave',
    :maxTIme => 60,
    :silenceTimeout  => 2,
    :transcriptionOutURI => "http://web1.tunnlr.com:11053/transcribe?fax=" + result.value
    }

say "Your voice is being converted to a facsimily!  Go check your fax machine!  Goodbye.", :voice => 'dave'

hangup

Here is the complimentary Ruby/Sinatra code that catches the Tropo transcription callback and sends the fax of the transcription to the number specified in the Tropo script using the PamFaxr gem as demonstrated above. This code needs to be run on a publicly-accessible web server to which Tropo can connect and send the data. You have several options including:

  • Running the code on your own publicly-available webserver
  • Running the code on a hosting service like Heroku
  • Running the code on your local machine and use a service like Tunnlr to make the service available

Once you have the Ruby/Sinatra code below running in one of those locations, you’ll just update the Tropo code above with the correct URL (on line 11).

The code is here:

require "rubygems"
require "sinatra"
require 'json'
require 'pamfaxr'

pamfaxr = PamFaxr.new :username => 'your_username',
                      :password => 'secret'

post "/transcribe" do

  transcript_json = JSON.parse(request.body.read)
  identifier = transcript_json['result']['identifier']
  transcript = transcript_json['result']['transcription']

  # Create a new FaxJob
  faxjob = pamfaxr.create_fax_job

  # Add the cover sheet
  covers = pamfaxr.list_available_covers
  pamfaxr.set_cover(covers['Covers']['content'][1]['id'], transcript)

  # Add a recipient
  pamfaxr.add_recipient('+' + params[:fax])

  # Loop until the fax is ready to send
  loop do
    fax_state = pamfaxr.get_state
    break if fax_state['FaxContainer']['state'] == 'ready_to_send'
    sleep 5
  end

  # Send the fax
  pamfaxr.send_fax

end

Wow, that was fun!  I hope that you enjoyed this demonstration and I hope that you find both our PamFaxr gem and our Tropo Scripting API useful and powerful.

Hacking Fun with Tropo and Phono at #SHDH42

Monday, February 21st, 2011

Diggz and SocialVirgil hit up SuperHappyDevHouse 42 this weekend in San Jose at the tech museum, joining over 300 hackers from all over the bay area. Virgil shot & edited this montage video with some highlights of the day’s fun:

How to Build a VoIP-Based Baby Monitor

Thursday, February 17th, 2011

Two members of the Phono/Tropo team, and soon a third member, have recently added new babies to their families. Congratulations Mark, Justin, and John!

All of this excitement got the hacker in me thinking…  What would a modern Baby Monitor look like today?  Armed with the Phono and Tropo APIs, I started hacking and 2 hours later had the following example application to share with you!  Here’s the link to the demo.  Let us know what you think! http://phonophone.heroku.com/babymonitor.html

Phono, the jQuery WebPhone from the Tropo team, runs in the web browser to monitor activity in the room where it is running.  Tropo is used to manage the baby monitor’s conference room (based on the access code) and the dial-in numbers to listen to the baby monitor via PSTN, Skype, SIP, or iNum.  The Phono side of the conference is unmuted so you can hear activity while the Tropo side of the conference is muted.  You can have many people (Mom, Dad, Grandparents, etc.) dialed in listening to the same baby monitor using any combination of the access channels listed above.

Check out the Phono Blog to learn more about this demo and see the source code!

Tweetchat Mobile Lookup Powered by Tropo

Tuesday, February 15th, 2011

Twitter chats – also known as “tweetchats” – are meetings on Twitter. They are usually moderated by an individual or group and meet at a set time each week or each month. They can be on any topic, and they are sometimes associated with businesses or non-profits. Tweetchats have been described as a way to “filter out the chaotic mass of tweets” to focus on a specific topic.

Tweetchats are very popular, but many Twitter users don’t know what they are or how to participate in them. In simplest terms, tweet chats are online conversations, typically held at a pre-arranged time, between a group of Twitter users, and using a specific Twitter hashtag to identify the discussion.

Eric Bryant, Director at Gnosis Arts Multimedia Communications LLC, recently reached out to me on Twitter to share with me a link consisting of existing Tweet Chat time schedules for people to get started and participate in these chats online.  If you participate in Tweetchats, then you know how hard it is to remember the dates – especially seeing as how they’re growing so fast and there are so many of them in existence already.  Anyone can edit the Wiki, all you need to do is create an account.

So here is where Tropo comes in!  Eric and his team created a Tweetchat Mobile Lookup application.

Text a hashtag or a day to 1.513.655.2216 and it will send you the day/time of the tweetchat. Your mobile number is encrypted and never seen or stored.

Now you will never worry about missing a Tweetchat again :)