0
votes

Good Day,

How do I properly receive an SMS on my web app using twilio without responding back to the sender.

I read about this.. https://support.twilio.com/hc/en-us/articles/223134127-Receive-SMS-messages-without-Responding but I need to use the webhook to send the sms to my webapplication too, if I do receive it without setting a response, It will generate an Error - 11200 (HTTP retrieval failure) how do I prevent this? also by setting up respones.

my code is

var resp = new twilio.twiml.MessagingResponse();
resp.message('<Response></Response>');
                      res.writeHead(200, {
                        'Content-Type':'text/xml'
                      });
                      res.end(resp.toString());

sadly this one sends <Response></Response> to the sender instead.. im using nodejs by the way.. Thanks!

2

2 Answers

3
votes

Those who are finding this in 2021,

If you need to just recieve message from twilio and not send any message to user then you can use this code.

res.writeHead(200, {'Content-Type': 'text/plain'});
res.end();

For more refer this doc, Receive SMS and MMS Messages without Responding

1
votes

I have not tried yet but I think if you comment out this line:

// resp.message("<Response></Response>");

no message will be sent.


Update after reading Phil's comment:

This: resp.message('<Response></Response>');

is equivalent with sending the folowing XML to Twilio:

<Response>
  <Response></Response>
</Response>

in which case the sender will receive a message like: <Response></Response>

If you comment out the line

// resp.message("<Response></Response>");

or if you do resp.message("");

is equivalent with sending the folowing XML to Twilio:

<Response />

in which case no message will be sent to the sender.