0.1.0 • Published 8 years ago

slack-integrator v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

Build Status

node-slack-integrator

A very simple Express-based server for creating Slack integrations.

node-slack-integrator runs an Express server with an /integration endpoint.

How to use

  1. Log into your Slack and configure a slash command integration that posts to <your-integration-host.com>/integration when a Slack user enters /some command.

  2. Deploy a node-slack-integrator instance to <your-integration-host.com>. Your node-slack-integrator instance should be instantiated with a payload method & a hookPath property.

The payload method receives Slack's post request and generates the appropriate payload your integration should post in your Slack.

The hookPath property specifies the unique part of your Slack hook endpoint. This can be found in your Slack's admin.

Example

// slack_integration.js
var Integrator = require('slack-integrator');

new Integrator({
  // a 'payload' method to generate a Slack-formatted payload object
  // this method receives the request Slack issues to your integration
  // in response to a user's `/command`, as well as a callback called
  // with the Slack-formatted payload object
  payload: function(request, callback) {
    // this should return the payload object containing the
    // data you wish to display in Slack
    // see Slack documentation regarding its format

    // example:
    callback({
      username: 'my bot',
      text: 'some text',
      channel: request.body.channel_id,
      icon_emoji: ':ghost:'
    });
  },

  // optional; if set, this ensures against requests from un-authorized Slacks
  token: 'the token provided by your Slack instance',

  // https://hooks.slack.com/services/<YOUR_HOOK_PATH>
  hookPath: 'the path to your Slack instance's hook endpoint'
});

Running node slack_integration.js runs an Express app at port 3000. Port 3000 can be overridden via a PORT environment variable, or by a port declared on the options object passed to your integrator during instantiation.

The slack integration instance's /integration endpoint can be used to receive slash command-prompted POST requests from Slack.

0.1.0

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago