问题
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:
- Grab the twilio-ruby helper library.
- Point your SMS Url to the Rails controller/action you'd like to invoke
- Process the incoming request & execute your business logic
- 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