Packages ยท Chat
@notifkit/provider-slack
The native Slack transport. Posts to Slack channels, direct messages (DMs), or Incoming Webhook URLs with support for plain text, mentions, and rich Block Kit UI components.
npm install @notifkit/provider-slack
import { NotifkitServer } from "notifkit";
import { SlackTransport } from "@notifkit/provider-slack";
const server = new NotifkitServer({
services: ["all"],
providers: [
new SlackTransport({
botToken: process.env.SLACK_BOT_TOKEN, // xoxb-...
webhookUrl: process.env.SLACK_WEBHOOK_URL, // optional fallback webhook
}),
],
});
Options
| Option | Required | Notes |
|---|---|---|
botToken / token | optional* | Bot or user OAuth token (xoxb-... or xoxp-...). Required for sending to Slack channels or user IDs via chat.postMessage. |
webhookUrl | optional* | Default Incoming Webhook URL. Used when a message or recipient specifies no destination target. |
appId | no | Descriptive app ID for multi-workspace logging. |
logger | no | A notifkit logger instance. |
limits | no | Provider sliding-window rate limit. Defaults to { limit: 1000, windowSeconds: 10 }. |
*At least one of botToken or webhookUrl must be provided.
Destinations
A recipient's slack contact target determines how the transport sends:
- Channel ID (e.g.
C0123456789) or User ID (e.g.U0123456789for DMs): Dispatched via Slack Web API (chat.postMessage) usingbotToken. - Incoming Webhook URL (e.g.
https://hooks.slack.com/services/...): Posted directly to the webhook URL without requiring a bot token.
Which template keys it reads
| Template key | Lands as |
|---|---|
text or body | The message text or fallback notification banner. |
blocks | An array of Slack Block Kit layout objects (sections, dividers, actions, context). |
channel | Override the destination channel ID, user ID, or webhook URL per template. |
Block Kit example
await notifkit.syncTemplates({
templates: [
{
id: "incident-alert",
channel: "slack",
content: {
text: "Incident alert: {{service}} is degraded",
blocks: [
{
type: "header",
text: { type: "plain_text", text: "๐จ Service Incident" }
},
{
type: "section",
text: { type: "mrkdwn", text: "*Service:* {{service}}\n*Severity:* {{severity}}" }
}
]
},
},
],
});
automatic deactivation
If Slack returns errors indicating a dead destination (such as channel_not_found, is_archived, user_not_found, or not_in_channel), notifkit flags the contact target as invalid and suspends future deliveries to that target.