×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Love Code
Added: Jun 6, 2018 12:32 AM
Modified: Jun 6, 2018 12:56 AM
Views: 3123
Tags: no tags
  1. const http = require('http');
  2. const express = require('express');
  3. const MessagingResponse = require('twilio').twiml.MessagingResponse;
  4.  
  5. const app = express();
  6.  
  7. app.post('/sms', (req, res) => {
  8.   const twiml = new MessagingResponse();
  9.  
  10.   twiml.message('The Robots are coming! Head for the hills!');
  11.  
  12.   res.writeHead(200, {'Content-Type': 'text/xml'});
  13.   res.end(twiml.toString());
  14. });
  15.  
  16. http.createServer(app).listen(1337, () => {
  17.   console.log('Express server listening on port 1337');
  18. });