Twilio: How to get answers from message log with just phone number

196 views Asked by At

I want to get received messages of the same day of a phone number with the help of API or anything. (I have purchased ofcourse a phone number) **

Requirement :

** I have a twilio app which sends 5 questions to 1000 user and users reply's to it. Like a survey. App is deployed on Azure. I will get 5000 messages in log. I am planning to retrieve messages by phone number and update my database from the user.

Implemented :

Implemented this https://www.twilio.com/docs/guides/sms/how-to-receive-and-reply-in-csharp. Any other idea for the requirement is also appreciated.

1

There are 1 answers

1
philnash On BEST ANSWER

Twilio developer evangelist here.

I see that you've implemented the basic flow for responding to incoming SMS messages. If you are implementing surveys across a number of users my advice would be to expand on that application.

Firstly, you would need to run through your database to get all your users' phone numbers and send the first question to all of them using the Twilio REST API to send each a text message.

Then, when you receive an incoming message from one of your respondents you can find out the number that sent the message by inspecting the From parameter on the incoming request body. You can then look up your user in your database by phone number and save that response for them. Then you can use the TwiML <Message> to respond to the user and send them the next question.

This way you can collect the responses as they come in, rather than call the REST API to list all responses.

Let me know if that helps at all.