Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twilio test SMS does not result StatusCallback

I noticed that when I send a test SMS with the Twilio API, everything works as described in the documentation but the StatusCallback is not invoked by the system. The same setting works fine with the real credentials, I get the callback. Is this the expected behavior?

This is how I send the SMS:

/* Test credentials */ 
var account_sid = "<<test acc>>";        
var auth_token = "<<test auth>>";
var fromNumber = "+15005550006"; // test number

var fromNumberEnc = encodeURIComponent(fromNumber); 
var toNumberEnc = encodeURIComponent(toNumber);
var textEnc = encodeURIComponent(text);
var body = "From=" + fromNumberEnc + "&To=" + toNumberEnc + "&Body=" + textEnc + "&StatusCallback=" + "https%3A%2F%2Fexample.com%2Ftwiliocallback";
    httpRequest.post({
        url: "https://" + account_sid + ":" + auth_token +
             "@api.twilio.com/2010-04-01/Accounts/" + account_sid + "/SMS/Messages.json",
        headers: { 'content-type': 'application/x-www-form-urlencoded' },
        body: body
    }, function (err, resp, body) {
        console.log(body);
    });
like image 472
allprog Avatar asked Jul 26 '13 12:07

allprog


People also ask

How do I use StatusCallback in Twilio?

Configure a StatusCallback URL when creating a Room using the REST API, and Twilio will make an HTTP request (webhook) to that URL whenever an event takes place in the Room. The Rooms API will generate the following Status Callback events.

Why is Twilio not sending SMS?

Two common reasons for this: You might be trying to send SMS from a phone number which is only enabled for voice. This list shows which Twilio phone numbers are SMS enabled. All other Twilio phone numbers are not capable of sending SMS messages.

How do I check my Twilio SMS status?

This status is only shown in Messaging Insights; SMS records will remain in the sent status in the Message Log or /Messages API. Twilio has received confirmation of message delivery from the carrier, (and, where available, the destination handset).

Does Twilio retry SMS?

Twilio webhooks (for SMS or phone calls) do not make retry attempts to the same URL if your application fails to respond with a 200 response. However, you can supply a fallback URL that Twilio will request with the same parameters if your primary URL fails.


1 Answers

Rob from Twilio here.

Great question here on using Twilio's test credentials when building against the SMS API. You are correct - StatusCallbacks do not fire for the Messages resource when invoked with test credentials. The documentation section on StatusCallback you reference indicates that the API response will return the value you set for the StatusCallback parameter when testing a phone number purchase, not creating a message or phone call.

I test for StatusCallbacks by mocking the StatusCallback request inside my test using the parameters from the documentation here. The relevant parameter you want to test against on the new Messages resource is MessageStatus.

like image 55
Rob Spectre Avatar answered Oct 04 '22 09:10

Rob Spectre