Repository navigation
Slack
Typed Slack Web API client for Deno, Bun,
Node.js and Cloudflare Workers. Post, update and delete messages, list channels
and read history, look up users, and verify request signatures. A lightweight
alternative to @slack/web-api for the methods it covers.
Slack's Web API is a large collection of POST/GET methods, all under
https://slack.com/api, authenticated with a bot token as a standard
Bearer header. This connect covers the core surface for a bot that posts
notifications and reads back what it (or others) posted: sending, updating,
and deleting a channel message; listing conversations; paging through a
conversation's history; and looking up a user. It uses RESTler for
transport and Guardian for runtime request/response validation.
Slack's defining API quirk — most documented failures arrive as
HTTP 200 OK with { ok: false, error: '<string>' } in the body, not a
4xx/5xx status — is handled centrally; see
Errors for the full mapping.
import { Slack } from '@tundraconnect/slack';
const client = new Slack({
auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});Your tests don't need to fake HTTP. Have your code take a Slack instance and
pass in a stand-in that returns the shapes from @tundraconnect/slack/schemas
or throws a real SlackError:
import { SlackError } from '@tundraconnect/slack/errors';
const outage = new SlackError('SERVICE_UNAVAILABLE', { status: 503 });
console.log(outage.code);To exercise the client itself against a fake transport, subclass it and
reassign the protected _fetch.
| Topic | Description |
|---|---|
| API | Client configuration and endpoint methods |
| Errors | Error codes and diagnostic metadata |
| Schemas | Public Guardian schemas and inferred types |
- Slack Web API reference
- Create a Slack app (install it to a workspace and grab the bot token from OAuth & Permissions)
Deno:
deno add jsr:@tundraconnect/slackBun:
bunx jsr add @tundraconnect/slackNode.js:
npx jsr add @tundraconnect/slackimport { Slack } from '@tundraconnect/slack';
const client = new Slack({
auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});
const sent = await client.postMessage({
channel: 'C123ABC456',
text: 'Deploy succeeded',
});
console.log(sent.ts);import { Slack } from '@tundraconnect/slack';
const client = new Slack({
auth: { type: 'BEARER', token: 'xoxb-your-bot-token' },
});
export async function onSlackRequest(req: Request): Promise<void> {
const raw = await req.text(); // text(), never json()
const body = await client.verifyWebhook({
payload: raw,
headers: req.headers,
signingSecret: 'your-signing-secret',
});
// `body` is now trustworthy.
}See API → Webhooks.
MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.
- Algolia
- AzureBlob
- CloudflareDNS
- CloudflareEmail
- CloudflareSaaS
- CloudflareTurnstile
- CoinGecko
- Discord
- DodoPayments
- GCS
- GoogleAnalytics
- GoogleCertificateManager
- GoogleWebRisk
- Kalshi
- ntfy
- OpenExchange
- OpenWeatherMap
- PayPal
- Polymarket
- Razorpay
- Resend
- S3
- SendGrid
- Sentry
- Slack
- Stripe
- Telegram
- Twilio
- UpstashRedis
- URLhaus