Telegram chat with buffering
Workflow Description
A Telegram chatbot automation template with intelligent buffering. It receives messages through Telegram, queues and sorts them, processes them via an AI agent powered by OpenAI, retrieves conversation context from Postgres, and sends intelligent responses back to users.
How it works
- 1.Receive incoming message from Telegram trigger
- 2.Queue and sort messages by priority using Sort node
- 3.Process message through AI Agent with OpenAI model
- 4.Retrieve conversation history from Postgres memory
- 5.Send response back to user via Telegram
Use cases
- Build an intelligent chatbot that maintains full conversation context across sessions
- Handle high-volume concurrent message processing while preserving message order
- Manage long-running conversations with persistent memory of previous interactions
Requirements
- Configure OpenAI API key and enable AI Agent permissions
- Set up Postgres database with conversation context storage tables
- Connect Telegram bot with valid Bot API token
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (22)
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Reply
Set
Receive Message
Set
Wait 10 Seconds
Wait
Sticky Note3
Sticky Note
Add to Queued Messages
Supabase
No Operation, do nothing
No Op
Aggregate
Aggregate
Delete Queued Messages
Supabase
Sticky Note2
Sticky Note
OpenAI Chat Model
OpenAI
Sort by Message ID
Sort
Get Queued Messages
Supabase
Check Most Recent Message
If
AI Agent
Agent
Postgres Chat Memory
Memory Postgres Chat
Sticky Note4
Sticky Note
Sticky Note5
Sticky Note
Sticky Note6
Sticky Note
Sticky Note8
Sticky Note
Sticky Note9
Sticky Note