Facebook Integration with NPM

Create a bot API key

Each bot needs its own API key for tracking.

Create a bot to get an API key.

Install Dashbot via NPM

npm install --save dashbot

Include Dashbot

Use the API key created above.

const dashbot = require('dashbot')(process.env.DASHBOT_API_KEY).facebook;

Log whenever your webhook is called

...'/guessnumber', (request, response) => {

Whenever you send a message, log the request and response

const requestData = {
url: '',
qs: {access_token: process.env.FACEBOOK_PAGE_TOKEN},
method: 'POST',
json: {
recipient: {id: sender},
message: {
text: 'You are right when you say: ' + text
request(requestData, (error, response, body) => {
dashbot.logOutgoing(requestData, response.body);


View sample code for a Facebook Messenger Bot, with Dashbot analytics already integrated.