botimize - Analytics built to optimize your bots
-
Create a free account at botimize to get an API key.
-
Install botimize SDK with
npm:npm install --save botimize
Use API key to create a new botimize object
-
Facebook:
const botimize = require('botimize')('<YOUR-API-KEY'>, 'facebook');
-
Generic Logging:
const botimize = require('botimize')('<YOUR-API-KEY'>, 'generic');
-
Facebook
app.post('/webhook', function (req, res)) { botimize.logIncoming(req.body); ... }
-
Generic
app.post('/webhook', function (req, res)) { const incomingLog = { sender: { id: 'UNIQUE_USER_ID', name: 'USER_SCREEN_NAME' }, content: { type: 'CONTENT_TYPE', // 'text', 'image', 'audio', 'video', 'file', 'location' text: 'CONTENT_TEXT' } }; botimize.logIncoming(incomingLog); ... }
-
Facebook
const options = { uri: 'https://graph.facebook.com/v2.6/me/messages', qs: { access_token: PAGE_ACCESS_TOKEN }, method: 'POST', json: messageData }; request(options, function (error, response, body) { botimize.logOutgoing(options); ... });
-
Generic
const outgoingLog = { receiver: { id: 'UNIQUE_USER_ID', name: 'USER_SCREEN_NAME' }, content: { type: 'CONTENT_TYPE', // 'text', 'image', 'audio', 'video', 'file', 'location' text: 'CONTENT_TEXT' } }; request(options, function (error, response, body) { botimize.logOutgoing(outgoingLog); ... });
const data = {
to: '<recipient-email>',
text: '<text-content-to-be-sent>'
};
botimize.notify(data, 'email');const data = {
to: '<incoming-webhook-url>',
text: '<text-content-to-be-sent>'
};
botimize.notify(data, 'slack');data can have all properties supported by Slack incoming webhook, e.g., channel, username, icon_emoji, attachments, etc.