Registry / http-networking / slack-cloudflare-workers

slack-cloudflare-workers

JSON →
library1.3.9jsnpmunverified

slack-cloudflare-workers is an opinionated framework for building Slack applications designed specifically for Cloudflare Workers, leveraging their serverless environment. Inspired by Slack's popular Bolt framework but not strictly following its blueprint, it distinguishes itself with a strong TypeScript focus, built-in lazy listener capabilities (similar to bolt-python), and a commitment to zero additional runtime dependencies beyond its foundational `slack-edge` module. The current stable version is 1.3.9. This library caters to developers seeking highly performant, type-safe, and lightweight Slack integrations on the Cloudflare Workers platform, providing a streamlined experience compared to general-purpose Node.js frameworks. While release cadence isn't explicitly stated, the active development and frequent updates to the `slack-edge` ecosystem suggest a responsive maintenance schedule.

npm install slack-cloudflare-workers
INSTALL
IMPORT
SIG · SLACK-CLOUDFLARE-W
S
slack-cloudflare-workers
http-networkingjavascriptv1.3.9
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

App
import { App } from 'slack-cloudflare-workers';
const App = require('slack-cloudflare-workers');
Cloudflare Workers primarily use ESM. CommonJS `require` is not natively supported without a build step.
Context
import type { Context } from 'slack-cloudflare-workers';
Import types separately for clarity and to avoid runtime overhead, especially for TypeScript projects.
SlackAPIClient
import type { SlackAPIClient } from 'slack-cloudflare-workers';
Import the type definition for the underlying Slack API client if direct API calls are made outside of event contexts.

Sets up a basic Cloudflare Worker handling Slack 'hello' messages and '/echo' slash commands, demonstrating app initialization and event listeners.

import { App } from 'slack-cloudflare-workers'; interface Env { SLACK_SIGNING_SECRET: string; SLACK_BOT_TOKEN: string; } const app = new App({ signingSecret: process.env.SLACK_SIGNING_SECRET ?? 'your-signing-secret-if-not-env', token: process.env.SLACK_BOT_TOKEN ?? 'your-bot-token-if-not-env', }); // Listen for a 'hello' message app.message('hello', async ({ say, payload }) => { await say(`Hello, <@${payload.user}>! How can I help you?`); }); // Respond to a slash command app.command('/echo', async ({ command, ack, respond }) => { await ack(); // Acknowledge the command immediately await respond(`You said: ${command.text}`); }); export default { async fetch( request: Request, env: Env, ctx: ExecutionContext ): Promise<Response> { // Ensure the app instance uses the environment variables from the Worker's context // This is crucial for local development vs. deployed Worker app.oauth = undefined; // Reset OAuth for each request to use correct env app.receiver.signingSecret = env.SLACK_SIGNING_SECRET; app.client.token = env.SLACK_BOT_TOKEN; return app.fetch(request, env, ctx); }, };
Debug
Known issues
gotchaThis framework's design, while inspired by Slack's Bolt.js, does not strictly follow its blueprint. Developers migrating from Bolt.js might find differences in API surface or expected behavior, requiring careful review of the `slack-cloudflare-workers` documentation.
fix
Consult the `slack-cloudflare-workers` documentation (especially for event payloads and context objects) when porting Bolt.js code or encountering unexpected behavior.
affects: >=1.0.0
breakingPrior to version 1.0, the package's core logic and API surface were less stable. While no explicit breaking change documentation is provided for minor versions, it is generally recommended to pin to a major version (e.g., `slack-cloudflare-workers@^1.0.0`) and review changelogs for updates.
fix
Update to version `1.x.x` for the latest stable API. Always test updates thoroughly, especially if upgrading from pre-1.0 versions.
affects: <1.0.0
gotchaCloudflare Workers do not have a traditional filesystem or `process.env` in the same way as Node.js. Environment variables must be passed explicitly via the `env` argument in the `fetch` handler or configured via `wrangler.toml` and accessed via the `Env` interface. Hardcoding secrets is a security risk.
fix
Define secrets (like `SLACK_SIGNING_SECRET`, `SLACK_BOT_TOKEN`) in `wrangler.toml` or using Cloudflare's dashboard, then access them via the `env` object passed to the Worker's `fetch` handler and during `App` initialization.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Signature verification failed.
The Slack `x-slack-signature` header does not match the computed signature using `SLACK_SIGNING_SECRET`.
fix
Ensure `SLACK_SIGNING_SECRET` is correctly set in your Cloudflare Worker's environment variables and exactly matches the value from your Slack app settings. Check for leading/trailing whitespace or accidental character changes.
TypeError: app.message is not a function
The `App` instance was not correctly initialized or the import path is wrong, leading to an undefined or incorrect object.
fix
Verify that `import { App } from 'slack-cloudflare-workers';` is correct and that `new App({ ... })` is called with valid parameters before attempting to call listener methods.
Failed to execute 'fetch' on 'WorkerGlobalScope': The provided URL 'undefined' is not valid.
This error often occurs when `SLACK_BOT_TOKEN` is missing or undefined, causing the underlying `SlackAPIClient` to attempt an API call with an invalid base URL.
fix
Ensure `SLACK_BOT_TOKEN` is correctly provided to the `App` instance, either directly or via environment variables, and that it is a valid Slack bot token.
Upgrade
Version history
1.3.9latest on npm
Audit
Dependencies
slack-edgerequiredCore foundational module for Slack API interactions, providing primitives for event handling and API calls.
Agent activity
22 hits · last 30 days
node
20
OpenAI (training)
1
Resources
slack-cloudflare-workers — npm install slack-cloudflare-workers · libregistry