I am currently using Twilio to send someone a text, this person/phone number is associated with a data object on the backend. When the object is created, this text is sent out with a question.
I have setup a webhook for the Twilio number so that when it receives a message, it will hit an endpoint I have setup on my server. I would like to alter the object based on the user's response.
However I cannot figure out a way to associate the text sent that corresponds with the initial object, to the text/object that I receive as a response. The messages have ID's, but those are unique to each message, they are not unique to each 'conversation' or phone number, so they are not useful for me in this scenario.
Is there a way to do this? The backend data objects have a unique ID on them, but I don't see a way to pass this around so that I can access it later once I get a response text.
SMS is stateless, so the only way to keep track of a session is to use a unique number to send the message from which isn’t realistic.
You will need to send only one message out at a time and await a response with some built in timeout on your side and then decide what to do next, send the same message or send the next message.
Another way is have them reference some value you can look for in the response body to match the response with the request.