Generic

You can use Botmeter whatever your implementation, as long as you are able to call the API.

curl -X POST 'https://api.botfuel.io/botmeter/' \
  -H 'Content-Type: application/json' \
  -H "App-Id: $BOTFUEL_APP_ID" \
  -H "App-Key: $BOTFUEL_APP_KEY" \
  -d '{
    "body": "Hello",
    "responses": [
      "Hi !",
      "How are you ?"
    ],
    "bot_version": "0.0.2",
    "timestamp": 1491475013000,
    "body_type": "text",
    "intent": {
      "score": 0.8,
      "name": "Greetings"
    },
    "user": {
      "first_name": "John",
      "last_name": "Doe"
    },
    "state_out": "Root",
    "user_id": "JohnDoe",
    "state_in": "Root",
    "channel": "Webchat"
  }'

# Body will equal 'ok' if logging is successful

We also provide a generic wrapper in Node.js.

To use it, install botmeter-logger:

npm install --save botmeter-logger
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
  ...
});