Posts Tagged ‘instant messaging’

Asterisk & Tropo and a Single Adhearsion Dialplan

Friday, October 8th, 2010

A key goal of Tropo AGItate is to allow you to use Tropo seamlessly with an existing Asterisk server. With AGItate you may add any Tropo feature to your existing Asterisk server without installing additional Asterisk modules and using the AGI protocol you already know. These features include:

  • Speech Synthesis/TTS in 7 languages and 2 dialects
  • Speech Recognition/ASR in 7 languages and 2 dialects
  • Transcription of audio messages, like voicemail
  • Multi-channel support for SMS, Instant Messaging and Twitter
  • Conferencing
  • and more

The ease of interoperability between Asterisk and the Tropo cloud highlights exactly why we run and make available an open SIP network. Every application created gets a SIP address automatically:

To show this in action I have chosen Adhearsion as the framework to serve diaplans for both Asterisk and Tropo to process a single caller on an Asterisk server. Here is a quick overview of how it works:

Through the use of SIP, SIP headers and call tagging in Adhearsion, you may write a single dialplan that handles the call and interaction between the Asterisk and Tropo cloud seamlessly. Here is a quick walkthrough of the dialplan itself and the dialplan taking calls in action:

The entire dialplan may be seen here:

# Serves up FastAGI to your Asterisk server
asterisk_agi {
  # Add a custom SIP Header to the session so that when we send to
  # Tropo we may know which Asterisk call the Tropo call is
  # servicing
  execute 'SIPAddHeader', "x-ahn-id: #{channel}"

  # Send the call to your Tropo AGItate app on Tropo
  # option 'g' is required in order for the call to come back
  # to the dialplan
  dial 'SIP/9991479110@sip.tropo.com', { :options => 'g' }

  # After the call comes back find this call and then
  # grab the tag of the result we are looking for
  this_call = Adhearsion.active_calls.find(channel)
  favorite_muppet = ''
  this_call.tags.each do |tag|
    hash = JSON.parse tag
    favorite_muppet = hash['favorite_muppet'] if hash['favorite_muppet']
  end

  # Play back the appropriate audio file based on the user's input by passing the appropriate value
  # in a custom SIP header
  case favorite_muppet
  when 'kermit'
    # Tropo supports wav/mp3 playback, so pass it a link
    execute 'SIPAddHeader', "x-ahn-mp3file: http://downloads.members.tripod.com/Tiny_Dancer/beingreen.mp3"
  when 'swedish chef'
    execute 'SIPAddHeader', "x-ahn-mp3file: http://dl.dropbox.com/u/25511/Voxeo/TTS-Example/SwedishChef.mp3"
  else
    execute 'SIPAddHeader', "x-ahn-choice: bad"
  end
  dial 'SIP/9991479110@sip.tropo.com', { :options => 'm(silence)' }
}

# Serves up FastAGI to your Tropo AGItate application
tropo_agi {
  # Grab the SIP headers from the Tropo cloud delivered in the first message over AGI and made
  # available in Adhearsion as 'tropo_headers'
  headers = JSON.parse tropo_headers

  if headers['x-ahn-mp3file']
    # If we have the mp3file header, then lets play the fileback, otherwise ask for the input
    play headers['x-ahn-mp3file']
  elsif headers['x-ahn-choice']
    # If the bad choice header is here, we know they did not choose a Muppet they should have
    play 'You silly muppet fan, the best muppets are kermit or the swedish chef. Try again another time. Goodbye.'
  else
    # Invoke the Tropo Speech Synthesis/TTS to speak to the caller
    # https://www.tropo.com/docs/scripting/say.htm
    play 'Welcome to the Muppetorium.'
    # Invoke the Tropo Speech Recognition/ASR to ask the caller for input
    # https://www.tropo.com/docs/scripting/ask.htm
    result = execute 'ask', { :prompt   => 'Which is your favorite muppets character?',
                              :choices  => 'kermit, fozzie, statler, waldorf, oscar, bert, ernie, swedish chef',
                              :attempts => 3,
                              :timeout  => 10 }.to_json

    # Parse the result from Tropo into a Ruby hash
    result = JSON.parse result.split('200 result=')[1]

    # Find the active Adhearsion call object based on the SIP header passed into Tropo
    call = Adhearsion.active_calls.find headers['x-ahn-id']

    # Tag that call object with the value of the speech recognition, hangup the call between Asterisk and Tropo
    # so that Asterisk may continue handling it on its own
    call.tag({ :favorite_muppet => result['interpretation'] }.to_json)
  end
}

Or downloaded here. Thats it! You now have a fully featured Asterisk instance leveraging the best of what the cloud has to offer without adding or purchasing any additional software for your Asterisk box.

To get started with AGItate we created a howto walkthrough that you may see here. Tropo is free for development use, so there is no reason not to give it a try. Enjoy!

Heroku and Tropo Like Peanut Butter and Chocolate!

Tuesday, September 28th, 2010

Peanut butter and chocolate!

Who doesn’t love peanut butter and chocolate? By themselves, they are equally delicious but together, they are irresistible!

The same can now be said about Heroku and Tropo.  Heroku is the super simple cloud hosting platform for Ruby and Ruby on Rails web applications.  While Tropo is the super simple cloud hosting platform for communications applications including Voice, SMS, IM, and Twitter.

While Tropo works with any web programming language, we have been seeing more and more Ruby applications being developed using Tropo’s WebAPI. Traditionally deploying an application took just about as much time as actually writing the application.  This is no longer true with Heroku’s cloud hosting platform.

Deploying a Ruby application to Heroku is as simple as issuing the following commands from your terminal window:

> heroku create

> git push heroku master

Equally as simple to deploying your application to Heroku is writing your multi-channel communications application using Tropo like this hello world application that can be accessed via the telephone using Voice or SMS or via Instant Message or Twitter:

answer

say “Yes, Tropo is this easy!”

hangup

Now on to the how-to video and Heroku deployment instructions located at http://tropo.heroku.com!

Heroku & TropoTo demonstrate this yummy combination of technologies (Heroku and Tropo), Mark Silverberg (student and talented freelance Tropo developer) built a powerful Voice and IM application using Ruby and the Sinatra Framework and walks us through his 3.5 minute start-to-finish deployment of this application on the Heroku platform!

Mark’s multi-channel application is a volunteer finder service that provides information on volunteer opportunities in your zipcode.  The application can be accessed by calling +99000936 9991456957 via Skype or by IMing volunteer1234@tropo.im.  Mark’s Ruby code can be found on GitHub along with deployment instructions hosted on Heroku at http://warm-spring-38.heroku.com/

Now follow along with this video at http://tropo.heroku.com to learn how to build and deploy your next billion dollar idea using Heroku and Tropo!  Leveraging Heroku and Tropo gives you the best of advancements in cloud technology available today.  Heroku’s cloud technology allows you to scale your web application while Tropo’s cloud technology allows you to scale your communications applications.  These hybrid cloud technologies provide you, the web developer, with peace of mind and assurance that when your new application goes viral, we can easily scale to meet your demand.  Best of all, both cloud platforms offer free entry points to kick our tires and try us out.

So what are you waiting for?  Taste our peanut butter and chocolate now at Heroku and Tropo!

IM usage stats: the decline of AIM

Tuesday, August 31st, 2010

Like many early IM users, I was a heavy user of AIM for a very long time. (I also had a 6 digit ICQ number, but the lack of friends on the network led to me abandoning it). The first IM platform I implemented on what eventually became the IM support in Tropo was AIM. AIM holds a special place in my heart.

Today’s Chart of the Day from Silicon Alley Insider (SAI) is Comscore’s metrics on the use of various IM networks. For the venerable AIM, it isn’t pretty. After years in the #1 spot, a sharp decline starting at the end of 2008 led SAI to title their graphic “The Death Of AOL Instant Messenger.”

Yahoo had a huge spike around the same time, but within 6 months declined back to around where they started. I’m not sure what caused the Yahoo spike, but a few things may have contributed. Yahoo 9.0 was released around that time, as was the Yahoo iPhone IM client.

Facebook and Google Talk aren’t represented on the chart. Comscore is unable to break the IM traffic out from Gmail and regular Facebook usage.

Create an Audio, SMS and Instant Message Resume with Tropo Scripting

Thursday, March 4th, 2010

Getting noticed in the job market today gives you an edge. One edge is to create an audio resume that you may give out to show your developer prowess. Using the Tropo multi-channel capabilities, you may then allow that resume to interact with your perspective employer via SMS or even Instant Message.

Whats more, using Tropo Scripting you may create this resume and host it on our servers with no need for your own server or sending mark-up back and forth. And, you may do this in Groovy, Javascript, PHP, Python, Ruby or all of them to show off your polyglot skills.

For this example resume we will use a Ruby script hosted on Tropo.com to make John Doe’s background available (also available on Github here):

answer
say "Welcome to John Doe's audio resume."

listening = true
while listening
  result = ask "Please press 1 to hear an overview of John's resume, please press 2 to listen to his most recent experience or press 3 to connect to John and hire him!", { 'attempts' => 3, 'choices' => '1, 2, 3', 'onBadChoice' => lambda { say 'Invalid entry, please try again.' } }

  case result.value
  when '1'
    say 'Adept at managing all aspects of information technology, including ongoing business needs assessment, software development and implementation.'
    sleep 2
  when '2'
    say 'John served as the IT Director at ABC Insurance. John is a direct manager of a team of 6 people charged with delivery of enterprise level projects.'
    sleep 2
  when '3'
    transfer 'tel:+14155551234'
  else
    say 'Thank you for your time, goodbye.'
    listening = false
  end
end

hangup

You may call and listen to John Doe’s on 1 (408) 940-5947. To get started writing your own you may register for a free Tropo developer account, with a free phone number, here.