English | Русский
A Telegram bot that quietly logs messages in your group chat and posts a daily digest of what was discussed — with clickable links to the start of each discussion topic.
Example digest:
📅 Digest for 10.08.2026
🔹 Landing page redesign: Oleg, Maria and Ivan decided to simplify the header — drop the carousel, keep a single offer. 🔹 SBP payments: Anya raised the payments question, Maria suggested YooKassa with lower fees.
Day's mood: Productive day — clear next steps agreed on every topic
- The bot saves all text messages and media captions from the configured groups into a local SQLite database (
data/messages.db), including reply chains. - Every day at the configured time (
SUMMARY_TIME, default 22:00) the last 24 hours of messages are formatted as a log ([HH:MM] Name (ID: 123): text) and sent to an LLM via OpenRouter. - The LLM returns structured JSON: discussion topics, a one-line summary with participant names, and the
start_message_idof each topic. - The bot builds a digest where every topic links to the first message of that discussion (
https://t.me/c/<chat_id>/<message_id>) and posts it to the chat. - After a successful scheduled run the processed messages are deleted; records older than 48 hours are cleaned up automatically.
git clone <repo-url> && cd tg-summary-bot
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envFill in .env:
| Variable | Description |
|---|---|
TELEGRAM_BOT_TOKEN |
Bot token from @BotFather |
TELEGRAM_GROUP_CHAT_IDS |
Group chat ID(s), comma-separated, e.g. -1001234567890 |
SUMMARY_TIME |
Daily posting time, HH:MM (default 22:00) |
TIMEZONE |
Timezone for the schedule and message timestamps (default Europe/Moscow) |
OPENROUTER_API_KEY |
OpenRouter API key for summary generation |
LLM_MODEL |
Model name (default google/gemini-3-flash-preview) |
DATABASE_PATH |
SQLite path (optional, default ./data/messages.db) |
- Create a bot with @BotFather and disable privacy mode (
/setprivacy→ Disable) — otherwise the bot won't see regular group messages. - Add the bot to your group.
- Send
/chatidin the group — the bot replies with the chat ID; put it intoTELEGRAM_GROUP_CHAT_IDS. - Restart the bot.
python bot.py/summary(or/daily_summary) — generate a digest for the last 24 hours on demand (does not delete messages from the database)./chatid— show the current chat ID.
t.me/c/...links work for supergroups (IDs starting with-100) and open only for chat members.- The system prompt for topic extraction lives in prompts/daily_summary.txt — tune it to your chat's style.
- No external database required: everything is stored in a single SQLite file.