Created
August 16, 2013 00:08
-
-
Save jonathanhculver/6246113 to your computer and use it in GitHub Desktop.
a simple voice menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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