A simplified Telegram bot that monitors channels/chats, processes messages with AI, and sends concise summaries to your Saved Messages.
-
Install dependencies (using the existing virtual environment):
source .venv/bin/activate pip install -r requirements.txt -
Configure the bot:
- Edit
config.yamlwith your settings - Edit
watchlist.yamlto specify chats to monitor - Your API credentials are already loaded from
.env
- Edit
-
Run the bot:
source .venv/bin/activate python main.py
- 📥 Collect - Get recent messages from specified Telegram chats
- 🔍 Filter - Keep only messages from the last X hours (client-side)
- 🤖 Process - Send filtered messages to OpenAI for AI analysis
- 📄 Output - Generate Markdown digest file and send concise summary to Telegram
├── main.py # Entry point and orchestration
├── config.py # Configuration loading (YAML + .env)
├── telegram.py # Telegram API interface (Telethon)
├── llm.py # OpenAI API provider
├── output.py # Markdown files and Telegram summaries
├── config.yaml # Bot configuration
├── watchlist.yaml # Chats to monitor
├── prompt.txt # System prompt for AI
├── requirements.txt # Dependencies
└── digests/ # Output folder for Markdown files
- telegram: API credentials and session settings
- llm: OpenAI model and API key
- settings: Hours back to look, output directory
- chats: List of channels/chats to monitor
- Each chat can be enabled/disabled individually
- Use
@usernamefor public channels,chat_idfor private chats
- Markdown files: Detailed digest saved to
digests/folder - Telegram summary: Concise summary sent to your Saved Messages
Each module can be replaced independently:
- Change LLM provider → edit
llm.pyonly - Change output format → edit
output.pyonly - Change Telegram client → edit
telegram.pyonly - Change configuration → edit
config.pyonly
# Activate virtual environment
source .venv/bin/activate
# Run digest generation once
python main.py
# Show help
python main.py --helpThe bot will:
- Load configuration from YAML files and .env
- Connect to Telegram and collect recent messages
- Process messages with OpenAI to generate structured digest
- Save detailed Markdown file to
digests/folder - Send concise summary to your Telegram Saved Messages
- Authentication: First run will prompt for phone number and verification code
- No messages: Check
watchlist.yamlchat names and enable status - API errors: Verify OpenAI API key in
.envfile - Import errors: Make sure virtual environment is activated:
source .venv/bin/activate