Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

untitled notebook

node v12.21.0
version: 1.0.0
endpointsharetweet
const http = require('http'); const express = require('express'); const session = require('express-session'); const MessagingResponse = require('twilio').twiml.MessagingResponse; const app = express(); app.use(session({secret: 'anything-you-want-but-keep-secret'})); app.post('/sms', (req, res) => { const smsCount = req.session.counter || 0; let message = 'Hello, thanks for the new message.'; if(smsCount > 0) { message = 'Hello, thanks for message number ' + (smsCount + 1); } req.session.counter = smsCount + 1; const twiml = new MessagingResponse(); twiml.message(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'); });
Loading…

no comments

    sign in to comment