-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.rb
26 lines (19 loc) · 799 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'sinatra'
require 'twilio-ruby'
use Rack::TwilioWebhookAuthentication, ENV['AUTH_TOKEN'], '/message/forward'
get '/' do
"You are good to go. Now put the url #{request.url}message/forward/?to=2025551212 into your Messaging URL on your phone number in the Twilio Account interface.
<p>Obviously replacing with the phone number you want to forward to."
end
post '/message/forward/?' do
# take the forward number from the URL parameter
# and the content of the message from the POST param
# we then concatenate a message telling who the SMS is from
forward_number = params[:to]
body = "Message from #{params[:From]}: #{params[:Body]}"
#create a Twiml Response object
response = Twilio::TwiML::Response.new do |r|
r.Message body, to: forward_number
end
response.text
end