Node Slack SDK
Visit the full documentation for all the lovely details.
So you want to build a Slack app with Node.js? We've got you covered. This package is aimed at making building Slack apps ridiculously easy. It helps you build on all aspects of the Slack platform, from dropping notifications in channels to fully interactive bots.
Upgrading from version 3? The migration guide has all the information you need to bring your app up to speed.
This package supports Node v6 and higher. It's highly recommended to use the latest LTS version of node, and the documentation is written using syntax and features from that version.
Use npm to install the package and save it to your
$ npm install @slack/client
The Slack platform offers several APIs to build apps. Each API delivers part of the capabilities from the platform, with a range of complexity and functionality, so that you can pick the one that fits for your app.
|Slack API||Outgoing||Incoming||NPM Package||Documentation|
Just starting out? We suggest starting at the Getting Started guide which will walk you through building your first Slack app using Node.js.
Building a workspace app? The
WebClient can automatically handle token rotation for your app. Learn more about why you should enable token expiration (hint: its required for App Directory distribution).
Posting a message with Web API
Your app will interact with the Web API through the
WebClient object, which a top level export
from this package. At a minimum, you need to instantiate it with a token. The example below shows
how to post a message into a channel, DM, MPDM, or group. This will require either the
const WebClient = ;// An access token (from your Slack app or custom integration - xoxa, xoxp, or xoxb)const token = processenvSLACK_TOKEN;const web = token;// This argument can be a channel ID, a DM ID, a MPDM ID, or a group IDconst conversationId = 'C1232456';// See:webchat;
Posting a message with the Real-Time Messaging API
Your app will interact with the RTM API through the
RTMClient object, which is a top level
export from this package. At a minimum, you need to instantiate it with a token, usually a
const RTMClient = ;// An access token (from your Slack app or custom integration - usually xoxb)const token = processenvSLACK_TOKEN;// The client is initialized and then started to get an active connection to the platformconst rtm = token;rtmstart;// This argument can be a channel ID, a DM ID, a MPDM ID, or a group IDconst conversationId = 'C1232456';// The RTM client can send simple string messagesrtm;
Posting a message with Incoming Webhooks
Incoming webhooks are an easy way to send notifications
to a Slack channel with a minimum of setup. You'll need a webhook URL from a Slack app or a custom
integration to use the
const IncomingWebhook = ;const url = processenvSLACK_WEBHOOK_URL;const webhook = url;// Send simple text to the webhook channelwebhook;
If you get stuck, we're here to help. The following are the best ways to get assistance working through your issue:
- Issue Tracker for questions, feature requests, bug reports and general discussion related to this package.
- Email us in Slack developer support:
- Bot Developers Hangout: a Slack community for developers building all types of bots. You can find the maintainers and users of this package in #sdk-node-slack-sdk.