Each bot needs its own API key for tracking.
Create a bot to get an API key.
npm install --save dashbot
Use the API key created above.
const dashbot = require('dashbot')(<strong>process.env.DASHBOT_API_KEY</strong>).facebook;
app.use(bodyParser.json())
...
app.post('/guessnumber', (request, response) => {
<strong>dashbot.logIncoming(request.body);</strong>
...
})
const requestData = {
url: 'https://graph.facebook.com/v2.6/me/messages',
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) => {
<strong>dashbot.logOutgoing(requestData, response.body);</strong>
});
View sample code for a Facebook Messenger Bot, with Dashbot analytics already integrated.