3

I am using the Twilio java wrapper provided on the website and started making some tests. I am able to send text messages that are successfully received. However, I would like to make sure that the messages have been sent successfully and that no problem has been encountered by Twilio (bad phone number or whatever reason).

I understand that when you make a REST request to Twilio to send a SMS, Twilio responds with the Status. How could I get this response?

Here is the explanation page I found: http://www.twilio.com/docs/howto/sms-notifications-and-alerts

dukable
  • 3,968
  • 11
  • 31
  • 42

3 Answers3

4

If you specify a StatusCallback URL when you make the request to send an SMS, we will make a request to the callback URL you provided after the message has finished processing, with the parameters either SmsStatus=sent or SmsStatus=failed. You can use this information to do more processing on the SMS message. There's more information here: http://www.twilio.com/docs/api/rest/sending-sms#post-parameters-optional

Alternately, if you hang on to the SMS Message Sid, you should be able to query the API for the message and get the status in the response. So if the sid is SM123, making a GET request to https://api.twilio.com/2010-04-01/Accounts/AC123/SMS/Messages/SM123.json should return a object with the status of the SMS Message.

Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
1

I recall that the response comes to your url and can be matched up by an ID. In the REST post to SMSMessages you can specify a statuscallback url where Twilio will post a status message to your url.

When you receive that post to your site, you can record it or take any other action you need, such as retrying or using another mode of communication.

joshp
  • 1,886
  • 2
  • 20
  • 28
0

In 2020, with the Java SDK, you can now create a MessageFetcher with that SID and then call fetch to ask for the Message instance until its getStatus returns "delivered", "undelivered", or "failed".

Douglas Manley
  • 1,093
  • 13
  • 18