This Telegram bot summarizes messages from a group chat based on a selected time range (e.g., last 12 hours, 1 day, 1 week) or message count. It uses Google Gemini API to generate concise summaries, making it easier for users to catch up on important discussions.
I often miss out on reading all the messages in my group chats due to a busy schedule. This bot helps me stay informed by providing a summarized overview of key discussions over a selected period.
✅ Log messages from a Telegram group chat
✅ Summarize messages based on:
- Time ranges:
12 hours,1 day,1 week, etc. - Message count: Last N messages (e.g., last 50, last 100 messages)
✅ Uses Google Gemini API for high-quality AI-powered summaries
✅ API keys stored securely as environment variables
✅ Lightweight and fast - no local AI models to download
- Start the bot by adding it to your group chat.
- Use
/startto see all available options. - Use
/summarize <option>to get a summary:- Time-based:
/summarize 1day,/summarize 12hr,/summarize 1week - Count-based:
/summarize last 50,/summarize last 100(summarizes last N messages)
- Time-based:
-
Clone the repository:
git clone https://github.com/SamNm89/Telegram_Summarizer_Bot.git cd Telegram_Summarizer_Bot -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envand add your secrets:TELEGRAM_BOT_TOKEN: Your Telegram Bot Token (get it from @BotFather)GOOGLE_API_KEY: Your Google API key (required)- Get your API key from Google AI Studio
- Copy
-
Run the bot:
python telegram_bot.py
- Python 3.7+
pyTelegramBotAPI- Telegram bot API wrapperpandas- Data manipulationpython-dotenv- Environment variable managementgoogle-generativeai- Google Gemini API
Note: This bot uses Google Gemini API exclusively. No local AI models are required, making it lightweight and fast to install (~50-70 MB total).
To keep the bot running continuously on a server, use:
nohup python telegram_bot.py &This project is licensed under the MIT License - see the LICENSE file for details.
Forked & Enhanced by: SamNm89