GitHubBlog

Search Documentation

Search for a page in the docs

Telegram Bot

Connect Alice to Telegram for mobile chat access and push notifications. The bot integration uses grammY with polling.

Setup

1. Create the Bot

  1. Open Telegram and message @BotFather
  2. Send /newbot and follow the prompts
  3. Copy the bot token (e.g. 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)

2. Get Your Chat ID

  1. Message your new bot
  2. Check the OpenAlice logs — unauthorized chat IDs are logged:
    telegram: unauthorized chat 123456789, set TELEGRAM_CHAT_ID=123456789 to allow
    
  3. Copy the chat ID

3. Configure

Edit data/config/connectors.json:

{
  "telegram": {
    "enabled": true,
    "botToken": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
    "chatIds": [123456789]
  }
}
FieldDescription
enabledMaster switch
botTokenBot token from BotFather
chatIdsArray of allowed chat IDs (auth whitelist)

4. Restart or Hot-Toggle

Either restart OpenAlice, or if it's already running, Alice can reconnect connectors at runtime when you update the config.

Features

Chat

Message your bot to chat with Alice. She has access to all the same tools as the Web UI — market data, trading, brain, news, etc.

Auth Guard

Only chat IDs listed in chatIds can interact with the bot. Unauthorized messages are ignored with a one-time guidance reply (throttled to once per 60 seconds per chat).

Session Management

Each Telegram user gets their own session file (data/sessions/telegram/{chatId}.jsonl). Conversation history is maintained independently per user.

Media Support

Alice can send and receive images through Telegram. Media groups (multiple photos in one message) are automatically merged.

Push Notifications

When heartbeat or cron jobs generate output, notifications are delivered to the last-interacted channel. If you last chatted via Telegram, that's where notifications go.

Hot-Toggle

Telegram can be enabled or disabled at runtime without restarting OpenAlice. Update connectors.json and the connector reconnect system handles the lifecycle:

  • Starting: creates a new bot, begins polling
  • Stopping: gracefully stops polling, unregisters the connector