Webchat Node.js 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')(<strong>process.env.DASHBOT_API_KEY</strong>).webchat;

Whenever your bot sends or receives data, log to Dashbot

You can send the following fields:

Log whenever you receive a message:

const messageForDashbot = {
  "text": "Hi, bot",
  "userId": "USERIDHERE123123",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here"
  }
};

dashbot.logIncoming(messageForDashbot);

Log whenever you send a message:

const messageForDashbot = {
  "text": "Hello, my human pet",
  "userId": "USERIDHERE123123",
  "platformJson": {
    "whateverJson": "any JSON specific to your platform can be stored here"
  }
};

dashbot.logOutgoing(messageForDashbot);