ruby on rails - Twilio post to url with params[:text_response] and params[:phone_number] -


i using ruby 2.0.0 , rails 4.0.

i sending text message out via rails app end user.

when respond, want redirect them api call:

www.myapp.com/api/verify_text_response

within api call, want see text message sent end user url is. ideally, receive param of "text_response" wanted with.

how can redirect reply end_user above url, , capture phone number came message sent me in params? if isn't possible, how can use twiml similar?

end goal

for it's worth, i'm trying accomplish:

  1. i send text message out - "would subscribe?"
  2. the end user responds "yes" or "no".
  3. i change subscribed attribute on subscription model true or false.
  4. i send text message saying either "you subscribed." or "you not subscribed.".

item's #3 , #4 based on user responding "yes" or "no" in item #2.

the twilio guide here ruby useful documentation out there. recommend using twilio gem in rails application adding twilio-ruby gem gemfile.

all need add following code 1 of controller's actions (the 1 routed www.myapp.com/api/verify_text_response:

def receive_text   # not sure right parameter, it's easy test   sender_message = params[:body]    response = if (sender_message == "yes")     "you subscribed."   else     "you not subscribed."   end    twiml = twilio::twiml::response.new |r|     r.message(response)   end   twiml.text end 

to make rails application accessible twilio, follow directions found on this page:

copy , paste url of server "sms" url of number on numbers page of twilio account. on page number, change method "post" "get".

i wasn't sure looking @ documentation parameter holds user's response (i thought params[:body]), best way figure out printing out parameters controller receives when send text message twilio number.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -