Add framework for “magic” channel variables. This supports things like CALLERID(all) vs. CALLERID(name) vs. CALLERID(num) that all have overlap in Asterisk. We now try to do the right thing when setting or reading each variation. More special variables can be easily added.
Enhanced Dial compatibility: Allow setting the CallerID on outbound calls, set DIALSTATUS based on Tropo response and clean up parsing of dial string
Set the default AGI port if unspecified in the YAML
Update to RSpec 2
Allow detecting the Tropo dialed number for incoming calls (agi_dnid)
Fix fatal missing error on SIP failover failure
Update unit tests for new functionality; fix broken unit tests
Rspec tests now require JRuby v1.5.x or better
You may grab the latest script from Github here. As a refresher, AGItate is a script that emulates the Asterisk AGI protocol on Tropo. Allowing you to use frameworks like Adhearsion or Asterisk-Java with Tropo.
We are also cooking up some interesting developments for the Adhearsion community with Ben, so stay tuned!
The SAY DIGITS AGI command speaks the digits properly again.
If you are pulling directly from Github then you already have the update, if not go ahead and follow the instructions here to get the AGItate update up and running.
Here is a simple Adhearsion diaplan using Tropo AGItate that takes advantage of these languages:
require 'open-uri'
tropo_agi {
# A hash of all of the langauges we have on Tropo via Tropo AGItate
voices = { :es => { :lang => 'Spanish', :name => 'Carmen' },
:de => { :lang => 'German', :name => 'Katrin' },
:it => { :lang => 'Italian', :name => 'Paola' },
:nl => { :lang => 'Dutch', :name => 'Saskia' },
:fr => { :lang => 'French', :name => 'Florence' },
:pl => { :lang => 'Polish', :name => 'Zosia' } }
text = 'The color of the trees in the fall is always spectacular!'
# Google Translate URL
translate_uri = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{text}"
play text
voices.each do |voice|
# Do the translation of the text
url = URI.encode(translate_uri + "&langpair=en|#{voice[0].to_s}")
translation = JSON.parse(open(url).read)
# Switch back to our default voice to announce what we are about to play
execute "voice", "default"
play "Now in #{voice[1][:lang]}"
# Now play back the translated string, if we received one, in the appropriate language
if translation['responseData']['translatedText']
execute "voice", voice[1][:name]
play translation['responseData']['translatedText']
end
end
execute "voice", "default"
play 'Thanks for listening! Goodbye.'
hangup
}
In this case we are using the Google Translate API to perform the translation of our text to play back in each language supported. Watch this script in action:
For this example we will show an Italian catering company calling out to their appointments to ask them which shape of pasta they would like to have at their party. I have written an Adhearsion component that selects customers to call from the database. The component then launches an outbound request to Tropo, which in turn is handled by the Adhearsion dialplan via Tropo AGItate. Watch it in action:
The code for the component may be found on Github as couchdb-dialer. Enjoy!
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:
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!
Last Friday we announced Tropo AGItate on the Voipusers Conference. As you may recall, AGItate is a Tropo script that turns Tropo into an Asterisk platform in the cloud. This script allows you to run any FastAGI framework controlling Tropo as if it were an Asterisk server.
We have put together a short screencast that walks you through the simple installation of the script. And then show you the script in action with Adhearsion. Have a watch:
The Asterisk community is a vibrant one, one that we actively support through our sponsorship and advocacy of Adhearsion. We have decided to take it a step further and created a Tropo Scripting application that turns Tropo into a giant Asterisk application platform in the cloud. You can now run just about any Asterisk AGI application on Tropo.
Tropo AGItate was started on the Nerd Bird (good to have in-flight WiFi) from San Jose to Austin, on my way to LoneStar Ruby Conference. Jim Freeze – the organizer of LSRC – had recently been to AdhearsionConf in San Francisco; I wanted to be able to show something extra special during my talk there. On that one flight, I was able to get the basics working and show Tropo emitting AGI during my talk, just like that. (For those non-Asterisk folks out there, AGI is an API that lets external applications connect in to Asterisk and fully control it).
Since then, it’s been fun working on the application and expanding its capabilities. With Tropo AGItate, you could build your own interactive art display, a full blown cloud PBX like OpenVoice, or add Tropo capabilities to your own Asterisk server. The key features coming out today are:
A long list of Asterisk commands are supported, and of course all the Tropo ones.
While the script is written in Ruby, no Ruby knowledge is necessary to use it. Just point your Tropo application to the Ruby script on Github, upload a configuration file via FTP or WebDAV to your Tropo account, and you are ready.
Fail over to a SIP URI, in case your FastAGI server does not respond. This could be to another Tropo application, another Asterisk box, or anything that supports SIP.
You get all of the Tropo channels over AGI, including SMS, Instant Messaging and Twitter, all using the same application.
Support for custom SIP Headers in and out of Tropo.
And much more, with more to come…
Not only can you use AGI to write an entire cloud communications application, but you can also seamlessly integrate Tropo services into existing Asterisk systems using the interface you already know and love; after-all, its all SIP to us.
If you want to hear a Tropo AGItate ‘hello world’, give it a ring:
Phone/SMS: (408) 641-4410
Skype: +990009369991456829
SIP: sip:9991456829@sip.tropo.com
Jabber/XMPP: tropo_agitate@tropo.im
While this is great for all of the Asterisk developers out there, it also gave us the opportunity to showcase the power of the Tropo Scripting API. Tropo AGItate is 100% Tropo Scripting, no special libraries, no tricks, its all right there in the script. Tropo Scripting allows you to bend the Tropo cloud to your will; this is what we believe is truly innovative about our platform.
Stay tuned for more! We will be providing howtos, screencasts and more features soon.