# slack-devkit

> A Slack developer kit to make building distributed Slack apps easy.

Latest version **1.2.3** (published 2018-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install slack-devkit
pnpm add slack-devkit
yarn add slack-devkit
bun add slack-devkit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2018-10-05 |
| First published | 2018-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.14.4 |
| Dependencies | 0 |
| Unpacked size | 255.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | John Agan |
| Maintainers | johnagan |
| Keywords | slack, router, express, middleware, serverless, lambda, sdk, bot |

## Links

- npm: https://www.npmjs.com/package/slack-devkit
- Repository: https://github.com/johnagan/slack-devkit
- Issues: https://github.com/johnagan/slack-devkit/issues
- npm.io page: https://npm.io/package/slack-devkit

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.2.3 (latest) — 2018-10-05
- 1.2.2 — 2018-09-16
- 1.2.1 — 2018-09-04
- 1.2.0 — 2018-09-04
- 1.1.4 — 2018-08-30
- 1.1.3 — 2018-08-28
- 1.1.2 — 2018-08-27
- 1.1.1 — 2018-08-27
- 1.0.3 — 2018-08-17
- 1.0.2 — 2018-08-15
- 1.0.1 — 2018-08-13

## README

![](https://cl.ly/3V2e321C0D00/logo-black.png)

# Slack DevKit

Slack DevKit is a light-weight developer kit to build [Slack Apps](https://api.slack.com/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](https://glitch.com) even faster, but it works everywhere!

Learn more on [SlackDevKit.com](https://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

- [App](./src/core/app.js) - The Slack App
- [Request](./src/core/request.js) - The request made from Slack
- [Client](./src/core/client.js) - Minimal HTTPS client (to call other APIs)
- [Payload](./src/core/payload.js) - Wrapper for Slack payloads (to standardize attributes)
- [Router](./src/server/router.js) - An [Express.js](https://expressjs.com/) router (middleware)
- [Express](./src/server/express.js) - An [Express.js](https://expressjs.com/) instance with the router attached
- [Lambda](./src/server/lambda.js) - An [AWS Lambda](https://aws.amazon.com/lambda/) AWS Lambda handler
- [FileStore](./src/datastore/filestore.js) - File-based storage to save workspace information
- [DynamoDB](./src/datastore/dynamodb.js) - DynamoDB storage to save workspace information

### Examples

| File                                                          | Description                                                                                                 |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| [features.js](./examples/features.js)                         | Examples of some common Slack App features                                                                  |
| [internal-integration.js](./examples/internal-integration.js) | Example configuration of an [internal integrations](https://api.slack.com/slack-apps#internal_integrations) |
| [storing-data.js](./examples/storing-data.js)                 | Example of storing and retrieving data from the datastore                                                   |
| [express.js](./examples/express.js)                           | Example of adding Slack DevKit to an exiting [Express.js](https://expressjs.com/) server                    |
| [lambda.js](./examples/lambda.js)                             | Using Slack DevKit with AWS Lambda and DynamoDB                                                             |

## Getting Started

### Install

```
npm i slack-devkit
```

### Usage

```javascript
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

| Name                 | Type     | Description                                                                                                      |
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------- |
| `scope`              | Required | [Slack OAuth scopes](https://api.slack.com/docs/oauth#step_1_-_sending_users_to_authorize_and_or_install)        |
| `client_id`          | Required | [Slack OAuth client id](https://api.slack.com/docs/oauth#step_1_-_sending_users_to_authorize_and_or_install)     |
| `client_secret`      | Required | [Slack OAuth client secret](https://api.slack.com/docs/oauth#step_1_-_sending_users_to_authorize_and_or_install) |
| `redirect_uri`       | Optional | [Slack OAuth redirect uri](https://api.slack.com/docs/oauth#step_1_-_sending_users_to_authorize_and_or_install)  |
| `signing_secret`     | Optional | [Slack signing secret](https://api.slack.com/docs/verifying-requests-from-slack#about)                           |
| `verification_token` | Optional | [Slack verification token](https://api.slack.com/events-api#url_verification)                                    |
| `access_token`       | Optional | Access token for [internal integrations](https://api.slack.com/slack-apps#internal_integrations)                 |
| `slack_root`         | Optional | Root domain to use for Slack requests                                                                            |
| `datastore`          | Optional | File path to write to or a DataStore object                                                                      |

---
_Source: https://npm.io/package/slack-devkit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
