Skip to content

mnort9/node-botmetrics

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

node-botmetrics

Official NodeJS client for BotMetrics, bot & conversation analytics.

Installation

npm install node-botmetrics --save

Facebook Messenger SDK

var botmetrics = require('node-botmetrics')('API_TOKEN').facebook;

Incoming

app.post('/webhook', function (req, res) {
    botmetrics.trackIncoming(req.body);
    
    // Handle incoming message...
}

Outgoing

// Example POST to Facebook

var fbData = {
    recipient: { id: fbUserId },
    message: {
        text: 'Hi there!'
    }
};

var options = {
    url: 'https://graph.facebook.com/v2.6/me/messages',
    qs: { access_token: FB_PAGE_TOKEN },
    method: 'POST',
    json: fbData
};

request(options, function(err, res, body) {
    if (err) return console.log(err);
    
    // After FB post is successful, send req data to BotMetrics
    botmetrics.trackOutgoing(fbData);
});

Other Messaging Platforms

var botmetrics = require('node-botmetrics')('API_TOKEN');

botmetrics.track({
    text: 'Hi there!',
    message_type: 'outgoing',
    user_id: '54367392345234',
    platform: 'kik'
});

Debug Mode

// Turn on debug mode to print BotMetrics API messages
var botmetrics = require('node-botmetrics')('API_TOKEN', true);

Documentation

View complete documentation here: https://bot-metrics.com/docs

About

Official NodeJS client for BotMetrics - Bot & Conversation Analytics

Resources

Stars

Watchers

Forks

Packages

No packages published