Skip to content

Commit

Permalink
Added goodbye message.
Browse files Browse the repository at this point in the history
  • Loading branch information
jarodreyes committed Aug 17, 2015
1 parent 41d1c46 commit 0e9f8ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions app/controllers/twilio_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
# POST ivr/welcome
def ivr_welcome
response = Twilio::TwiML::Response.new do |r|
r.Gather numDigits: '1', action: '/ivr/selection' do |g|
r.Gather numDigits: '1', action: menu_path do |g|
g.Play "http://howtodocs.s3.amazonaws.com/et-phone.mp3", loop: 3
end
end
Expand Down Expand Up @@ -80,24 +80,26 @@ def twiml_say(phrase, exit = false)
response = Twilio::TwiML::Response.new do |r|
r.Say phrase, voice: 'alice', language: 'en-GB'
if exit
r.Hangup
r.Say "Thank you for calling the ET Phone Home Service - the
adventurous alien's first choice in intergalactic travel."
r.Hangup
else
r.Redirect "/ivr/welcome"
r.Redirect welcome_path
end
end

render text: response.text
end

def twiml_play(audio_url, exit = false)
# Respond with some TwiML and say something.
# Should we hangup or go back to the main menu?
response = Twilio::TwiML::Response.new do |r|
r.Play audio_url, loop:2
if exit
r.Hangup
r.Say "Thank you for calling the ET Phone Home Service - the
adventurous alien's first choice in intergalactic travel.", voice: 'alice', language: 'en-GB'
r.Hangup
else
r.Redirect "/ivr/welcome"
r.Redirect welcome_path
end
end

Expand Down
6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
root 'twilio#index'

# webhook for your Twilio number
match 'ivr/welcome' => 'twilio#ivr_welcome', via: [:get, :post]
match 'ivr/welcome' => 'twilio#ivr_welcome', via: [:get, :post], as: 'welcome'

# callback for user entry
match 'ivr/selection' => 'twilio#menu_selection', via: [:get, :post]
match 'ivr/selection' => 'twilio#menu_selection', via: [:get, :post], as: 'menu'

# callback for planet entry
match 'ivr/planets' => 'twilio#planet_selection', via: [:get, :post]
match 'ivr/planets' => 'twilio#planet_selection', via: [:get, :post], as: 'planets'

end

0 comments on commit 0e9f8ce

Please sign in to comment.