Project Details
Overview
I developed a custom Telegram bot for a private group called Vabastegan, which brings together long-time high school friends now spread across multiple international time zones. Because members reside in different parts of the world, keeping up with active chat discussions often proved difficult for anyone away from their phone for a few hours or days. To solve this, I designed and built an automated backend using n8n, PostgreSQL, and AI models to generate chat summaries, answer specific questions, track member participation, and manage group memories.
The Problem
Group members living across different time zones frequently missed ongoing conversations. When catching up after missing a day or two of messages, reviewing hundreds of unread texts was inefficient and time-consuming. The group required a system that could summarize unread conversations on demand, allow members to query chat history, record specific rules or memories, and highlight active group members without interrupting normal messaging flow.
My Approach
I structured the backend around n8n, designing 10 distinct workflows to handle different user commands and tasks. I utilized Cursor as my primary development editor to write custom components and import them cleanly into n8n. To maintain state, group rules, and memory logs, I integrated PostgreSQL as the database layer. I incorporated AI models into the workflows to process incoming text data, generate concise chat summaries, and handle context-aware responses when members query the bot.
The Solution
The finished system operates directly within the Telegram group through dedicated commands and text interactions:
- Chat Summarization: Users trigger the
/summarycommand to receive an automated overview of recent unread messages and topics discussed. - Interactive Q&A: Members ask questions by replying to a message using the
/askcommand, which prompts the AI-driven workflow to return a direct answer. - Rule Learning: Users introduce guidelines or reference information to the system using the
/remembercommand. - Activity & Memory Management: The bot tracks activity metrics, highlights active group contributors, and retains shared group memories to announce back to the chat over time.
The 10 n8n workflows process these incoming requests, interact with the PostgreSQL database, run the text through AI processing, and post clear responses back to the group.
Technical Stack
- n8n: I used n8n as the primary workflow engine to orchestrate 10 backend workflows connecting incoming messages, AI processing, and database actions.
- Telegram: It served as the interactive interface where group members execute commands and view automated summaries and answers.
- PostgreSQL: I implemented PostgreSQL to store structured data, group memories, activity metrics, and learned rules.
- Cursor: I used Cursor as my development environment to write code modules and import them into n8n.
- Artificial Intelligence: I integrated AI models into the n8n workflows to summarize long text threads and generate contextual answers to user queries.
Results & Impact
The automation provides the group with an efficient way to keep up with conversation threads without reading hundreds of accumulated messages. Members can catch up instantly using simple commands, retrieve stored memories, and see engagement statistics. The combination of n8n workflows and PostgreSQL ensures structured data handling, while the AI processing provides clear text summaries for all group members.
Key Takeaways
- Multi-workflow backend: I built 10 distinct n8n workflows to manage command parsing, AI processing, data storage, and responses.
- Structured data storage: Integrating PostgreSQL allowed the system to maintain activity statistics and retain long-term group memories.
- Custom dev integration: Using Cursor enabled efficient code writing and seamless import into n8n workflows.
- Practical AI application: Deploying AI models provided context-aware chat summarization and Q&A directly within a multi-time-zone group chat.