slack-commander

2.0.0 • Public • Published

node-slack-commander

NPM

Build Status

Listen for Slack Slash Commands

var express = require('express'),
  bodyParser = require('body-parser'),
  slackCommander = require('slack-commander');

module.exports = function () {
  var app = express();

  app.use('/slack', slackCommander.router({
    token: 'SLACK_SLASH_COMMAND_TOKEN',
    commands: 'HASH_OF_SUPPORTED_COMMANDS'
  }));

  return app;
};

Example Command Hash

Commands are expected to return promises.

var Promise = require('bluebird'),
  commands = {
    reverse: function (command, input) {
      return Promise.resolve()
        .then(function () {
          var reversed = input.split('').reverse().join('');
          // ... use messenger to log this back to a chat
          return;
        });
    },
    echo: function (command, args) {
      return Promise.resolve()
        .then(function () {
          // ... use messenger to log this back to a chat
          return;
        });
    }
  }

Send Messages to a Slack Room

var slackCommander = require('slack-commander'),
  options = {
    username: 'Lanetix',
    webhookUrl: 'WEBHOOK_URL'
  },
  messenger = slackCommander.messenger(options);

  messenger.send('i can haz messages', { channel: '#cats' });

Readme

Keywords

none

Package Sidebar

Install

npm i slack-commander

Weekly Downloads

0

Version

2.0.0

License

none

Last publish

Collaborators

  • sharmarakesh
  • showvhick-winmore
  • arpit1024
  • rahulbharadwaj
  • jasif-wm
  • sidharth.n
  • renjith_ram_qburst
  • jyothis-qb
  • cdrohithmqb
  • dheerajds
  • arjunqb
  • lanetix-system
  • manu-kodiyan-winmore
  • dnm-winmore
  • mkdyanugk
  • vigneshk7
  • aswanth
  • sajith.qb
  • dhiluraj-qburst