trailpack-chatbot

2.0.8 • Public • Published

trailpack-chatbot

📦 Trailpack to create chatbot under your Trails projects

Gitter Known Vulnerabilities NPM version Linux + OSX Build Status Code Climate Follow @trailsjs on Twitter

Intallation

With yo :

npm install -g yo generator-trails
yo trails:trailpack trailpack-chatbot

With npm (you will have to create config file manually) :

npm install --save trailpack-chatbot

Compatibility

This Trailpack is compatible with Sequelize trailpack-sequelize.

Usage

Load in your trailpack config.

// config/main.js
module.exports = {
  // ...
  packs: [
    require('trailpack-core'),
    // ...
    require('trailpack-cache'),
    require('trailpack-chatbot')
  ]
}

Dependencies

In order to work you need to install and configure trailpack-cache with a memory store

It's needed to keep in cache the last answer of the user and his context to calculate the next action

Config

Setup your bots.

// config/chatbot.js
module.exports = {
  bots: {}, // put you bots definitions here (see example below)
  allowAnonymousUsers: false, // allow to use basic chatbot command (no nested states for unlogged user
  defaultAnswer: (app, data) => { // set a default answer when no bot recognize the sentence
    data.action = 'UNKNOWN'
    return Promise.resolve(data)
  },
  hooks: {} // set some hooks on bot states to add/modify the bot response 
}
 
// config/caches.js minimum config
module.exports = {
  stores: [
      {
        name: 'chatbot',
        type: 'memory',
        ttl: 0
      }
    ] 
}

Default config here

Full example of bot here

Contributing

We love contributions! Please check out our Contributor's Guide for more information on how our projects are organized and how to get started.

License

MIT

Package Sidebar

Install

npm i trailpack-chatbot

Weekly Downloads

1

Version

2.0.8

License

MIT

Last publish

Collaborators

  • jaumard