Skip to content

Instantly share code, notes, and snippets.

@dstotijn
Created November 10, 2017 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstotijn/fb6d8b46e5f97b68dbc70f5c25ee4bd0 to your computer and use it in GitHub Desktop.
Save dstotijn/fb6d8b46e5f97b68dbc70f5c25ee4bd0 to your computer and use it in GitHub Desktop.
Web server that logs incoming SMS message callbacks from MessageBird
const app = require("express")();
const bodyParser = require("body-parser");
const port = process.env.PORT || 3000;
app.use(bodyParser.urlencoded({ extended: true }));
/**
* @see https://developers.messagebird.com/docs/messaging#messaging-receive
*/
app.post("/", (req, res) => {
console.log({
id: req.body.id,
recipient: req.body.recipient,
originator: req.body.originator,
body: req.body.body,
createdDatetime: req.body.createdDatetime
});
res.send("OK");
});
app.listen(port, () =>
console.log(`Server running on http://localhost:${port}`)
);
{
"name": "messagebird-callbacks-node",
"version": "1.0.0",
"description":
"Web server that logs incoming SMS message callbacks from MessageBird.",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "David Stotijn <david@messagebird.com>",
"license": "MIT",
"dependencies": {
"body-parser": "^1.18.2",
"express": "^4.16.2"
},
"devDependencies": {
"prettier": "^1.8.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment