Skip to content

Simple module for implementing a chatbot. (EXPERIMENTAL STAGE)

License

Notifications You must be signed in to change notification settings

Hexastack/sails-hook-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sails-hook-chatbot

Simple module for implementing a chatbot.

Installation

  1. First you need to setup a new sails project :
sails new myChatbot
  1. Go inside your project and install sails-hook-chatbot :
cd myChatbot
npm install sails-hook-chatbot --save
  1. You will need to add the following config/chatbot.js :
module.exports.chatbot = {
  handler: 'messenger',
  messenger: {
    appSecret: "...",
    accessToken: "...",
    verifyToken: "..."
  }
};

Please note that for now only Facebook Messenger handler is available :

  1. In order to teach your chatbot what to say/do, you will need to create a new hook. As a starting example, you can create a file under api/hooks/hello/index.js containing :
module.exports = function(sails) {

  return {
    initialize: function(cb) {
    
      // Add the script breakdown to the Chatbot instance (Service)
      Chatbot.hear(['hello', 'hi', /hey( there)?/i], function(payload, chat) {
        // Send a text message followed by another text message that contains a typing indicator
        chat.say('Hello, human friend!').then(function() {
          chat.say('How are you today?', {
            typing: true
          });
        });
      });
      
      return cb();
    }
  }
};

See the "examples" folder for more about the usage.

Coming soon

Our next priority is to implement a default handler that allows a simple XHR/WebSocket interactions. Next may come is a adding slack support ...

License

MIT

Credits

Freeways/messenger-bot-sails Boiletplate has been a starting point for this project. The messenger handler's source code is a modified version of Charca/bootbot which is a powerful JavaScript Framework to build Facebook Messenger's Chat bots. Special thanks to Maxi Ferreira !

About

Simple module for implementing a chatbot. (EXPERIMENTAL STAGE)

Resources

License

Stars

Watchers

Forks

Packages

No packages published