Tofetopo
Tofetopo

Reputation: 496

How to execute code in my app from Twilio SMS

I'm developing a Java application that will send a sms to the user when a specific event happens. This part is perfectly working, I'm using Twilio to do this. Now I would like to know the steps to follow if I want to send a reply to the received message, for example, when I get a message with the event on my phone, I'd like to send a message to be able to execute some code in my application, i.e. send 1 to kill a process, or send 2 to shut down the computer. I can't find documentation for this specific case. Anyone?

Upvotes: 0

Views: 83

Answers (2)

Dan Revel
Dan Revel

Reputation: 124

Twilio's FAQ says:

When an SMS message is received by one of your Twilio numbers, 
Twilio makes an HTTP request to the SMS Request URL configured for that number

Configure your twilio phone number to send a request to your app when an in-bound SMS is received. You can set the url for in-bound SMS messages through the twilio console.

Upvotes: 0

Usman Shahid
Usman Shahid

Reputation: 302

You can use session data (like cookies) to track the back and forth between a specific phone number and their requests.

https://www.twilio.com/docs/quickstart/java/sms/tracking-conversations

You can use this to store information about the senders previous requests. If you want it to execute some code based off their message (i.e. if they send the number 1 it does some code) you can use a case statement.

Upvotes: 1

Related Questions