简体   繁体   中英

How to manage a SMS conversation with Twilio?

I know how to send and receive SMS in Twilio. What I don't know is how to build a PHP server application to send an SMS message with a question and, in case a SMS response for that question is not received in a specified amount of time (2 minutes or other value), would send a SMS reminder and restart the timer.

Can anyone help me out?

Any time you want to do something on a schedule, you need to use a scheduler of some sort. PHP does not have one built in (like the Ruby delayed_job gem ), so you'd need to write a cron job or use something like Moment .

The workflow would go something like this:

  • Send the initial message using the Twilio REST API
  • Log that the message was sent in your app's data store with a timestamp for the time it was sent
  • When a response is received, mark the log entry as completed
  • Use the scheduler to run a process every minute or so looking for unanswered messages
  • If your scheduled process finds a message that has 'expired', mark it as expired and re-send the message with a new log entry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM