Star
Packages ยท Chat

@notifkit/provider-slack

The Slack transport. Posts to channels, direct messages (DMs) or Incoming Webhook URLs, with plain text, mentions and Block Kit 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

OptionRequiredNotes
botToken / tokenoptional*Bot or user OAuth token (xoxb-... or xoxp-...). Required for sending to Slack channels or user IDs via chat.postMessage.
webhookUrloptional*Default Incoming Webhook URL. Used when a message or recipient specifies no destination target.
appIdnoDescriptive app ID for multi-workspace logging.
loggernoA notifkit logger instance.
limitsnoProvider sliding-window rate limit. Defaults to { limit: 1000, windowSeconds: 10 }.

*At least one of botToken or webhookUrl must be provided.

Destinations

The recipient's slack contact target decides how it sends:

  • Channel ID (e.g. C0123456789) or User ID (e.g. U0123456789 for DMs): sent via the Slack Web API (chat.postMessage) with botToken.
  • Incoming Webhook URL (e.g. https://hooks.slack.com/services/...): posted straight to the URL, no bot token needed.

Which template keys it reads

Template keyLands as
text or bodyThe message text or fallback notification banner.
blocksAn array of Slack Block Kit layout objects (sections, dividers, actions, context).
channelOverride 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 reports a dead destination (channel_not_found, is_archived, user_not_found or not_in_channel), notifkit marks the target invalid and stops delivering to it.