AutomationMart
Home/Browse/End of turn detection for smoother AI agent chats with Telegram and Gemini
n8n

End of turn detection for smoother AI agent chats with Telegram and Gemini

n8nn8n23 modulesv1.0
TelegramGemini

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 over multiple messages or when it comes to voice, break our speech with the odd pause or umms and ahhs. If an agent replies to every message, it's likely to interrupt us before we finish our thoughts and it can get very annoying! Previously, I

At a glance

End of turn detection for smoother AI agent chats with Telegram and Gemini is a ready-made n8n workflow you import as a workflow JSON file — no build required. It connects Telegram, Gemini. It's free to download. Follow the 5-step import below to go live in minutes.

Platform
n8n
Connects
Telegram, Gemini
Modules
23
Price
Free
Version
v1.0
End of turn detection for smoother AI agent chats with Telegram and Gemini workflow diagram

About this workflow

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 over multiple messages or when it comes to voice, break our speech with the odd pause or umms and ahhs. If an agent replies to every message, it's likely to interrupt us before we finish our thoughts and it can get very annoying! Previously, I demonstrated a simple technique for buffering each incoming message by 5 seconds but that approach still suffers in some scenarios when more time is needed. This technique has no arbitrary time limit and instead uses AI to figure out when its the agent's turn based on the user's message, allowing for the user to take all the time they need. How it works Telegram messages are received but no reply is generated for them by default. Instead they are sent to the prediction subworkflow to determine if a reply should be generated. The prediction subworkflow begins by checking Redis for the current user's prediction session state. If this is a new "utterance", it kicks off the "predict end of utterance" loop - the purpose of which is to buffer messages in a smart way! New users message can continue to be accepted by the workflow until enough is collected to allow our prediction classifier to determine the end of the utterance has been reached. The loop is then broken and the buffered chat messages are combined and sent to the AI agent to generate a response and sent to the user via the telegram node. The prediction session state is then deleted to signal the workflow is ready to start again with a new message. How to use This system sits between your preferred chat platform and the AI agent so all you need to do is replace the telegram nodes as required. Where LLM-only prediction isn't working well enough, consider more traditional code-based checking of heuristics to improve the detection. Ideally you'll want a fast but accurate LLM so your user isn't waiting longer than they have to - at time of writing Gemini-2.5-flash-lite was the fastest in testing but keep a look out for smaller and more powerful LLMs in the future. Requirements Gemini for LLM Redis for session management Telegram for chat platform

n8n

How to import this n8n workflow

  1. 1

    Download the workflow JSON file after purchase.

  2. 2

    Open n8n → click the menu → Import from File.

  3. 3

    Select the downloaded JSON and import.

  4. 4

    Set up credentials for each node that requires them.

  5. 5

    Click Execute Workflow to test, then activate.

Setup guide

Setup guide included

Purchase to unlock the full step-by-step guide

Related N8n workflows

Create and publish AI videos with Sora 2 Cameos, Gemini, and Blotato

Overview This workflow automatically creates short-form AI videos using Sora 2 Cameos, powered by n8n and AI agents. It connects viral content collection, AI script and prompt generation, video rendering, video merging, and multi-platform publishing into a single fully automated system. Once configured, the workflow runs end to end without manual editing or intervention. The workflow is designed for creators, marketers, and affiliate builders who want to scale faceless or avatar-style AI videos

Free

Extract text from images with Telegram Bot & Gemini 2.0 Flash OCR

Description Turn your Telegram bot into a powerful OCR (Optical Character Recognition) tool. This workflow allows you to send any image (like a screenshot, a photo of a document, or a picture of a sign) to your bot, and it will instantly extract and send back the text from that image. Powered by Google's advanced Gemini AI, this automation is perfect for quickly digitizing notes, saving important snippets, or avoiding manual typing. How it works This workflow performs a few high-level

Free

Get word definition from Urban Dictionary for a new message with the word in Telegram

Every time a new message with a word is received on Telegram, Make will automatically get the word definition and send it to a specified Telegram chat/channel.

Free

Generate newsletter drafts from real-time product updates using Qontext, Gemini, and Gmail

Generate newsletter content from real-time product updates and per-recipient context using Qontext, Gemini, HubSpot and Gmail.

Free

Create Telegram Bot messages for new Toky calls

Every time a call is ended in Toky, Make will automatically create a new message in Telegram.

Free

Hotel receptionist with WhatsApp, Gemini model-switching, Redis & Google Sheets

Overview This project is an AI-powered hotel receptionist built using n8n, designed to handle guest queries automatically through WhatsApp. It integrates Google Gemini, Redis, MySQL, and Google Sheets via LangChain to create an intelligent conversational system that understands and answers booking-related questions in real time. A standout feature of this workflow is its AI model-switching system — it dynamically assigns users to different Gemini mo

Free

Auto-audit SEO traffic drops with AI & Google Search Console to Slack

Auto-Audit SEO Traffic Drops with AI & GSC Automatically monitor your Google Search Console data to catch SEO performance drops before they become critical. This workflow identifies pages losing rankings and clicks, scrapes the live content, and uses AI to analyze the gap between "Search Queries" (User Intent) and "Page Content" (Reality). It then delivers actionable fixes—including specific Title rewrites and missing H2 headings—directly to Slack. Ideal for SEO managers, content marketers, and

Free

AI premium proposal generator with OpenAI, Google Slides & PandaDoc

AI Proposal Generator System Categories - Sales Automation - Document Generation - AI Business Tools This workflow creates a complete AI-powered proposal generation system that transforms simple form inputs into professional, personalized proposals in under 30 seconds and can be deployed during live sales calls, allowing you to send polished proposals before the call even ends. Benefits - Instant Proposal Generation - Convert 30-second form inputs into professional proposals

Free

Reviews

No reviews yet

Be the first to buy and share your experience.

Leave a review

Sign in to share your experience with this workflow.

Log in to review
Free
No ratings yet

Create a free account to purchase workflows.

  • JSON blueprint — instant download
  • Setup guide PDF included
  • 5 downloads · valid 30 days
  • Works with n8n

Need help setting this up?

Book a 3-hour live setup session with an Agility consultant.

₹2,499/ session
3 hrs · video call
  • Configure live on Google Meet / Zoom
  • Free follow-up if workflow has defects
  • Platform expert assigned to you
Book installation session
Free