0

I am trying to use Twilio to follow through a workflow depending on responses to a SMS. I trigger the SMS in an application I have written and I want the user's reply to then cancel an action. There can be multiple instances of each action but each will have a unique ID. I need a way to link the users reply to the original message that is triggered by the app as the body will contain the unique ID. Thanks in advance.

Hannah
  • 67
  • 6
  • Check out my answer to this question, it's very similar to your use case: https://stackoverflow.com/questions/44587334/twilio-sms-reply-feature/44587494#44587494 – philnash Jul 06 '17 at 11:15

1 Answers1

1

I'm not sure I fully understand your use case so forgive me if this is way off the mark, but isn't it just a case of logging the MessageSid of your outgoing SMS which is returned by Twilio when your app sends the first SMS, then saving this in a local database associated with the phone number it was sent to?

Then when you receive an incoming SMS you take the number of the sender provided by Twilio and perform a database query to search for the MessageSid which corresponds to that number.

Now you have the unique MessageSid you use the Twilio API to retrieve the body of the original message your app sent and you have your unique ID.

On an even simpler level, if your app is only sending one SMS to each user then no need to log the original MessageSid. Upon receiving a reply just submit the incoming phone number as the "To" parameter to the Twilio SMS API and you can retrieve the content of your original outgoing SMS.

miknik
  • 5,748
  • 1
  • 10
  • 26