Star
Packages ยท Chat

@notifkit/provider-telegram

The Telegram transport. Sends through the Telegram Bot API to chat IDs or channels, with HTML/Markdown formatting, link preview controls, and automatic deactivation when blocked.

npm install @notifkit/provider-telegram
import { NotifkitServer } from "notifkit";
import { TelegramTransport } from "@notifkit/provider-telegram";

const server = new NotifkitServer({
  services: ["all"],
  providers: [
    new TelegramTransport({
      botToken: process.env.TELEGRAM_BOT_TOKEN!,
    }),
  ],
});

Options

OptionRequiredNotes
botTokenyesBot API token obtained from Telegram's @BotFather.
loggernoA notifkit logger instance.
limitsnoProvider sliding-window rate limit. Defaults to { limit: 1000, windowSeconds: 10 }.

Recipient targeting

A recipient must message your bot first (e.g. /start) before it can message them. Store their Telegram Chat ID as the contact target:

await notifkit.addContact("usr_123", {
  channel: "telegram",
  target: "5910738042",
});

Template keys & formatting

Template keyLands as
text or bodyMessage text.
parseModeFormatting mode: "HTML", "MarkdownV2", or "Markdown".
disableWebPagePreviewBoolean. When true, suppresses URL preview thumbnails.
disableNotificationBoolean. When true, sends the message silently with no notification sound.
Deactivation on block

If a user blocks the bot or deletes the chat, Telegram returns bot was blocked by the user or chat not found, and notifkit marks the target invalid and stops retrying.