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)
- Create a Bot Father token and paste it in Settings → Integrations → Telegram.
- Add the bot to your group; grant Read Messages permission.
- 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)
- Tick Scheduler — A cron job triggers every 60 seconds.
- Context Gatherer — Fetch last 30 messages + bot action history + unread counts.
- LLM Orchestrator — Builds a prompt (
system-ticking-v1.velin.md) asking the LLM to reply with only a JSON action. - Action Executor — Parses JSON and performs the chosen action via
grammyAPI. - 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
/sleepcommand to mute the bot for a specified duration.
Related Technical Files
| Functional Role | Code File | Description |
|---|---|---|
| Telegram Service Entry | services/telegram-bot/src/index.ts | Launches grammy bot & DB setup |
| LLM Action Logic | services/telegram-bot/src/llm/actions.ts | Builds prompt & interprets JSON |
| Ticking Prompt | services/telegram-bot/src/prompts/system-ticking-v1.velin.md | Instructs LLM on allowed actions |
| Media Handler | services/telegram-bot/src/media/photo.ts, .../sticker.ts | Vision LLM & embedding storage |
| DB Schema | services/telegram-bot/src/db/schema.ts | Messages, media, vector columns |