简体   繁体   中英

Twilio sms reply feature

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.

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 developer evangelist here.

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.

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.

Let me know if this helps at all.

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