@enablo/workplace-webhooks
v1.0.4
Published
Simple node module to bootstrap the process of developing against Workplace by Facebook webhooks.
Downloads
13
Readme
workplace-webhooks
A simple node module to help bootstrap developing with Workplace by Facebook webhooks. It takes care of things like the webhooks verification, X-hub-signature validaton, etc.
Install
$ npm install @enablo/workplace-webhooks
Usage
Create a simple app
The example below creates a basic app which listens for requests on /webhook.
const WorkplaceWebhooks = require('@enablo/workplace-webhooks');
const workplaceWebhooks = new WorkplaceWebhooks(process.env.WORKPLACE_APP_SECRET,
process.env.WORKPLACE_VERIFY_TOKEN);
workplaceWebhooks.page((message) => {
// Do something with the page message
});
const port = process.env.PORT || 3000;
workplaceWebhooks.listen(port)
.then(() => console.info(`🖥️ Server listenting on port ${port}.`))
.catch(err => console.error(err.message));
Examples
A basic example of how to implement the webhooks is available under /examples.