otajor
otajor

Reputation: 953

How can a Twilio user reply to take a specific action

So here's our desired sequence of events:

  1. We use Twilio to text our users with a notification about a specific transaction on our web app, which includes a simple call to action, e.g. 'Hi Alice. Your transaction regarding your teddy bear is pending. Please reply with "YES" to approve this transaction'.
  2. The user replies "YES"
  3. This triggers a call to an endpoint on our server which changes the status of this transaction to 'approved' in our database.

The problem is that we can't figure out how to keep track of WHICH transaction a particular SMS is linked to.

Our ideas so far:

Can anyone give us any pointers on how we could go about this?

Upvotes: 4

Views: 278

Answers (1)

Alex Baban
Alex Baban

Reputation: 11702

Use a group (pool) of Twilio numbers to send the messages.

Once a message is sent using a number, get that number out of the group, keep it associated with the user (and the phone number of the user) from where you expect the response (don't use it to send another SMS until you get the response from the user).

When you get the response also check from where it comes, if all OK put the number back in the group.

If the user does not respond in due time, free your Twilio number an put it back in the group.

Upvotes: 3

Related Questions