How do I use Twilio to receive text messages from users and reply to that text with a message?

折月煮酒 提交于 2019-12-06 04:30:51

问题


1.) User sends a text message to a designated Twilio phone number 2.) Application receives this message and parses it for actionable data 3.) Application replies to sender with a text message delivering the requested information

How the heck do I do this with rails?!


回答1:


Assuming your business logic doesn't take that long to execute, it's pretty simple to process a text and send a response. Here are the core steps:

  1. Grab the twilio-ruby helper library.
  2. Point your SMS Url to the Rails controller/action you'd like to invoke
  3. Process the incoming request & execute your business logic
  4. Instead of returning HTML, return TwiML

Here's a link to a simple app that does just this:

https://github.com/crabasa/twilio-rails-demo

Update: I've written two detailed blog posts on integration Twilio into a Rails 4.x app: Part 1 and Part 2.



来源:https://stackoverflow.com/questions/11022471/how-do-i-use-twilio-to-receive-text-messages-from-users-and-reply-to-that-text-w

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!