How slackapi/node-slack-sdk works
1. This repository is a monorepo for the Node Slack SDK, organized as several publishable packages under packages/. Each package has its own package.json, source, tests, and TypeDoc config, so the main architectural boundary is by Slack API surface rather than by deployment tier.
2. The core product packages map directly to Slack communication modes:
- @slack/web-api for HTTPS/REST calls to Slack’s Web API
- @slack/socket-mode for receiving events over Slack’s WebSocket-based Socket Mode
- @slack/rtm-api for the legacy RTM WebSocket API
- @slack/oauth for installation and token exchange flows
- @slack/webhook for outgoing message delivery via incoming webhooks
3. @slack/web-api is the largest subsystem and is the main outbound data plane. It exposes WebClient, which routes method calls into Slack API requests, handles retries and error typing, and includes special paths for file upload and chat streaming. Its src/types/request and src/types/response trees define the request/response shape for the many Slack methods, while src/methods.ts and generated type files provide the method surface.
4. @slack/socket-mode and @slack/rtm-api are the inbound real-time subsystems. Both manage long-lived WebSocket connections to Slack, but Socket Mode is the newer event delivery mechanism while RTM is the older chat/event stream. These packages encapsulate connection lifecycle, message acking/reply behavior, and recoverable vs unrecoverable connection errors.
5. @slack/oauth handles app installation and authorization as a stateful flow. It includes installation and state stores, support for file-backed or in-memory persistence, install URL generation, callback handling, and HTML rendering for install routes. The main data flow is: install request -> state generation/store -> Slack authorization redirect -> callback validation -> token/installation persistence.
6. @slack/webhook is the simplest boundary: it sends a single payload to a Slack-provided webhook URL over HTTP. It is intentionally narrow and stateless compared with the other packages.
7. @slack/types is the shared schema layer. It contains the canonical TypeScript models for blocks, events, messages, views, chunks, and other Slack payloads. The rest of the SDK depends on these types to keep API surfaces consistent across packages and to centralize Slack object definitions.
8. @slack/logger is a small cross-cutting utility package. It standardizes logging interfaces and log levels used by the client packages, rather than introducing a heavyweight shared runtime or framework.
9. packages/cli-test and packages/cli-hooks are support tooling rather than end-user SDK surfaces. cli-test provides a programmable CLI test harness and command wrappers, while cli-hooks supplies local hooks/doctor/start helpers for package development and validation.
10. The repository includes live validation infrastructure in prod-server-integration-tests/. That area contains Slack app manifests, scripts, and end-to-end tests that exercise the published packages against real Slack servers, so it serves as the architecture’s external-system verification layer.
11. examples/ shows how the packages are composed in real applications, with examples for Socket Mode and OpenID Connect. docs/english/ is the published documentation tree, including API reference, migration guides, and getting-started material, which reflects the package boundaries exposed to consumers.
12. Tooling and automation are part of the repo’s operational architecture: TypeScript is the primary implementation language, Node v18+ is the runtime baseline, Biome handles code style, and GitHub Actions drive CI, dependency updates, release, and issue triage. The scripts/ directory also contains code generation for the Web API type surface, which is important because much of the SDK’s method and type coverage is generated rather than handwritten.
Main entry points: web-api Web API · socket-mode Socket Mode · english Docs · types Types
Components 19
Packages
Publishable SDK packages and shared libraries.
- Web API · Primary outbound Slack API client over HTTPS.
packages/web-api - WebClient · Routes Slack method calls, retries, errors, uploads, and chat streaming.
packages/web-api/src/WebClient.ts - Methods · Method surface and generated call signatures.
packages/web-api/src/methods.ts - Req/Resp types · Request and response type trees for Slack Web API methods.
packages/web-api/src/types - Socket Mode · Newer inbound event delivery over Slack WebSockets.
packages/socket-mode - SocketModeClient · Manages Socket Mode connection lifecycle, acking, and recoverable errors.
packages/socket-mode/src/SocketModeClient.ts - RTM API · Legacy real-time Slack chat/event stream over WebSockets.
packages/rtm-api - RTMClient · Manages RTM connection lifecycle, replies, and connection errors.
packages/rtm-api/src/RTMClient.ts - OAuth · Installation, authorization, state, and token exchange flow.
packages/oauth - InstallProvider · Generates install URLs, handles callbacks, validates state, and persists installations.
packages/oauth/src/install-provider.ts - Webhook · Sends a single payload to a Slack incoming webhook URL.
packages/webhook - IncomingWebhook · Narrow stateless HTTP sender for incoming webhooks.
packages/webhook/src/IncomingWebhook.ts - Types · Canonical Slack payload models shared across packages.
packages/types - Logger · Shared logging interface and log levels used by client packages.
packages/logger
Tooling
Repo automation, docs, examples, and validation.
- Examples · Reference apps demonstrating package composition.
examples - Prod tests · End-to-end validation against real Slack servers and manifests.
prod-server-integration-tests - Scripts · Code generation and release/build automation, including Web API type generation.
scripts - Docs · Published documentation tree aligned to the package boundaries.
docs/english
Other components
- Node Slack SDK · Top-level monorepo for the Slack SDK packages.
Connections 35
- Node Slack SDK → Web API: contains
- Node Slack SDK → Socket Mode: contains
- Node Slack SDK → RTM API: contains
- Node Slack SDK → OAuth: contains
- Node Slack SDK → Webhook: contains
- Node Slack SDK → Types: contains
- Node Slack SDK → Logger: contains
- Web API → WebClient: implements
- Web API → Methods: defines
- Web API → Req/Resp types: shapes
- Web API → Types: depends on
- Web API → Logger: uses
- Socket Mode → SocketModeClient: implements
- Socket Mode → Types: depends on
- Socket Mode → Logger: uses
- RTM API → RTMClient: implements
- RTM API → Types: depends on
- RTM API → Logger: uses
- OAuth → InstallProvider: implements
- OAuth → Types: depends on
- OAuth → Logger: uses
- Webhook → IncomingWebhook: implements
- Webhook → Logger: uses
- Examples → Socket Mode: shows
- Examples → OAuth: shows
- Prod tests → Web API: verifies
- Prod tests → Socket Mode: verifies
- Scripts → Web API: generates
- Scripts → Types: generates
- Docs → Web API: documents
- Docs → Socket Mode: documents
- Docs → RTM API: documents
- Docs → OAuth: documents
- Docs → Webhook: documents
- Docs → Types: documents