Plugins
Telegram
Send and edit messages, send photos, long-poll for updates from a Telegram bot.
Authentication
| Type | Default | Details |
|---|---|---|
bot_token | ✅ | Token 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
| Path | Risk | Description |
|---|---|---|
messages.send | write | Send a text message to a chat. |
messages.edit | write | Edit an existing message's text. |
messages.delete | destructive (irreversible) | Delete a message. Requires admin in groups. |
messages.sendPhoto | write | Send a photo (URL, file_id, or attached file). |
updates.get | read | Long-poll for incoming updates. |
bot.me | read | Info 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 })],
});