AIRI in Telegram Groups

AIRI can join Telegram chats and decide when and how to speak, adding value without spamming.

Core Capabilities (Function-First)

  • Autonomous Replies: Every minute the agent evaluates context and may send a helpful or fun message.
  • Media Awareness: When someone posts a photo or sticker, AIRI can recognise and reference its content later.
  • Structured Actions: The AI chooses from a set list (send_message, read_unread_messages, sleep) so behaviour stays predictable.
  • Private Chat Mode: DM the bot for direct Q&A or persona testing.

Adding AIRI to Telegram (3 Steps)

  1. Create a Bot Father token and paste it in Settings → Integrations → Telegram.
  2. Add the bot to your group; grant Read Messages permission.
  3. The agent starts its ticking loop automatically — no further commands needed.

Note: By default AIRI waits at least 5 ticks before its first group message to observe the chat vibe.

How It Works (Conceptual)

  1. Tick Scheduler — A cron job triggers every 60 seconds.
  2. Context Gatherer — Fetch last 30 messages + bot action history + unread counts.
  3. LLM Orchestrator — Builds a prompt (system-ticking-v1.velin.md) asking the LLM to reply with only a JSON action.
  4. Action Executor — Parses JSON and performs the chosen action via grammy API.
  5. Media Pipeline — Photos/stickers are downloaded, described via a vision LLM, embedded, and stored in PostgreSQL for future reference.

Flow Diagram:

Tips for Healthy Group Dynamics

  • Increase Tick Interval to 5 minutes in busy chats.
  • Enable Sticker Interpretation only if the group uses lots of animated stickers (higher CPU).
  • Use /sleep command to mute the bot for a specified duration.

Functional RoleCode FileDescription
Telegram Service Entryservices/telegram-bot/src/index.tsLaunches grammy bot & DB setup
LLM Action Logicservices/telegram-bot/src/llm/actions.tsBuilds prompt & interprets JSON
Ticking Promptservices/telegram-bot/src/prompts/system-ticking-v1.velin.mdInstructs LLM on allowed actions
Media Handlerservices/telegram-bot/src/media/photo.ts, .../sticker.tsVision LLM & embedding storage
DB Schemaservices/telegram-bot/src/db/schema.tsMessages, media, vector columns