Guest User

Untitled

a guest
Jan 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. def number
  2.  
  3. if params[:redirect]
  4. puts 'From redirect pressed 4'
  5. end
  6.  
  7. user_id = params[:user_id]
  8. digit = params[:Digits]
  9. response = @@twilio.voice_response
  10.  
  11. case digit
  12. when '1'
  13. response.say(message: 'Give the title of idea after the beep, when you are finished, press Hash')
  14. response.pause(length: 2)
  15. response.record(action: '/save_record', method: 'GET', transcribe: true, play_beep: true, transcribeCallback: '/transcribe')
  16. response.say(message: 'I did not receive a recording')
  17. when '2'
  18. contents = fetch_content_ideas(user_id)
  19. response.say(message: "You have total #{contents.count} ideas")
  20. response.pause(length: 1)
  21. response.say(message: contents.join(', '))
  22. when '3'
  23. clients = fetch_clients(user_id)
  24. response.say(message: "You have total #{clients.count} clients")
  25. response.pause(length: 1)
  26. response.say(message: clients.join(', '))
  27. response.pause(length: 1)
  28. # let user press # and then redirect him to /gather_pin
  29. response.gather(action: '/main_menu', method: 'GET') do |gather|
  30. gather.say(message: 'Press hash to go back to Main Menu')
  31. gather.pause(length: 2)
  32. end
  33. when '4'
  34. puts 'You pressed 4'
  35. # This instead redirects to the /number route (same action)
  36. # doesn't redirect to /main_menu
  37. response.gather(action: '/main_menu?redirect=true', method: 'GET') do |gather|
  38. gather.say(message: 'lets see this redirects or not??')
  39. end
  40. ### redirect vs gather (whenever a user press a key gather redirects to the action provided)
  41. ### redirect might do the job
  42. else
  43. response.say(message: Conversation::NO_INPUT)
  44. end
  45. render xml: response.to_xml
  46. end
  47.  
  48.  
  49. def main_menu
  50. puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
  51. puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
  52. puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
  53. puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
  54. puts '==--=--------------=-=-=0-=0-=-0--wewiqr=-==='
  55. if params[:redirect]
  56. puts 'From the switch case Pressed 4'
  57. end
  58. puts '--------------------------main_menu--------------------------------------'
  59. response = @@twilio.voice_response
  60. digit = params[:Digits]
  61.  
  62. puts response
  63. puts digit
  64.  
  65. if digit.eql?('#')
  66. response.redirect('/gather_pin?redirect=true', method: 'GET')
  67. else
  68. puts digit
  69. end
  70. render xml: response.to_xml
  71. end
  72.  
  73. #--------------------routes.rb----------------------------#
  74. get 'gather_pin' => 'twilio#gather_pin'
  75. get 'main_menu' => 'twilio#main_menu'
  76. get 'number' => 'twilio#number'
Add Comment
Please, Sign In to add comment