Skip to content

Instantly share code, notes, and snippets.

@scpike
Created January 27, 2012 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scpike/1689399 to your computer and use it in GitHub Desktop.
Save scpike/1689399 to your computer and use it in GitHub Desktop.
Handle a response from twilio
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