Created
August 7, 2012 20:44
-
-
Save jonmarkgo/3289137 to your computer and use it in GitHub Desktop.
outletserver2
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
post '/control/?' do | |
output = "Message transmitted" #sms/html output message | |
#try to trigger a pusher event based on the Body of the incoming SMS or submitted form | |
begin | |
Pusher['robot_channel'].trigger('powersms', {:command => params['Body'].downcase}) | |
rescue Pusher::Error => e | |
output = "Failed: #{e.message}" | |
end | |
#if the web form was submitted, render our erb template | |
if params['SmsSid'] == nil | |
erb :index, :locals => {:msg => output} | |
else | |
#otherwise return TwiML to send an SMS | |
response = Twilio::TwiML::Response.new do |r| | |
r.Sms output | |
end | |
response.text | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment