Skip to content

Instantly share code, notes, and snippets.

@jonathanhculver
Created August 16, 2013 00:08
Show Gist options
  • Select an option

  • Save jonathanhculver/6246113 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanhculver/6246113 to your computer and use it in GitHub Desktop.
a simple voice menu
post '/voice.json' do
t = Tropo::Generator.new
t.ask :name => 'digit',
:timeout => 60,
:say => {:value => "Hello! What year were you born?"},
:choices => {:value => "[4 DIGITS]"}
t.on :event => 'continue', :next => '/continue.json'
t.response
end
post '/continue.json' do
t = Tropo::Generator.new
v = Tropo::Generator.parse request.env["rack.input"].read
answer = v[:result][:actions][:digit][:value]
time = 2013 - Integer(answer)
t.say(:value => "Wow! That was " + String(time) + " years ago.")
t.response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment