2.0.0 • Published 9 years ago

slack-commander v2.0.0

Weekly downloads
3
License
-
Repository
github
Last release
9 years ago

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' });
2.0.0

9 years ago

1.1.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago