← back
Packages · Chat

@notifkit/provider-telegram

The Telegram transport. Delivers notifications via the Telegram Bot API to individual chat IDs or channels, with HTML/Markdown formatting, link preview controls, and automatic contact 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 interact with your bot (e.g. sending /start) before the bot can message them. Store their Telegram Chat ID as their 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. notifkit marks the contact target invalid and halts retries.