Process Telegram messages with multi-session AI conversations
Workflow Description
Automation that receives messages from multiple Telegram channels, maintains conversation context per session, and sends intelligent replies using OpenAI models while recording data in Google Sheets.
How it works
- 1.Receive incoming messages from connected Telegram channels via trigger
- 2.Maintain separate memory buffer for each conversation session
- 3.Process message through AI agent using OpenAI language model
- 4.Route response based on message analysis (reply, store, or execute action)
- 5.Log conversation and results automatically to Google Sheets
Use cases
- Multi-channel customer support bot handling concurrent inquiries across Telegram channels
- Smart chatbot that remembers conversation history and delivers personalized responses
- Automated data collection from Telegram conversations for analysis and organization
Requirements
- Active OpenAI account with valid API key
- Telegram bot or channel configured for receiving messages
- Google Sheets spreadsheet for logging conversation data
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 (38)
OpenAI Chat Model
OpenAI
Simple Memory
Memory Buffer Window
Get message
Set
Command or text?
Switch
Get session
Google Sheets
Disable previous session
Google Sheets
Set new session
Google Sheets
Session activated
Set
Send response
Set
Update database
Google Sheets
Sticky Note
Sticky Note
Summarization Chain
Chain Summarization
OpenAI Chat Model1
OpenAI
OpenAI Chat Model2
OpenAI
Basic LLM Chain
LLM Chain
Get message1
Set
Set to expire
Google Sheets
Exist?
If
OK
Set
KO
Set
Trim resume
Code
Get session1
Google Sheets
Prompt + Resume
Code
Send summary
Set
Get message2
Set
Trim question
Code
Set new current session
Google Sheets
Response + Text
Google Sheets
fullText
Code
Send answer
Set
Send current session
Set
Sticky Note1
Sticky Note
Sticky Note2
Sticky Note
Sticky Note3
Sticky Note
Sticky Note4
Sticky Note
Sticky Note5
Sticky Note
Sticky Note6
Sticky Note
Telegram Chatbot
Agent