Skip to content

Instantly share code, notes, and snippets.

@jonmarkgo
Created August 7, 2012 20:44
Show Gist options
  • Save jonmarkgo/3289137 to your computer and use it in GitHub Desktop.
Save jonmarkgo/3289137 to your computer and use it in GitHub Desktop.
outletserver2
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