easy-slack-bot

Easy Slack bot package.

Usage no npm install needed!

<script type="module">
  import easySlackBot from 'https://cdn.skypack.dev/easy-slack-bot';
</script>

README

easy-slack-bot

Node.js based, modular Slack bot framework.

NPM Version Linux Build Windows Build Dependency Status devDependency Status Codecov coverage

INSTALLATION

$ npm install easy-slack-bot --save

EXAMPLE

See sample files in "example" directory.

USAGE

Simple index.js:

var SlackBot = require("easy-slack-bot"),
    BotItems = __dirname + "/items",
    BotOptions = {
        Slack: {
            SLACK_TOKEN: "slack-bot-token"
        }
    };

new SlackBot(BotItems, BotOptions);

Simple items/hello.js item:

module.exports = function( bot )
{
    // https://api.slack.com/methods/chat.postMessage
    var params = {
        icon_emoji: ':robot_face:'
    };

    return 
    {
        // Get message
        // https://rawgit.com/sipimokus/easy-slack-bot/master/docs/interfaces/islackbotsmessage.html
        // https://rawgit.com/sipimokus/easy-slack-bot/master/docs/interfaces/iitemsonmessagecallback.html
        message: function( message, callBack ) 
        {
            // Detecting word in message
            if ( message.natural.indexOf("hello") > -1 ) 
            {
                // Answer message
                callBack("Hello world!", params);

                return true;
            }

            return false;
        }
    };
};

DOCUMENTATION

Source code documentation find here.