Tropo is excited to partner with Apigee on the Tropo API Explorer! The API Explorer allows more developers to explore, learn, and test Tropo’s cloud communications APIs faster than ever before.
Tropo provides an API and cloud communications platform for building powerful Voice applications with speech recognition and text-to-speech in 24 languages, call recording, conferencing, SIP/VoIP, and phone numbers in 41 countries. Tropo also provides international SMS services.
The API Explorer makes this integration easier, helping developers authenticate and test our API in seconds, view the full surface area of an API, view request/response pairs in only a few clicks and share what they are seeing with others.
Now you can use the Apigee API explorer to experiment with our REST API without writing a single line of code! It is built with Apigee To-Go, a free product to let users build, skin and embed their own API Console. The Tropo API Explorer is embedded below or you can jump to this full screen version.
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:
In Ushahidi, create a user with “Admin” privileges.
check out the code from Github
edit the configuration lines at the top with your Ushahidi credentials and URL
create a new Scripting API Application on Tropo.com.
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:
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.
This commercial was released in 1971 but touchtone (DTMF) was originally invented in 1941. That was 70 years ago! If your voice application is still using touchtone for user input, don’t you think it’s time to enter the 21st century?
Tropo offers speech recognition in 24 languages by default on every prompt allowing callers to use either touchtone or their voice to answer prompts during the call. We support four forms of speech recognition grammars include:
Using Tropo’s simple grammars are incredibly, well, simple. Here is what an auto-attendant’s dial directory prompt would look like using Tropo’s simple speech recognition grammar.
ask "Welcome to the Tropo company directory. Who are you trying to reach?", {
:choices => "department(support, engineering, sales), person(chris, jason, adam)",
:onChoice => lambda { |event|
say("You said " + event.choice.interpretation + ", which is a " + event.value)
}
}
From here you could also transfer the call to the department or person’s phone number or SIP address by substituting the onChoice say prompt with the following logic:
say "Please wait while we transfer your call. Press star to cancel the transfer."
transfer ["+14075550100","sip:12345678912@221.122.54.86"], {
:playvalue => "http://www.phono.com/audio/holdmusic.mp3",
:terminator => "*",
:onTimeout => lambda { |event|
say "Sorry, but nobody answered"}
}
The possibilities of developing new voice apps using speech recognition are endless! For one, your customers will have a better user experience (UX) by not having to press buttons on the phone. Secondly, apps such as language translater applications and personal assistant applications are now possible.
We want to be your speech recognition and cloud communications partner.
Have you ever wanted to set a timer on a conference call and pop-in at a certain time to either:
1) announce something, say, every 15 minutes;
2) let participants know that they have 2 minutes remaining; or
3) ask them a question or survey?
This is easy to do by connecting Tropo applications! I created a quick demo using the Tropo Scripting API that allows people to call into a Tropo phone number, SIP address, or Skype address and after x seconds announce that they have two minutes remaining. The demo code below is written in Ruby and it uses threading to start a timer and wait/sleep until x seconds has transpired. Once the timer expires, it calls and conferences a second Tropo application via its SIP address and simply announces the warning message. You could easily extend the second Tropo application to prompt the user to answer a single question or a take a poll/survey and report their answers back to the main application either via a database or via SIP headers on the transfer back to the application.
Here’s the Ruby source code on the main application:
#Method to create timeStamp as our conferenceID
def get_conference_id()
timeVar = Time.new
returnValue = timeVar.strftime("%Y%H%M%S")
return returnValue
end
conferenceOptions={
:mute=>false,
:playTones=>true,
:leaveprompt=>"beep"
}
begin
#Create conference ID
conferenceID = get_conference_id()
log "@"*5 + "User has answered"
#Create second thread for second for timer and announcements
Thread.new do
log "@"*5 + "Start second tread"
sleep 10
call 'sip:9996137086@sip.tropo.com', {
:onAnswer=>lambda{|event|
log "@"*5+"answered join conference"
newCall = event.value
newCall.conference(conferenceID,conferenceOptions)
}
}
end #thread
say 'You are now in conference.'
conference(conferenceID,conferenceOptions)
end
Here’s the Ruby source code of the announcement application:
say "you have two minutes remaining."
Note the SIP address used in the main application. It’s the SIP address assigned to your second announcement application by Tropo when it’s created. Every Tropo application automatically gets a SIP address, iNum address, Skype address, and Phono address assigned to it upon creation. You can transfer and conference calls app-to-app using SIP addresses and even pass data between them using SIP headers. How’s that for webscale?!
We are always excited to see developers using Tropo to extend GoogleVoice functionality and features by adding things like SIP and Call Forwarding and Call-In enhancements. Terry Swanson (@FunnyBoy243) is one of these cool developers who wrote 2 of these extensions and opensourced them for others to share and contribute:
His Call Forwarding Extender Tropo Script includes the following features that extend/add to the current Google Voice feature-set:
Easy forwarding to SIP Numbers (especially compared to IPKall)
Outbound call recoding
Allows forwarding to numbers that cannot be verified through Google Voice (such as numbers with extensions). You can append “postd=DIGITSp” and/or “pause=WAITTIMEms” in the CALL_DEST variable to allow the script to forward to your extension. For example, “+14155551212;postd=ppppp1234pp56″ would dial (415) 555-1212 wait 5 seconds (1 second for each p) dial 1 2 3 4, wait 2 seconds then dial 5 6. Look enter the Parameters section of the Tropo API for more information.
You can have this script call multiple SIP/Telephone numbers at the same time by using an array for the CALL_DEST variable. All numbers will ring and the first to answer the call will take the call.
For step by step instructions, check out Terry’s original post here.
His Google Voice Call In Extender Tropo Script includes the following features that extend/add to the current Google Voice feature-set:
SIP Address for your Google Voice number.
Skype number for your Google Voice number.
Phone Number Aliases for your Google Voice number – You can have multiple phone numbers from different areas forward to the same Google Voice number so they wont have to pay long distance fees to call your Google Voice number.
Here are some additional tips and tricks with this extension:
You can have this script call multiple Google Voice numbers at the same time by using an array for the GV_NUM variable. All numbers will ring and the first to answer the call will take the call. Example: $GV_NUM = array(“5103364032″, “5103364002″);
You can add International Phone numbers to allow people from other countries to call your Google Voice number without paying International rates.
You can use the Skype number to make free telephone calls using Google Voice.
For step by step instructions, check out Terry’s original post here.
Ham radio or amateur radio communications has been around since the early 1900s. Ham radio technology has kept pace with traditional communications and may even be the only technology that allows people to communicate in natural disasters. Ham radio operators can communicate over very far distances using HF (high frequencies) as well as through satellites via AMSAT and even using VoIP over the Internet using EchoLink, IRLP, or D-STAR!
There are nearly 750,000 FCC licensed ham radio operators in the United States and over 3M licensed operators worldwide. Each operator has federally issued callsign that is used to uniquely identify the station operating on the band.
Using Tropo and Callook (Josh Dick’s W1JDD Callsign API), Chris Matthieu (N7ICE) was able quickly develop a speech recognition and text-to-speech based telephony app that is accessible by any of the following channels:
Upon calling the application, you are asked to spell a callsign using military phonetics:
A – Alfa, B – Bravo, C – Charlie, D – Delta, E – Echo, F – Foxtrot, G – Golf, H – Hotel, I – India, J – Juliet, K – Kilo, L – Lima, M – Mike, N – November, O – Oscar, P – Papa, Q – Quebec, R – Romeo, S – Sierra, T – Tango, U – Uniform, V – Victor, W – Whiskey, X – X-Ray, Y – Yankee, Z – Zulu
In addition to these commands, you can say restart to start over or stop if your callsign is entered correctly. Upon saying stop, the Tropo application does a REST-based call to Callook to get a JSON response of the data related to the callsign inquired. In addition to the communication channels listed above, Chris Matthieu was able to use his handheld hamradio (like the one featured above) to communicate using VHF (very high frequencies) to connect to a repeater nearly 50 miles away on a mountaintop and connect to Tropo via an auto-patch phone line to perform a callsign lookup. Here is a screencast and source code for the application!
Here is the source code running on Tropo’s Scripting API:
require 'rest_client'
require 'json'
answer
sleep 2
say "welcome to the tropo ham radio call sign lookup application"
callsign = ""
callsigntext = ""
loop do
result = ask "spell the callsign phonetically. say stop when done or restart to start over", {
:choices => "alpha, bravo, charlie, delta, echo, foxtrot, golf, hotel, india, juliette, kilo, lima, mike, november, oscar, papa, quebec, romeo, sierra, tango, uniform, victor, whiskey, xray, yankee, zulu, one, two, three, four, five, six, seven, eight, nine, zero, stop, restart"}
if result.value == "stop"
break
elsif result.value == "restart"
callsign = ""
callsigntext = ""
else
callsigntext = callsigntext + " " + result.value
say "so far you entered #{callsigntext}"
letter = case result.value
when "alpha" then "a"
when "bravo" then "b"
when "charlie" then "c"
when "delta" then "d"
when "echo" then "e"
when "foxtrot" then "f"
when "golf" then "g"
when "hotel" then "h"
when "india" then "i"
when "juliette" then "j"
when "kilo" then "k"
when "lima" then "l"
when "mike" then "m"
when "november" then "n"
when "oscar" then "o"
when "papa" then "p"
when "quebec" then "q"
when "romeo" then "r"
when "sierra" then "s"
when "tango" then "t"
when "uniform" then "u"
when "victor" then "v"
when "whiskey" then "w"
when "xray" then "x"
when "yankee" then "y"
when "zulu" then "z"
when "one" then "1"
when "two" then "2"
when "three" then "3"
when "four" then "4"
when "five" then "5"
when "six" then "6"
when "seven" then "7"
when "eight" then "8"
when "nine" then "9"
when "zero" then "0"
end
if letter
callsign = callsign + letter
end
end
end
response = RestClient.get 'http://callook.info/' + callsign + '/json'
data = JSON.parse(response)
say callsigntext + "belongs to "
say data["name"]
say "in " + data["address"]["line2"]
say "and holds a " + data["current"]["operClass"] + " license"
Tropo makes it super simple to create a conference call application.
In just a few lines of code, you can have a functional conference call application that you can use with Skype, SIP or a PSTN number.
Creating an app is as simple as this:
// Welcome the caller to the conference.
say("Welcome to the conference line. Press the star key to exit.");
// Start the conference.
conference("1337", {
terminator: "*",
playTones: true
});
// Play a message when the caller leaves the conference.
say("Thanks for calling the conference line. Goodbye.");
A conference call application – in JavaScript! How easy is that?
But it gets even better!
Tropo also makes it super simple to record a conference call if your use case requires it. With just a few extra lines of code (and a small bit of server side logic) you can record conference calls.
Again, in JavaScript:
// Start recording the conference call.
startCallRecording("http://url-for-your-server/record.php", { format: "audio/mp3" });
// Welcome the caller to the conference.
say("Welcome to the conference line. Press the star key to exit.");
// Start the conference.
conference("1337", {
terminator : "*",
playTones : true
});
// Play a message when the caller leaves the conference.
say("Thanks for calling the conference line. Goodbye.");
// Stop call recording.
stopCallRecording();
Using the Tropo startCallRecording() method, you can designate where your recorded audio file is sent and the format of the audio file. Saving the audio files on the server side can be done with a trivial amount of code.
For example, in PHP:
<?php
// Audio files saved to a parallel directory called 'recordings'
$target_path = 'recordings/' . $_FILES['filename']['name'];
move_uploaded_file($_FILES['filename']['tmp_name'], $target_path);
?>
With Tropo, it’s never been easier or more efficient to create powerful conference call applications in JavaScript, or any of the other languages support by the Tropo Scripting platform.
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 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.
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!
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: