-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix validateExpressRequest issue (#665)
- Loading branch information
1 parent
65a59af
commit 671c7ac
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const twilio = require('twilio'); | ||
const bodyParser = require('body-parser'); | ||
const MessagingResponse = require('twilio').twiml.MessagingResponse; | ||
|
||
const express = require('express') | ||
const app = express() | ||
const port = 3000 | ||
|
||
app.use(bodyParser.json({ | ||
verify: (req, res, buf) => { | ||
req.rawBody = buf | ||
} | ||
})) | ||
|
||
app.get('/', (req, res) => { | ||
res.send('Hello World!') | ||
}) | ||
|
||
app.post('/message', twilio.webhook(), (req, res) => { | ||
// Twilio Messaging URL - receives incoming messages from Twilio | ||
const response = new MessagingResponse(); | ||
|
||
response.message(`Your text to me was ${req.body.Body}. | ||
Webhooks are neat :)`); | ||
|
||
res.set('Content-Type', 'text/xml'); | ||
res.send(response.toString()); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`Example app listening at http://localhost:${port}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters