Node Integration

Integrate with Dimension Labs using a Node integration

Create an API key

Check out this page on how to generate you dimension API keys.


Install Dimension Labs via NPM

npm install --save dimensionlabs

Include Dimension Labs

Use the API key created above.

const dimension = require('dimensionlabs')(process.env.DIMENSION_API_KEY).universal;

Notice above, we assume you have set an environment variable DIMENSION_API_KEY with your api key.


Whenever your bot sends, or receives data, log to Dimension Labs

See below for an example:

Log whenever your webhook is called

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

dimension.logIncoming(messageForDimension);

Whenever you send a message, log the response

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

dimension.logOutgoing(messageForDimension);

Example

View sample code.