Twilio 短信回复功能 [英] Twilio sms reply feature

查看:42
本文介绍了Twilio 短信回复功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个基于 cron 作业的系统,它为用户生成新任务.生成新任务时,cron 文件使用 twilio sms api 向用户发送短信.现在我想做一些事情,比如当用户用完成"这个词回复短信时,与短信相关的任务将在我的数据库中完成.

I've created a system based on cron job which generates new tasks for user. When new task is generated cron file sends a sms to user using twilio sms api. Now I want make something like when user reply to that sms with word "Done" that task associated with sms will be completed in my database.

我在 twilio 帐户中设置了回复 URL.一切正常.我的观点是如何在数据库中完成该任务.twilio 中是否有任何功能可以帮助我发送额外的参数作为任务 id,以便我可以从回复中获取该 id 并更新任务的状态.

I've set reply URL in twilio account. And everything is working fine. My point is how can I complete that task in database. Is there any feature exist in twilio that can help me to send extra parameter as task id, so that I can fetch that id from reply and update the status of task.

推荐答案

Twilio 开发人员布道者在这里.

Twilio developer evangelist here.

SMS 无法回复特定消息(您可以在手机上的 SMS 应用程序中亲自尝试),因此没有可以在对话中秘密传递的 ID.

There's no way in SMS to reply to a specific message (try it yourself in your SMS app on your phone), so there's no ID that you can pass around secretly within conversations.

有几种方法可以解决这个问题.

There are a few ways you can work around this.

如果一次只向用户发送一个任务,那么您可以记录他们当前的任务是什么,当您收到完成"消息时,勾选该任务并发送下一个任务.

If the user is sent only one task at a time, then you can record what their current task is and when you receive the message saying "done" tick that one off and send them the next task.

您可以在消息中向他们发送任务 ID,并告诉他们在回复说已完成时包含该 ID.然后,您可以从消息中解析出 ID,并将其在您的数据库中标记为已完成.

You could send them a task ID within the message, and tell them to include that ID when they respond to say they are done. You could then parse the ID out of the message and mark it as done in your database.

或者,这可能太过分了,您可以使用一组数字来发送任务,这样用户的每个实时任务都有一个用户响应的唯一编号.然后您可以根据用户和他们回复的号码查找任务.然后你就可以腾出号码来做一个新的任务.

Or, and this might be too far, you could use a pool of numbers to send tasks out such that each live task for a user has a unique number the user responds to. Then you can look up the task based on the user and the number they replied to. Then you can free up the number for a new task.

告诉我这是否有帮助.

这篇关于Twilio 短信回复功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆