FabricFabricSDK
Plugins

Telegram

Send and edit messages, send photos, long-poll for updates from a Telegram bot.

Authentication

TypeDefaultDetails
bot_tokenToken from BotFather, embedded in the URL path

Telegram's auth model is unusual: there's no Authorization header. Instead the bot token goes in the URL itself (https://api.telegram.org/bot<TOKEN>/<METHOD>). The plugin's keyBuilder resolves the token and the fetch helper inlines it into every URL.

Endpoints

PathRiskDescription
messages.sendwriteSend a text message to a chat.
messages.editwriteEdit an existing message's text.
messages.deletedestructive (irreversible)Delete a message. Requires admin in groups.
messages.sendPhotowriteSend a photo (URL, file_id, or attached file).
updates.getreadLong-poll for incoming updates.
bot.mereadInfo about the authenticated bot.

messages.send

await fabric.telegram.api.messages.send({
  chat_id: 1234567890,
  text: '*Build complete* — see [logs](https://example.test/logs)',
  parse_mode: 'MarkdownV2',
});

parse_mode accepts 'MarkdownV2' or 'HTML'. The runtime un-wraps Telegram's { ok, result } envelope automatically — your code only sees result.

Error handling

Telegram returns { ok: false, description: '…' } on failures. The plugin throws an Error with the description text so you can catch and pattern-match:

try {
  await fabric.telegram.api.messages.send({ chat_id: 0, text: 'x' });
} catch (err) {
  if (err.message.includes('chat not found')) { /* … */ }
}

Factory

import { telegram } from '@fabricorg/integrations/plugins';

const fabric = createFabric({
  plugins: [telegram({ botToken: process.env.TELEGRAM_BOT_TOKEN })],
});