-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreceiveMessages.js
32 lines (25 loc) · 1.02 KB
/
receiveMessages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Download the Node helper library from twilio.com/docs/node/install
// These vars are your accountSid and authToken from twilio.com/user/account
var accountSid = 'ACcb08645cd700ef8293b7466eed8219a9';
var authToken = "96bfe1ccfda5ff6f9fbe5012c4eccdd5";
//var client = require('twilio')(accountSid, authToken);
var send = require('./momentMessages');
var twilio = require('twilio'),
express = require('express');
// Create express app with middleware to parse POST body
var app = express();
app.use(express.urlencoded());
// Create a route to respond to a message
app.post('/https://demo.twilio.com/welcome/sms/reply/setup', function(req, res) {
//Validate that this request really came from Twilio...
if (twilio.validateExpressRequest(req, authToken)) {
var twiml = new twilio.TwimlResponse();
twiml.sms('Thanks for setting up Moment!');
res.type('text/xml');
res.send(twiml.toString());
}
else {
res.send('Error. Expected Twilio.');
}
});
app.listen(process.env.PORT || 3000);