How to use the node-wit.log.Logger function in node-wit

To help you get started, we’ve selected a few node-wit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SnowStormIO / botkit-witai / src / botkit-witai.js View on Github external
module.exports = function (options) {

  if (!options || !options.accessToken) {
    throw new Error('No wit.ai Access Token specified');
  }

  options.minConfidence = options.minConfidence || 0.5;

  options.logLevel = options.logLevel ? (logLevels.indexOf(options.logLevel) !== -1 ? options.logLevel : "debug") : null;

  const params = {
    accessToken: options.accessToken
  }

  if (options.logLevel){
    params.logger = new log.Logger(options.logLevel);
  }

  const client = new Wit(params);

  const middleware = {};

  middleware.receive = function (bot, message, next) {

    //Avoid text payload generated by buttons in Facebook Messenger
    if (message.text && message.text.indexOf("_") == -1 && !message.payload && !message.attachments && !message.quick_reply) {
      client.message(message.text)
        .then((data) => {
        console.log('Wit.ai response: ' + JSON.stringify(data));
        message.entities = data.entities;
        next();
      })

node-wit

Wit.ai Node.js SDK

Unrecognized
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis