Skip to content
This repository has been archived by the owner on Jan 28, 2018. It is now read-only.

add javascript webhook implementation #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/**/node_modules
27 changes: 27 additions & 0 deletions javascript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';
const express = require('express');
const bodyParser = require('body-parser');

// The rest of the code implements the routes for our Express server.
let app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));

// Webhook validation
app.get('/webhook', function(req, res) {
// replace <VERIFY_TOKEN> here with the verify token you specified on messenger dashboard
if (req.query['hub.mode'] === 'subscribe' &&
req.query['hub.verify_token'] === '<VERIFY_TOKEN>') {
res.status(200).send(req.query['hub.challenge']);
} else {
res.send('Error, wrong validation token');
}
});

// Set Express to listen out for HTTP requests
var server = app.listen(process.env.PORT || 3000, function () {
console.log("Listening on port %s", server.address().port);
});
350 changes: 350 additions & 0 deletions javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading