End of turn detection for smoother AI agent chats with Telegram and Gemini
Ready for 3.0What this workflow does
This AI workflow has 23 nodes and runs on Telegram events (message) (plus 1 other trigger). Along the way it connects Telegram, Google Gemini Chat Model, Redis Chat Memory and Redis.
How it runs
Trigger: On Telegram events (message) (plus 1 other trigger).
- Is Bot command? (If): checks a condition and branches into true / false
- Get Session (Redis): get
- Get Values (Edit Fields (Set)): sets 3 fields: from, message, createdAt
- Update Session (Redis): set
- Call Prediction Subworkflow (Execute Sub-workflow): calls another n8n workflow
- Get Updated Session Values (Edit Fields (Set)): sets 1 field: data
- is New Session? (If): checks a condition and branches into true / false
- Is Waiting? (If): checks a condition and branches into true / false
- Update Session (Redis): set
- Resume Wait Node (HTTP Request): calls an HTTP API
…plus 7 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (14)
- Telegram Trigger
n8n-nodes-base.telegramTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - Google Gemini Chat Model
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - Redis Chat Memory
@n8n/n8n-nodes-langchain.memoryRedisChat - Edit Fields (Set)
n8n-nodes-base.set - Redis
n8n-nodes-base.redis - If
n8n-nodes-base.if - No Operation, do nothing
n8n-nodes-base.noOp - Wait
n8n-nodes-base.wait - Text Classifier
@n8n/n8n-nodes-langchain.textClassifier - Telegram
n8n-nodes-base.telegram - HTTP Request
n8n-nodes-base.httpRequest - Execute Sub-workflow
n8n-nodes-base.executeWorkflow - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger
From the author
This n8n template demonstrates one approach to achieve a more natural and less frustration conversations with AI agents by reducing interrupts by predicting the end of user utterances. When we text or chat casually, it's not uncommon to break our sentences…