← back
Packages · Chat

@notifkit/provider-discord

The Discord transport. Delivers rich alerts into Discord channels via incoming webhooks with custom display names, avatars, and embed layouts, automatically pruning dead webhooks.

npm install @notifkit/provider-discord
import { NotifkitServer } from "notifkit";
import { DiscordTransport } from "@notifkit/provider-discord";

const server = new NotifkitServer({
  services: ["all"],
  providers: [new DiscordTransport()],
});

Getting a Webhook URL

In Discord: Edit Channel → Integrations → Webhooks → New Webhook, then copy its URL. Store the webhook URL directly as the recipient contact target:

await notifkit.addContact("channel_ops", {
  channel: "discord",
  target: "https://discord.com/api/webhooks/123456789012345678/abcdef...",
});

Template keys & Rich Embeds

Template keyLands as
text or bodyMessage content text.
usernameOverride the webhook's sender display name per template.
avatarUrlOverride the webhook's avatar image URL per template.
embedsArray of Discord embed objects (title, description, color, fields, timestamp).
await notifkit.syncTemplates({
  templates: [
    {
      id: "build-status",
      channel: "discord",
      content: {
        username: "DeployBot",
        avatarUrl: "https://example.com/deploybot.png",
        text: "Build finished for **{{repo}}**",
        embeds: [
          {
            title: "Build #{{buildId}} Passed",
            color: 0x22c55e,
            fields: [
              { name: "Branch", value: "{{branch}}", inline: true },
              { name: "Duration", value: "{{duration}}", inline: true },
            ],
          },
        ],
      },
    },
  ],
});
dead webhook detection

If Discord responds with 404 or 401 because a webhook was deleted or modified, notifkit treats the target as invalid and suspends future deliveries to that URL.