Skip to main content

Telegram

Send messages, photos, and read bot updates via the Telegram Bot API. No external SDK required — uses pure HTTP via fetch.

Quick Start

import { Agent, openai, TelegramToolkit } from "@radaros/core";

const telegram = new TelegramToolkit({
  botToken: process.env.TELEGRAM_BOT_TOKEN,
});

const agent = new Agent({
  name: "telegram-bot",
  model: openai("gpt-4o"),
  instructions: "Help manage Telegram messages.",
  tools: [...telegram.getTools()],
});

const result = await agent.run("Send 'Hello from RadarOS!' to chat 123456789.");

Config

botToken
string
required
Telegram Bot token from @BotFather. Falls back to TELEGRAM_BOT_TOKEN env var.

Tools

ToolDescription
telegram_send_messageSend a text message to a chat (supports Markdown/HTML).
telegram_send_photoSend a photo (by URL or file_id) to a chat.
telegram_get_updatesGet recent messages/updates received by the bot.

No External Dependencies

This toolkit uses the Telegram Bot API directly via fetch — no SDK needed.

Getting a Bot Token

  1. Open Telegram and message @BotFather
  2. Send /newbot and follow the prompts
  3. Copy the token and set it as TELEGRAM_BOT_TOKEN

Environment Variables

VariableDescription
TELEGRAM_BOT_TOKENBot token from @BotFather