@vercel/slack-bolt 1.7.2 → 2.0.0-canary.20261021155202.7aaad09

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,24 +9,26 @@ A custom [Slack Bolt](https://slack.dev/bolt-js/) receiver built for Vercel's [F
9
9
 
10
10
  Visit our [template](https://vercel.com/templates/backend/slack-bolt-with-nitro) to get started building a Slack app. If you are building an agent we recommend the [eve](https://eve.dev) framework. You can find the eve template [here](https://github.com/vercel/eve-examples/tree/main/eve-slack-agent-template).
11
11
 
12
+ Upgrading from v1? See [Migrating from v1](#migrating-from-v1).
13
+
12
14
  ## Installation
13
15
 
14
16
  ```bash
15
- npm install @vercel/slack-bolt
17
+ npm install @vercel/slack-bolt @slack/bolt
16
18
  # or
17
- yarn add @vercel/slack-bolt
19
+ yarn add @vercel/slack-bolt @slack/bolt
18
20
  # or
19
- pnpm add @vercel/slack-bolt
21
+ pnpm add @vercel/slack-bolt @slack/bolt
20
22
  # or
21
- bun add @vercel/slack-bolt
23
+ bun add @vercel/slack-bolt @slack/bolt
22
24
  ```
23
25
 
24
26
  ### Compatibility
25
27
 
26
- | Dependency | Supported versions |
27
- | ------------- | ------------------- |
28
- | `@slack/bolt` | `^4.4.0` or `^5.0.0` |
29
- | Node.js | `>=22` |
28
+ | Dependency | Supported versions |
29
+ | ------------- | -------------------- |
30
+ | `@slack/bolt` | `^4.7.3` or `^5.0.0` |
31
+ | Node.js | `>=22.12` |
30
32
 
31
33
  `@slack/bolt` is a peer dependency, so declare it in your own `package.json` alongside this package. Do not install with `--legacy-peer-deps`: Bolt 5's `@slack/socket-mode` declares `undici` as a peer, and skipping peers makes `require('@slack/bolt')` fail with `Cannot find module 'undici'`.
32
34
 
@@ -34,20 +36,21 @@ bun add @vercel/slack-bolt
34
36
 
35
37
  ### `VercelReceiver`
36
38
 
37
- Responsible for handling and parsing any incoming requests from Slack and then forwarding them to your Bolt app for event processing.
39
+ A Bolt receiver for Vercel Functions. It extends Bolt's `HTTPReceiver`: your route passes it each request, it answers Slack as soon as your listener calls `ack()`, and [`waitUntil`](https://vercel.com/docs/functions/functions-api-reference/vercel-functions-package#waituntil) keeps the listeners running after the response.
38
40
 
39
- This example shows a single-tenant app with a fixed bot token. For multi-tenant apps that need OAuth, see [OAuth](#oauth-multi-tenant-apps) below.
41
+ This example shows a single-workspace app with a fixed bot token. For an app that other workspaces install, see [OAuth](#oauth-multi-workspace-apps) below.
40
42
 
41
43
  ```typescript
44
+ // lib/slack.ts
42
45
  import { App } from "@slack/bolt";
43
46
  import { VercelReceiver } from "@vercel/slack-bolt";
44
47
 
45
48
  const receiver = new VercelReceiver();
46
49
 
47
50
  const app = new App({
48
- token: process.env.SLACK_BOT_TOKEN,
49
- signingSecret: process.env.SLACK_SIGNING_SECRET,
50
51
  receiver,
52
+ token: process.env.SLACK_BOT_TOKEN,
53
+ // Checks the token on the first event, and again if that fails.
51
54
  deferInitialization: true,
52
55
  });
53
56
 
@@ -55,129 +58,45 @@ app.message(/^(hi|hello|hey).*/, async ({ say }) => {
55
58
  await say("Hello, world!");
56
59
  });
57
60
 
58
- export { app, receiver };
61
+ export const { POST } = receiver;
59
62
  ```
60
63
 
61
- #### Parameters
62
-
63
- | Name | Type | Default Value | Required | Description |
64
- | --------------------------- | ------------------------------------------------------ | ---------------------------------- | -------------- | ----------------------------------------------------------------------- |
65
- | `signingSecret` | `string` | `process.env.SLACK_SIGNING_SECRET` | No<sup>1</sup> | Signing secret for your Slack app used to verify requests. |
66
- | `signatureVerification` | `boolean` | `true` | No | Enable or disable request signature verification. |
67
- | `logger` | `Logger`<sup>2</sup> | `new ConsoleLogger()` | No | Logger used for diagnostics. |
68
- | `logLevel` | `LogLevel`<sup>2</sup> | `LogLevel.INFO` | No | Minimum log level for the logger. |
69
- | `customPropertiesExtractor` | `(req: Request, body: StringIndexed) => StringIndexed` | `undefined` | No | Return value is merged into Bolt event `customProperties`<sup>2</sup>. |
70
- | `beforeProcess` | `BeforeProcessFn` | `undefined` | No | Intercept requests before Bolt processing. |
71
- | `ackTimeoutMs` | `number` | `3001` | No | Milliseconds to wait for `ack()` before returning a timeout error. |
72
- | `clientId` | `string` | `process.env.SLACK_CLIENT_ID` | No<sup>3</sup> | Your app's client ID (required for OAuth). |
73
- | `clientSecret` | `string` | `process.env.SLACK_CLIENT_SECRET` | No<sup>3</sup> | Your app's client secret (required for OAuth). |
74
- | `stateSecret` | `string` | `process.env.SLACK_STATE_SECRET` | No<sup>3</sup> | Secret for OAuth CSRF state parameter. |
75
- | `scopes` | `string[] \| ScopesResolver` | `undefined` | No | Bot scopes for OAuth. Can be a function for dynamic scopes. |
76
- | `redirectUri` | `string` | `undefined` | No | Redirect URI registered with your Slack app. |
77
- | `installationStore` | `InstallationStore`<sup>2</sup> | `undefined` | No<sup>4</sup> | Persistent storage backend for OAuth installations. |
78
- | `installerOptions` | `VercelInstallerOptions` | `{}` | No | Advanced OAuth options (user scopes, direct install, state store, etc). |
79
-
80
- <sup>1</sup> Optional if `process.env.SLACK_SIGNING_SECRET` is provided.
81
-
82
- <sup>2</sup> Provided by the [`@slack/bolt`](https://www.npmjs.com/package/@slack/bolt) library. More information [here](https://docs.slack.dev/tools/bolt-js/reference#app-options).
83
-
84
- <sup>3</sup> Required for OAuth. Read from `process.env` automatically if not provided.
85
-
86
- <sup>4</sup> Required for OAuth in serverless environments -- the default in-memory store does not persist across cold starts.
87
-
88
- ### `createHandler`
89
-
90
- A function that returns a Vercel-compatible request handler that will initialize and start your Bolt app to process the event.
91
-
92
64
  ```typescript
93
- // An example using Next.js route handlers
94
-
95
- import { createHandler } from "@vercel/slack-bolt";
96
- import { app, receiver } from "./app";
97
-
98
- export const POST = createHandler(app, receiver);
65
+ // app/api/slack/events/route.ts
66
+ export { POST } from "@/lib/slack";
99
67
  ```
100
68
 
101
- #### Parameters
69
+ Point your Slack app's event subscription, interactivity and slash command URLs at the route. It can live at any path. With `deferInitialization`, the receiver runs `app.init()` on the first request, so nothing calls Slack while your app builds.
102
70
 
103
- | Name | Type | Required | Description |
104
- | ---------- | ----------------- | -------- | ------------------------------------------------------------ |
105
- | `app` | `App`<sup>1</sup> | Yes | Your Bolt app |
106
- | `receiver` | `VercelReceiver` | Yes | The Vercel receiver instance used to process Slack requests. |
71
+ #### Options
107
72
 
108
- <sup>1</sup> Provided by the [`@slack/bolt`](https://www.npmjs.com/package/@slack/bolt) library. More information [here](https://docs.slack.dev/tools/bolt-js/reference#app-options).
73
+ `VercelReceiver` takes Bolt's [`HTTPReceiver` options](https://docs.slack.dev/tools/bolt-js/reference), except `endpoints`, `port`, `customRoutes` and `dispatchErrorHandler`, which configure Bolt's own HTTP server. The ones you're most likely to need:
109
74
 
110
- ## OAuth (Multi-Tenant Apps)
75
+ | Name | Type | Default | Description |
76
+ | ------------------------------- | ---------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------- |
77
+ | `signingSecret` | `string` | `process.env.SLACK_SIGNING_SECRET` | Verifies that requests come from Slack. Required unless `signatureVerification` is `false`. |
78
+ | `signatureVerification` | `boolean` | `true` | Set to `false` to skip signature verification, for example in tests. |
79
+ | `logger` | `Logger` | Bolt's `ConsoleLogger` | Pass it here: Bolt doesn't apply the `App`'s logger to a custom receiver. |
80
+ | `logLevel` | `LogLevel` | `LogLevel.INFO` | Minimum level for the receiver's logger. |
81
+ | `processBeforeResponse` | `boolean` | `false` | Waits for your listeners to finish before answering Slack, instead of answering at `ack()`. |
82
+ | `processEventErrorHandler` | `(args) => Promise<boolean>` | Bolt's default | Handles an error from your listeners. The receiver keeps it running with `waitUntil`. |
83
+ | `unhandledRequestTimeoutMillis` | `number` | `3001` | How long to wait for a listener to call `ack()` before `unhandledRequestHandler` runs. |
84
+ | `unhandledRequestHandler` | `(args) => void` | Logs an error and answers `404` | Answers Slack when no listener calls `ack()` in time. |
85
+ | `customPropertiesExtractor` | `(req) => StringIndexed` | None | Adds properties from the request to each event's `context`. |
111
86
 
112
- `VercelReceiver` has built-in support for Slack's [OAuth v2 flow](https://docs.slack.dev/authentication/installing-with-oauth), allowing your app to be installed by multiple workspaces. For background on how OAuth works with Bolt, see the [Bolt OAuth guide](https://slack.dev/bolt-js/concepts/authenticating-oauth).
87
+ The OAuth options are described in [OAuth](#oauth-multi-workspace-apps).
113
88
 
114
- ### Environment variables
89
+ The constructor throws Bolt's `AppInitializationError` when the signing secret is missing, when `clientId` is set without an `installationStore`, or when `redirectUri` isn't an absolute URL.
115
90
 
116
- Set these in your Vercel project (or `.env.local` for local development):
91
+ #### `receiver.fetch(request)`
117
92
 
118
- | Variable | Description |
119
- | ---------------------- | ------------------------------------------------------------------------------------------------ |
120
- | `SLACK_CLIENT_ID` | App client ID, found under **Basic Information** on [api.slack.com](https://api.slack.com/apps). |
121
- | `SLACK_CLIENT_SECRET` | App client secret, found in the same section. |
122
- | `SLACK_STATE_SECRET` | A random string used to sign the OAuth state parameter. |
123
- | `SLACK_SIGNING_SECRET` | Signing secret for verifying incoming Slack requests. |
124
-
125
- All four are read from `process.env` automatically.
126
-
127
- ### Receiver setup
93
+ Handles a Slack request and resolves with the `Response` once Slack is acknowledged. `receiver.POST` and `receiver.GET` are the same function, for frameworks that route by exported method names. In any other framework, pass the Web `Request` to `receiver.fetch`. See [Frameworks](#frameworks) for Hono, Express, Nitro and TanStack Start.
128
94
 
129
- When using OAuth, the receiver manages token retrieval via the `installationStore` -- you no longer pass `token` or `signingSecret` to the `App` constructor.
95
+ - `POST` requests are events, slash commands and interactions.
96
+ - With the OAuth options, a `GET` with a `code`, `error` or `state` query parameter is the OAuth callback, and any other `GET` is the install page.
97
+ - Anything else gets a `404`.
130
98
 
131
- ```typescript
132
- import { App } from "@slack/bolt";
133
- import { VercelReceiver } from "@vercel/slack-bolt";
134
-
135
- const receiver = new VercelReceiver({
136
- scopes: ["chat:write", "commands"],
137
- installationStore: myInstallationStore,
138
- installerOptions: {
139
- directInstall: true,
140
- },
141
- });
142
-
143
- const app = new App({
144
- receiver,
145
- deferInitialization: true,
146
- });
147
- ```
148
-
149
- ### Route handlers
150
-
151
- Expose two GET routes for the OAuth flow. The paths can be anything -- just make sure the callback path matches the **Redirect URL** in your Slack app settings.
152
-
153
- ```typescript
154
- // app/api/slack/install/route.ts
155
- import { receiver } from "@/bolt/app";
156
-
157
- export const GET = receiver.handleInstall;
158
- ```
159
-
160
- ```typescript
161
- // app/api/slack/oauth-redirect/route.ts
162
- import { receiver } from "@/bolt/app";
163
-
164
- export const GET = receiver.handleCallback;
165
- ```
166
-
167
- ### Installation store
168
-
169
- An `installationStore` is required in serverless environments. The default in-memory store does not survive cold starts, so each new function invocation would lose all installation data.
170
-
171
- Your store must implement `storeInstallation`, `fetchInstallation`, and optionally `deleteInstallation`. Any persistent backend works (Redis, PostgreSQL, DynamoDB, etc). See the [Bolt InstallationStore docs](https://slack.dev/bolt-js/concepts/authenticating-oauth#the-installation-store) for the full interface, and the [Next.js example](https://github.com/vercel-labs/slack-bolt/tree/examples/examples/nextjs) for a working Redis implementation.
172
-
173
- ### Notes for Bolt 5
174
-
175
- The receiver's OAuth installer uses `@slack/oauth` 3.x internally, while Bolt 5 depends on `@slack/oauth` 4.x. Both are installed in a Bolt 5 app. This is safe: the `Installation`, `InstallationStore` and `Logger` types you write against are structurally identical in both versions, so an `installationStore` typed via `@slack/bolt` works unchanged. Two details differ:
176
-
177
- - `installerOptions.clientOptions` follows `@slack/web-api` 7's `WebClientOptions` (`agent`, `tls`), not 8's (`fetch`). A custom `fetch` you pass to the Bolt `App` is not used for the OAuth token exchange.
178
- - Errors passed to `installerOptions.callbackOptions.failure` are `@slack/oauth` 3.x instances. Check `error.code` rather than `instanceof` against classes imported from `@slack/oauth`, which would resolve to the 4.x copy.
179
-
180
- The installer will move to `@slack/oauth` 4.x in the next major release, when Bolt 4 support is dropped.
99
+ Bolt needs the raw body to verify Slack's signature, so `fetch` throws a `TypeError` if the request body has already been read. To read it yourself too, read a `request.clone()` and pass the original to `fetch`.
181
100
 
182
101
  ### `preview`
183
102
 
@@ -224,6 +143,123 @@ const result = await preview({
224
143
  | `installStatus` | `string` | Installation outcome (e.g. `installed`, `missing_service_token`). |
225
144
  | `app` | `object` | Slack API response containing `app_id` and credentials. |
226
145
 
146
+ ## Frameworks
147
+
148
+ Serve the receiver from one route, and point your Slack app's request URLs at it. The route handles `POST` for events, slash commands and interactions, and with the [OAuth options](#oauth-multi-workspace-apps), `GET` for the install page and OAuth callback. In Next.js, export `POST` and `GET` from a route handler, as in [`VercelReceiver`](#vercelreceiver). The snippets below import `receiver` from the file that creates your `App`, so export it there with `export { receiver };`.
149
+
150
+ Bolt verifies Slack's signature against the raw request body, so don't add middleware to the Slack route that reads the body first. The [examples](#examples) show each framework in a complete app.
151
+
152
+ ### Hono
153
+
154
+ ```typescript
155
+ import { Hono } from "hono";
156
+ import { receiver } from "./slack";
157
+
158
+ const app = new Hono();
159
+
160
+ app.all("/api/slack/events", (c) => receiver.fetch(c.req.raw));
161
+
162
+ export default app;
163
+ ```
164
+
165
+ ### Express
166
+
167
+ Express hands your route Node.js's request and response, not a Web `Request`, so adapt `receiver.fetch` with `toNodeHandler` from [srvx](https://srvx.h3.dev). This package uses srvx already, but add it to your own dependencies to import it.
168
+
169
+ ```typescript
170
+ import express, { type RequestHandler } from "express";
171
+ import { toNodeHandler } from "srvx/node";
172
+ import { receiver } from "./slack";
173
+
174
+ const app = express();
175
+
176
+ // srvx types its handler for HTTP/1 and HTTP/2 servers; Express is HTTP/1,
177
+ // hence the cast.
178
+ app.all("/api/slack/events", toNodeHandler(receiver.fetch) as RequestHandler);
179
+
180
+ export default app;
181
+ ```
182
+
183
+ Add the Slack route before any body parser, like `express.json()` or `express.urlencoded()`, or add parsers only to the routes that need them.
184
+
185
+ ### Nitro
186
+
187
+ ```typescript
188
+ // routes/api/slack/events.ts
189
+ import { defineHandler } from "nitro";
190
+ import { receiver } from "../../../slack";
191
+
192
+ export default defineHandler((event) => receiver.fetch(event.req));
193
+ ```
194
+
195
+ In Nitro 3, `event.req` is the Web `Request`. Put the route under `routes/api`: Nitro's top-level `api` directory [isn't compatible with Vercel](https://nitro.build/deploy/providers/vercel).
196
+
197
+ ### TanStack Start
198
+
199
+ ```typescript
200
+ // src/routes/api/slack/events.ts
201
+ import { createFileRoute } from "@tanstack/react-router";
202
+ import { receiver } from "../../../slack";
203
+
204
+ export const Route = createFileRoute("/api/slack/events")({
205
+ server: {
206
+ handlers: {
207
+ GET: ({ request }) => receiver.fetch(request),
208
+ POST: ({ request }) => receiver.fetch(request),
209
+ },
210
+ },
211
+ });
212
+ ```
213
+
214
+ ### Other frameworks
215
+
216
+ Any framework that hands your route a Web `Request` and takes a `Response` back works the same way: pass the request to `receiver.fetch`.
217
+
218
+ ## OAuth (Multi-Workspace Apps)
219
+
220
+ `VercelReceiver` uses Bolt's own [OAuth support](https://slack.dev/bolt-js/concepts/authenticating-oauth), so other workspaces can install your app. Pass the OAuth options to the receiver, not the `App`, and leave `token` off the `App`: Bolt looks up each workspace's tokens in your `installationStore`.
221
+
222
+ ```typescript
223
+ import { App } from "@slack/bolt";
224
+ import { VercelReceiver } from "@vercel/slack-bolt";
225
+ import { installationStore } from "./installation-store";
226
+
227
+ const receiver = new VercelReceiver({
228
+ clientId: process.env.SLACK_CLIENT_ID,
229
+ clientSecret: process.env.SLACK_CLIENT_SECRET,
230
+ stateSecret: process.env.SLACK_STATE_SECRET,
231
+ scopes: ["chat:write", "commands"],
232
+ installationStore,
233
+ });
234
+
235
+ const app = new App({ receiver, deferInitialization: true });
236
+
237
+ export const { GET, POST } = receiver;
238
+ ```
239
+
240
+ Export `GET` and `POST` from one route, and add its URL as a **Redirect URL** under **OAuth & Permissions** in your Slack app settings. Opening the route in a browser shows the install page, and Slack sends the OAuth callback back to it. Separate install and callback routes also work: export `GET` from each, and the receiver tells them apart by their query parameters. If you set `redirectUri`, it must be a full URL, like `https://example.com/api/slack/oauth`.
241
+
242
+ `installerOptions` takes Bolt's installer options, except `installPath`, `redirectUriPath` and `port`: the receiver serves the install page and callback at whatever path your route has.
243
+
244
+ ### Environment variables
245
+
246
+ Set these in your Vercel project (or `.env.local` for local development):
247
+
248
+ | Variable | Description |
249
+ | ---------------------- | ------------------------------------------------------------------------------------------------ |
250
+ | `SLACK_CLIENT_ID` | App client ID, found under **Basic Information** on [api.slack.com](https://api.slack.com/apps). |
251
+ | `SLACK_CLIENT_SECRET` | App client secret, found in the same section. |
252
+ | `SLACK_STATE_SECRET` | A random string used to sign the OAuth state parameter. |
253
+ | `SLACK_SIGNING_SECRET` | Signing secret for verifying incoming Slack requests. |
254
+
255
+ The receiver reads `SLACK_SIGNING_SECRET` from `process.env` automatically. Pass the other three as options, as in the example above.
256
+
257
+ ### Installation store
258
+
259
+ Bolt's default installation store keeps installations in memory, which Vercel doesn't share between function instances or keep across deployments. So `VercelReceiver` requires an `installationStore` whenever you set `clientId`.
260
+
261
+ Your store must implement `storeInstallation` and `fetchInstallation`, and optionally `deleteInstallation`. Any persistent backend works (Redis, PostgreSQL, DynamoDB, etc). See the [Bolt InstallationStore docs](https://slack.dev/bolt-js/concepts/authenticating-oauth#the-installation-store) for the full interface, and the [Next.js example](https://github.com/vercel-labs/slack-bolt/tree/master/examples/nextjs) for a working Redis implementation that also deletes installations on `app_uninstalled` and `tokens_revoked`.
262
+
227
263
  ## Preview Deployments
228
264
 
229
265
  `@vercel/slack-bolt` can automatically create and manage a dedicated Slack app for each preview branch. On every preview build it will:
@@ -318,58 +354,122 @@ Options:
318
354
 
319
355
  All Vercel and Slack environment variables are read automatically. You can override any of them via CLI flags (e.g. `--vercel-env`, `--slack-app-id`).
320
356
 
321
- ## Advanced
357
+ ## Migrating from v1
322
358
 
323
- ### Request Interception
359
+ v2 rebuilds `VercelReceiver` on Bolt's `HTTPReceiver`. Your listeners don't change: what changes is how you create the receiver and serve it. v2 needs `@slack/bolt` 4.7.3 or newer and Node.js 22.12 or newer. The `preview` API and the `vercel-slack` CLI are unchanged.
324
360
 
325
- The `beforeProcess` hook lets you intercept requests after signature verification but before Bolt processes them. Return a `Response` to short-circuit, or `undefined` to continue normally.
361
+ ### Replace `createHandler`
362
+
363
+ `createHandler(app, receiver)` is removed. In v1, your route created the handler:
326
364
 
327
365
  ```typescript
328
- const receiver = new VercelReceiver({
329
- signingSecret: process.env.SLACK_SIGNING_SECRET,
330
- beforeProcess: async (req, body) => {
331
- if (body.team_id === "T_ENTERPRISE") {
332
- return fetch("https://enterprise-handler.example.com/slack", {
333
- method: "POST",
334
- body: await req.text(),
335
- headers: req.headers,
336
- });
337
- }
338
- // Return undefined to continue normal Bolt processing
339
- },
340
- });
366
+ // app/api/slack/events/route.ts
367
+ import { createHandler } from "@vercel/slack-bolt";
368
+ import { app, receiver } from "@/lib/slack";
369
+
370
+ export const POST = createHandler(app, receiver);
371
+ ```
372
+
373
+ In v2, export the receiver's `POST` where you create the `App`, and re-export it from the route:
374
+
375
+ ```typescript
376
+ // lib/slack.ts, after creating the App
377
+ export const { POST } = receiver;
378
+ ```
379
+
380
+ ```typescript
381
+ // app/api/slack/events/route.ts
382
+ export { POST } from "@/lib/slack";
383
+ ```
384
+
385
+ Keep `deferInitialization: true` on the `App`. Like `createHandler`, the receiver then runs `app.init()` on the first request. Outside Next.js, pass each request to `receiver.fetch`, as in [Frameworks](#frameworks).
386
+
387
+ ### Serve OAuth with `GET`
388
+
389
+ `receiver.handleInstall` and `receiver.handleCallback` are replaced by `receiver.GET`, which tells the install page and the OAuth callback apart by their query parameters. Your v1 routes can keep their paths:
390
+
391
+ ```typescript
392
+ // app/api/slack/install/route.ts
393
+ import { receiver } from "@/lib/slack";
394
+
395
+ export const GET = receiver.GET; // was receiver.handleInstall
341
396
  ```
342
397
 
343
- > **Note:** `beforeProcess` is not called for `url_verification` challenges.
398
+ ```typescript
399
+ // app/api/slack/oauth-redirect/route.ts
400
+ import { receiver } from "@/lib/slack";
401
+
402
+ export const GET = receiver.GET; // was receiver.handleCallback
403
+ ```
404
+
405
+ Or serve both from your events route with `export const { GET, POST } = receiver`, and make that route's URL your Slack app's Redirect URL.
344
406
 
345
- ### Dynamic Scopes
407
+ ### Pass the OAuth credentials
346
408
 
347
- The `scopes` option accepts either a static array or a resolver function. This enables requesting different OAuth scopes based on the install request context (e.g., different scopes for enterprise vs. standard workspaces).
409
+ v1 read `clientId`, `clientSecret` and `stateSecret` from `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET` and `SLACK_STATE_SECRET`. v2 only reads `SLACK_SIGNING_SECRET`, so pass the other three yourself:
348
410
 
349
411
  ```typescript
350
412
  const receiver = new VercelReceiver({
351
413
  clientId: process.env.SLACK_CLIENT_ID,
352
414
  clientSecret: process.env.SLACK_CLIENT_SECRET,
353
415
  stateSecret: process.env.SLACK_STATE_SECRET,
354
- installationStore: myInstallationStore,
355
- scopes: async (req) => {
356
- const url = new URL(req.url);
357
- const isEnterprise = url.searchParams.get("enterprise") === "true";
358
-
359
- const baseScopes = ["chat:write", "commands"];
360
- if (isEnterprise) {
361
- return [...baseScopes, "users:read", "channels:read"];
362
- }
363
- return baseScopes;
364
- },
416
+ scopes: ["chat:write", "commands"],
417
+ installationStore,
365
418
  });
366
419
  ```
367
420
 
368
- The resolver receives the install request, allowing you to inspect query parameters, headers, or any other request data to determine which scopes to request.
421
+ Without `clientId`, the receiver doesn't set up OAuth: `GET` answers `404`, and Bolt can't initialize an `App` that has neither a token nor OAuth. The receiver also needs an `installationStore` whenever you set `clientId`, and throws an `AppInitializationError` without one. `redirectUri`, if you set it, must be a full URL.
422
+
423
+ ### Changed options
424
+
425
+ `VercelReceiver` takes Bolt's `HTTPReceiver` options, described in [Options](#options). `installerOptions` takes the same fields as in v1.
426
+
427
+ | v1 | v2 |
428
+ | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
429
+ | `ackTimeoutMs` | `unhandledRequestTimeoutMillis`. Pass `unhandledRequestHandler` to change what Slack gets when no listener calls `ack()` in time. |
430
+ | `customPropertiesExtractor(req, body)` | `customPropertiesExtractor(req)`, where `req` is Bolt's `BufferedIncomingMessage`: read headers from `req.headers`, with lowercase names, and the body from `req.rawBody`. |
431
+ | `scopes` as a function | Removed. `scopes` takes a fixed list. |
432
+ | `beforeProcess` | Removed. See [Replace `beforeProcess`](#replace-beforeprocess). |
433
+
434
+ `createHandler` and the `VercelHandler`, `BeforeProcessFn`, `ScopesResolver` and `VercelInstallerOptions` types are removed too. For the installer options' type, use `VercelReceiverOptions["installerOptions"]`.
435
+
436
+ The installer is now Bolt's own, so v1's notes for Bolt 5 no longer apply: `installerOptions.clientOptions` and the errors passed to `installerOptions.callbackOptions.failure` come from the same `@slack/web-api` and `@slack/oauth` versions as your Bolt.
437
+
438
+ ### Replace `beforeProcess`
439
+
440
+ To run code for every event, command and interaction after Bolt has verified it, use Bolt's [global middleware](https://docs.slack.dev/tools/bolt-js/concepts/global-middleware) with `app.use()`.
441
+
442
+ To answer a request yourself instead of passing it to Bolt, as `beforeProcess` could, handle it in your route before calling `receiver.fetch`. Your route runs before Bolt verifies Slack's signature, so check it with Bolt's `isValidSlackRequest` before you trust the body:
443
+
444
+ ```typescript
445
+ // app/api/slack/events/route.ts
446
+ import { isValidSlackRequest } from "@slack/bolt";
447
+ import { forward, shouldForward } from "@/lib/forward";
448
+ import { receiver } from "@/lib/slack";
449
+
450
+ export async function POST(request: Request) {
451
+ // Read a copy, so the receiver still gets the untouched body.
452
+ const body = await request.clone().text();
453
+ const verified = isValidSlackRequest({
454
+ signingSecret: process.env.SLACK_SIGNING_SECRET ?? "",
455
+ body,
456
+ headers: {
457
+ "x-slack-signature": request.headers.get("x-slack-signature") ?? "",
458
+ "x-slack-request-timestamp": Number(
459
+ request.headers.get("x-slack-request-timestamp"),
460
+ ),
461
+ },
462
+ });
463
+ if (verified && shouldForward(body)) return forward(body);
464
+ return receiver.fetch(request);
465
+ }
466
+ ```
467
+
468
+ `shouldForward` and `forward` stand in for your own code. `body` is the raw body: JSON for events, and form data for slash commands and interactions, which put their JSON in a `payload` field.
369
469
 
370
470
  ## Examples
371
471
 
372
- Starter templates: [Next.js](https://github.com/vercel-labs/slack-bolt/tree/examples/examples/nextjs), [Hono](https://github.com/vercel-labs/slack-bolt/tree/examples/examples/hono), [Nitro](https://github.com/vercel-labs/slack-bolt/tree/examples/examples/nitro).
472
+ Starter templates: [Next.js](https://github.com/vercel-labs/slack-bolt/tree/master/examples/nextjs), [Hono](https://github.com/vercel-labs/slack-bolt/tree/master/examples/hono), [Express](https://github.com/vercel-labs/slack-bolt/tree/master/examples/express), [TanStack Start](https://github.com/vercel-labs/slack-bolt/tree/master/examples/tanstack-start), [Nitro](https://github.com/vercel-labs/slack-bolt/tree/master/examples/nitro).
373
473
 
374
474
  ## Contributing
375
475
 
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_preview = require("./preview-Da5gwcM1.js");
2
+ const require_preview = require("./preview-DS5gSBPc.js");
3
3
  let node_fs = require("node:fs");
4
4
  node_fs = require_preview.__toESM(node_fs);
5
5
  let node_path = require("node:path");
@@ -298,7 +298,7 @@ function run(version) {
298
298
  const { version } = (/* @__PURE__ */ require_preview.__commonJSMin(((exports, module) => {
299
299
  module.exports = {
300
300
  "name": "@vercel/slack-bolt",
301
- "version": "1.7.2",
301
+ "version": "2.0.0-canary.20261021155202.7aaad09",
302
302
  "description": "A Vercel receiver for building Slack apps with Bolt and deploying them to Vercel",
303
303
  "main": "./dist/index.js",
304
304
  "types": "./dist/index.d.ts",
@@ -335,8 +335,8 @@ const { version } = (/* @__PURE__ */ require_preview.__commonJSMin(((exports, mo
335
335
  "typecheck": "tsc --noEmit",
336
336
  "test": "vitest run",
337
337
  "test:watch": "vitest watch",
338
- "lint": "biome check .",
339
- "lint:fix": "biome check . --write",
338
+ "lint": "oxlint src && oxfmt --check src",
339
+ "lint:fix": "oxlint --fix src && oxfmt src",
340
340
  "attw": "attw --pack ."
341
341
  },
342
342
  "keywords": [
@@ -347,27 +347,27 @@ const { version } = (/* @__PURE__ */ require_preview.__commonJSMin(((exports, mo
347
347
  "author": "Vercel",
348
348
  "license": "MIT",
349
349
  "dependencies": {
350
- "@slack/logger": "^4.0.1",
351
- "@slack/oauth": "3.0.5",
352
- "@vercel/functions": "^3.9.9",
350
+ "@vercel/functions": "^3.10.1",
353
351
  "commander": "^14.0.3",
352
+ "srvx": "~1.0.6",
354
353
  "yaml": "^2.9.1",
355
- "zod": "^4.6.5"
354
+ "zod": "^4.6.7"
356
355
  },
357
356
  "devDependencies": {
358
357
  "@arethetypeswrong/cli": "^0.18.5",
359
- "@biomejs/biome": "catalog:",
360
358
  "@slack/bolt": "^5.1.0",
361
359
  "@types/node": "catalog:",
362
- "@vitest/coverage-v8": "5.0.3",
363
- "tsdown": "^0.22.14",
360
+ "@vitest/coverage-v8": "5.0.5",
361
+ "oxfmt": "catalog:",
362
+ "oxlint": "catalog:",
363
+ "tsdown": "^0.23.1",
364
364
  "typescript": "catalog:",
365
- "vite": "^8.3.2",
366
- "vitest": "5.0.3"
365
+ "vite": "^8.3.4",
366
+ "vitest": "5.0.5"
367
367
  },
368
- "peerDependencies": { "@slack/bolt": "^4.4.0 || ^5.0.0" },
368
+ "peerDependencies": { "@slack/bolt": "^4.7.3 || ^5.0.0" },
369
369
  "peerDependenciesMeta": { "@slack/bolt": { "optional": false } },
370
- "engines": { "node": ">=22.0.0" },
370
+ "engines": { "node": ">=22.12.0" },
371
371
  "publishConfig": { "access": "public" }
372
372
  };
373
373
  })))();