npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

botmeter-logger

v1.11.0

Published

A Botmeter logger wrapper for Node.js

Downloads

10

Readme

botmeter-logger

This library allows to log your bot conversations in the Botmeter analytics platform.

It is currently designed to be used with:

  • Messenger bots (doc here),
  • Microsoft Botbuilder bots (doc here) or,
  • Botfuel bots (included in the Botfuel bot SDK).

How to setup

Install:

npm install --save botmeter-logger

How to use

There are 3 ways you can use botmeter-logger:

  • generic
  • messenger
  • botbuilder

Using the API

const BotmeterLogger = require('botmeter-logger');

const genericLogger = new BotmeterLogger({
  appId: 'id',
  appKey: 'key',
}).generic;

const document = {
  bot_version: '1.0.2',
  timestamp: 1491475013000,
  channel: 'Webchat',
  user_id: 'JohnDoe',
  user: {
    first_name: 'John',
    last_name: 'Doe',
  },
  body: 'Hello',
  body_type: 'text',
  responses: ['Hi !', 'How are you ?'],
  state_in: 'Root',
  state_out: 'Root',
  intent: {
    name: 'Greetings',
    score: 0.8,
  }
};

genericLogger.indexDocument(document, function(error, body) {
  // Body will equal 'ok' if logging is successful
  ...
});

With Messenger

Log the message inside the POST request callback made when the bot replies (the user message and bot response(s) must be logged in the same document).

const BotmeterLogger = require('botmeter-logger');
const request = require('request');

const messengerLogger = new BotmeterLogger({
  appId: '<APP_ID>',
  appKey: '<APP_KEY>',
}).messenger;

// User message
const requestBody = 'Hello';

// Bot response
const responseJson = {
    recipient: {
      id: senderId,
    },
    message: {
      text: 'Hello World',
    },
  };


// POST bot reponse to facebook
request({
  uri: 'https://graph.facebook.com/v2.6/me/messages',
  qs: { access_token: process.env.PAGE_ACCESS_TOKEN },
  method: 'POST',
  json: responseJson
}, () => {
    // The user message and bot response(s) must be logged in the same document
    messengerLogger.logDocument(requestBody, responseJson, (e, r) => {
        if (e) {
          console.log('Botmeter error: ', e);
        } else {
          console.log('Botmeter logging: ', r);
        }
    })
});

With Bot builder

We provide a middleware that you can easily plug to Microsoft bot builder (see right pane).

const BotmeterLogger = require('botmeter-logger');
const builder = require('botbuilder');
const restify = require('restify');

// Create a server
const server = restify.createServer();
server.listen(process.env.PORT || 3978, function () {
  console.log('%s listening to %s', server.name, server.url);
});

// Instantiate the Bot builder connector and bot
const connector = new builder.ChatConnector({
  // can be left undefined when testing with emulator
  appId: process.env.MICROSOFT_APP_ID,
  // can be left undefined when testing with emulator
  appPassword: process.env.MICROSOFT_APP_PASSWORD,
});

const bot = new builder.UniversalBot(connector);

// Instantiate Bot builder logger
const builderLogger = new BotmeterLogger({
  appId: '<APP_ID>',
  appKey: '<APP_KEY>',
}).botbuilder;

// Plug it
server.post('/api/messages', connector.listen());

bot.use(builderLogger);

bot.dialog('/', (session) => session.send('Hello World'));

License

See the LICENSE file.