Back to Eliza

Telegram Agent Examples

packages/examples/telegram/README.md

2.0.11.6 KB
Original Source

Telegram Agent Examples

Telegram bots using elizaOS with the full message pipeline (providers → LLM → actions → ALWAYS_AFTER hook actions).

Quick Start

bash
export TELEGRAM_BOT_TOKEN="your-token"
export OPENAI_API_KEY="your-key"
# Optional: export POSTGRES_URL="postgresql://..."
LanguageCommand
TypeScriptcd typescript && bun install && bun run start
Pythoncd python && pip install -r requirements.txt && python telegram_agent.py
Rustcd rust/telegram-agent && cargo run --release

How It Works

TypeScript: The telegramPlugin auto-integrates with the runtime - just include it and messages flow through the full pipeline automatically.

Python/Rust: Manually bridge Telegram to runtime.message_service.handle_message() which runs the full pipeline.

Message Pipeline

Message → Providers → LLM → Actions → Response
          (character,   (generate   (reply,
           entities,     response)   ignore,
           history)                  custom)

Configuration

The character defines personality, system prompt, and settings:

typescript
const character = {
  name: "TelegramEliza",
  bio: "A helpful AI assistant.",
  system: "Be friendly and concise...",
  settings: { model: "gpt-5-mini" },
  secrets: { TELEGRAM_BOT_TOKEN: "...", OPENAI_API_KEY: "..." },
};

Env Variables

VariableRequiredDescription
TELEGRAM_BOT_TOKENYesFrom @BotFather
OPENAI_API_KEYYesOpenAI API key
POSTGRES_URLNoPostgreSQL URL (defaults to PGLite)