Configuration

This document covers all you need to know to configure your bot. Regarding credentials, refer to Getting started.

Configuration files

A configuration file is a .js file exporting a configuration object:

module.exports = {
  ...
};

It is passed as an argument to a command (train, run or test):

 yarn run  

Note that you can omit the .js extension when passing the config file name to the bot command.

Configuration files allow you to configure many parts and behaviors of the bot.

Adapter

The adapter is configured using the adapter key. It defaults to 'shell'. Its possible values are:

  • 'shell' (shell adapter)
  • 'test' (test adapter)
  • 'messenger' (Facebook Messenger adapter)
  • 'botfuel' (see Botfuel Webchat for more details about the webchat)

Brain

The brain is configured using brain key. It defaults to 'memory'. Its possible values are:

  • 'memory' (non persistent in-memory brain)
  • 'mongo' (MongoDB brain)

Conversations duration

The duration of a conversation is the limit beyond which a new conversation is automatically created by the bot.

Its default value is 86400000ms (1 day).

To change this value, add the entry conversationDuration: <maximal duration in ms> to your config file.

Intent threshold

The intent threshold is used by the Natural Language Understanding component. It is configured using the intentThreshold key. It defaults to 0.8.

Locale

The locale is configured using the locale key. It defaults to 'en'. Its possible values are:

  • 'en'
  • 'fr'
  • 'es'

Logging

Botfuel Dialog uses the Logtown logging facade together with the Winston logger.

The logger is configured using logger key. It defaults to the 'info' logger. This logger only logs messages with severity greater than or equal to 'info'.

Pre-configured loggers

Botfuel Dialog comes with 3 pre-configured loggers:

  • 'debug'
  • 'info'
  • 'error'

Custom loggers

It is also possible to define your own logger.

For example, let's define a logger that mutes the brain of the bot. Simply add logger: 'mute' to your config file and, under the root of the bot, a file loggers/mute.js with the following content:

const WinstonWrapper = require('logtown-winston');
const winston = require('winston');

const transports = [
  new winston.transports.Console({
    json: false,
    colorize: true,
    prettyPrint: true,
    timestamp: true,
    handleExceptions: true,
    align: false,
    level: 'debug',
  }),
];

const options = {
  exitOnError: false,
};

module.exports = {
  wrapper: new WinstonWrapper(transports, options),
  config: {
    namespaces: {
      Brain: {
        disable: ['debug'],
      },
      MongoBrain: {
        disable: ['debug'],
      },
      MemoryBrain: {
        disable: ['debug'],
      },
    },
  },
};

Multi-intent detection

Enabling multi-intent detection is done with the multiIntent key. It expects a boolean value and defaults to false (multi-intent detection is disabled by default).

QnA

Botfuel provides an easy-to-use Questions and Answers module.

To integrate it in your bot, add qna: {} to your config file.

You can further configure QnA:

  • when determines whether the QnA classification runs after the bot's own classification or before, with corresponding values 'after' and 'before', it defaults to 'after'
  • strict determines whether the QnA returns only a single answer (true) or up to 3 answers (false), it defaults to false

Following is a complete configuration of the QnA module:

module.exports = {
  qna: {
    when: 'after',
    strict: true,
  },
};

Spellchecking

Botfuel provides a spell checking API.

To enable it in your bot, simply add spellchecking: '<dictionnary key>' to your config file.