Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return an empty response to an sms request?

How can I return nothing back to the twilio process after processing the sms message?

The examples in the api use the MessagingResponse and when that is used, it comes in as a Direction='reply' in the message log on the console. This incurs an additional charge (inbound + reply). Simply put, I want to do this..

app.post('/sms', (req, res) =>
{
    console.log('hello world');
}

without getting a 11200 error.

like image 444
ergonaut Avatar asked Nov 15 '25 12:11

ergonaut


1 Answers

Try an empty string as the response message (Twilio needs you to return valid XML).

const http = require('http');
const express = require('express');
const MessagingResponse = require('twilio').twiml.MessagingResponse;

const app = express();

app.post('/sms', (req, res) => {
  const twiml = new MessagingResponse();

  // twiml.message('');

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

http.createServer(app).listen(1337, () => {
  console.log('Express server listening on port 1337');
});
like image 127
Alex Baban Avatar answered Nov 18 '25 21:11

Alex Baban



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!