Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (58 sloc) 2.76 KB
require "rubygems"
require "sinatra"
require "tropo-webapi-ruby"
get "/" do
html = '<html>
<link type="text/css" rel="stylesheet" href=""/>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<h1>Tropo Voice Dialtone</h1>
<p>This is a Ruby/Sinatra-powered <a href="">Phono</a>/<a href="">Tropo</a> application. Click the button below and say or enter a 10 digit number that you would like to dial and we will do the rest.</p>
<h2>How does it work?</h2>
<p>Phono is a jQuery based VoIP SIP phone that runs in the browser. When the red button is clicked, it places a SIP call into a Tropo application using the WebAPI. The Tropo application is written in Ruby and uses the Tropo-WebAPI and Sinatra gems. The Tropo app first asks the caller to say or enter a phone number. The phone number is posted back to the Tropo app (/answer) where a transfer response is returned to the Tropo cloud. </p>
<p>Check out the code at <a href=""></a></p>
<script type="text/javascript">
apiKey: "C17D167F-09C6-4E4C-A3DD-2025D48BA243",
numberToDial: "app:9991489870",
buttonTextReady: "Call Someone",
return html
post "/" do
# sessions_object = Tropo::Generator.parse request.env['rack.input'].read
# msg = sessions_object[:session][:parameters][:msg]
# number_to_dial = sessions_object[:session][:parameters][:to]
tropo = do
on :event => 'continue', :next => '/answer'
say("Welcome to the Tropo voice dial tone application.")
ask({ :name => 'numbertodial',
:bargein => true,
:timeout => 30,
:require => 'true' }) do
say :value => 'Please say or enter a 10 digit phone number you would like to call.'
choices :value => '[10 DIGITS]'
post "/answer" do
tropo_event = Tropo::Generator.parse request.env["rack.input"].read
tropo = do
say("transferring call to " + tropo_event.result.actions.numbertodial.interpretation )
transfer({ :to => "+1" + tropo_event.result.actions.numbertodial.interpretation })
Jump to Line
Something went wrong with that request. Please try again.