1.2.3 • Published 6 years ago

slack-devkit v1.2.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

npm.io

Slack DevKit

Slack DevKit is a light-weight developer kit to build Slack Apps in node.js super fast. No previous knowledge about building Slack Apps or Bots needed! Plus, automatic support for verifying requests from Slack and responding to validations.

This was made to build Slack Apps on Glitch even faster, but it works everywhere!

Learn more on SlackDevKit.com

Overview

Features

  • OAuth support without 3rd-party database
  • Supports Single Channel Installations
  • Verifies request signatures and/or verification tokens
  • Support for short-lived tokens with automatic refresh
  • Automatic retrieval of workspace's authentication info
  • Auto-parsing of string-encoded JSON payloads
  • Authenticated HTTP client for Slack's API
  • Writeable datastore associated to the workspace

What's Included

Examples

FileDescription
features.jsExamples of some common Slack App features
internal-integration.jsExample configuration of an internal integrations
storing-data.jsExample of storing and retrieving data from the datastore
express.jsExample of adding Slack DevKit to an exiting Express.js server
lambda.jsUsing Slack DevKit with AWS Lambda and DynamoDB

Getting Started

Install

npm i slack-devkit

Usage

const Slack = require('slack-devkit');

// Configure express with the Slack App settings
const { server } = new Slack({
  scope: 'chat:write,bot',
  client_id: '1212313.1231231231231',
  client_secret: '12312312323123123',
  signing_secret: 'sdfsadfsadfasdfas',
  redirect_uri: 'https://myserver.com', // optional
  datastore: '.data/workspaces' // optional
});

// All GET routes redirect to the “Add to Slack” OAuth flow
server.get('/', (req, res) => {
  req.slack.data; // the authenticated workspace info
  res.send();
});

// All POST routes expect Slack callback events
// and verify against the verification token
server.post('/', (req, res) => {
  const user = req.slack.user_id;
  req.slack.api('users.info', { user }).then(r => {
    r.data; // the results of 'users.info' API request
  });
  res.send();
});

// Start the webserver on port 3000
server.start(3000);

Configuration

The configuration options used for the constructor

NameTypeDescription
scopeRequiredSlack OAuth scopes
client_idRequiredSlack OAuth client id
client_secretRequiredSlack OAuth client secret
redirect_uriOptionalSlack OAuth redirect uri
signing_secretOptionalSlack signing secret
verification_tokenOptionalSlack verification token
access_tokenOptionalAccess token for internal integrations
slack_rootOptionalRoot domain to use for Slack requests
datastoreOptionalFile path to write to or a DataStore object
1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago