简体   繁体   English

如何使用Twilio管理短信对话?

[英]How to manage a SMS conversation with Twilio?

I know how to send and receive SMS in Twilio. 我知道如何在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. 我不知道的是如何构建一个PHP服务器应用程序来发送带有问题的SMS消息,如果在指定的时间内(2分钟或其他值)没有收到该问题的SMS响应,发送短信提醒并重启计时器。

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 . PHP没有内置的(如Ruby delayed_job gem ),因此您需要编写一个cron作业或使用像Moment这样的东西。

The workflow would go something like this: 工作流程将是这样的:

  • Send the initial message using the Twilio REST API 使用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. 如果您的预定进程发现消息已“过期”,请将其标记为已过期,并使用新的日志条目重新发送该消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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