Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def number
- if params[:redirect]
- puts 'From redirect pressed 4'
- end
- user_id = params[:user_id]
- digit = params[:Digits]
- response = @@twilio.voice_response
- case digit
- when '1'
- response.say(message: 'Give the title of idea after the beep, when you are finished, press Hash')
- response.pause(length: 2)
- response.record(action: '/save_record', method: 'GET', transcribe: true, play_beep: true, transcribeCallback: '/transcribe')
- response.say(message: 'I did not receive a recording')
- when '2'
- contents = fetch_content_ideas(user_id)
- response.say(message: "You have total #{contents.count} ideas")
- response.pause(length: 1)
- response.say(message: contents.join(', '))
- when '3'
- clients = fetch_clients(user_id)
- response.say(message: "You have total #{clients.count} clients")
- response.pause(length: 1)
- response.say(message: clients.join(', '))
- response.pause(length: 1)
- # let user press # and then redirect him to /gather_pin
- response.gather(action: '/main_menu', method: 'GET') do |gather|
- gather.say(message: 'Press hash to go back to Main Menu')
- gather.pause(length: 2)
- end
- when '4'
- puts 'You pressed 4'
- # This instead redirects to the /number route (same action)
- # doesn't redirect to /main_menu
- response.gather(action: '/main_menu?redirect=true', method: 'GET') do |gather|
- gather.say(message: 'lets see this redirects or not??')
- end
- ### redirect vs gather (whenever a user press a key gather redirects to the action provided)
- ### redirect might do the job
- else
- response.say(message: Conversation::NO_INPUT)
- end
- render xml: response.to_xml
- end
- def main_menu
- puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
- puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
- puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
- puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
- puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
- if params[:redirect]
- puts 'From the switch case Pressed 4'
- end
- puts '--------------------------main_menu--------------------------------------'
- response = @@twilio.voice_response
- digit = params[:Digits]
- puts response
- puts digit
- if digit.eql?('#')
- response.redirect('/gather_pin?redirect=true', method: 'GET')
- else
- puts digit
- end
- render xml: response.to_xml
- end
- #--------------------routes.rb----------------------------#
- get 'gather_pin' => 'twilio#gather_pin'
- get 'main_menu' => 'twilio#main_menu'
- get 'number' => 'twilio#number'
Add Comment
Please, Sign In to add comment