Created
January 27, 2012 15:51
-
-
Save scpike/1689399 to your computer and use it in GitHub Desktop.
Handle a response from twilio
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
def handle_call | |
call_sid = params["CallSid"] | |
checkin = Checkin.find_by_twilio_call_id(call_sid) | |
if checkin | |
response = Twilio::TwiML::Response.new do |r| | |
r.Pause :length => 1 # Found that people like to say "Hello" when they pick up | |
# Separate controller action 'directions' handles your button presses | |
r.Gather :action => directions_path, :numDigits => 1 do |r| | |
r.Say checkin.message, :voice => 'woman' | |
r.Pause :length => 1 | |
r.Say "Press 1 to leave a reply, or 2 to repeat this message.", :voice => "woman" | |
end | |
end | |
else | |
response = Twilio::TwiML::Response.new do |r| | |
r.Hangup | |
end | |
end | |
respond_to do |format| | |
format.xml { render :xml => response.text } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment