Create a robust n8n workflow for a Telegram chatbot that transcribes voice messages, intelligently batches user input, and uses an OpenAI agent with Supabase RAG.
Download this n8n workflow template and start using it instantly.
• Automation developers seeking advanced n8n templates for conversational AI.
• Users needing high-availability n8n workflow solutions with debouncing capabilities.
• Technical teams integrating OpenAI agents with external knowledge bases (Supabase).
• Anyone requiring a smart system to manage and batch rapid-fire user messages within n8n.
This comprehensive n8n workflow demonstrates how to build a resilient and sophisticated Telegram chatbot capable of handling both text and voice input. The core value of this n8n automation lies in its message batching and debouncing mechanism, which prevents the AI model from being overwhelmed by multiple, rapid messages from the same user. By leveraging Google Sheets to temporarily store messages and track user waiting status, the system intelligently waits for a configurable period (e.g., 30 seconds) before compiling all recent inputs into a single prompt for the AI Agent. This approach optimizes API costs and ensures the AI receives complete context, resulting in highly coherent responses. The initial phase of this n8n node pipeline incorporates OpenAI Whisper technology to accurately transcribe voice messages, ensuring seamless accessibility for all users.
The entire process is initiated by the Telegram Trigger, which listens for incoming messages.
Link Filter) to check if the incoming message contains a voice file ID. If true, the Get Audio File Telegram n8n node downloads it, and the Transcribe a recording OpenAI n8n node converts the audio to text (Whisper). If false, the text passes directly through.Edit Fields n8n node, standardizing the user message (processedMessage) and sessionId.Append row in sheet n8n node.No Rows code n8n node ensures that new users default to a 'not waiting' status.What to do If n8n node decides whether to start the batching timer. It proceeds if the user is not waiting OR if the last message was received over 30 seconds ago.Update row in sheet), initiates a fixed time pause using the Wait n8n node, and then uses Get row(s) in sheet to pull all accumulated messages.Batch Messages code n8n node combines the retrieved messages into a single text block.AI Agent n8n node processes the batched message. This agent utilizes the OpenAI Chat Model, Simple Memory (for session history), and a Supabase Vector Store (for RAG capabilities).Send message Back to TG n8n node, and the user's waiting status is cleared by the final Google Sheets operation, completing the n8n workflow execution.date | userid | message.userid | iswaiting | lastupdated.Telegram Trigger n8n node and execute it once to register the webhook with Telegram.AI Agent n8n node and ensure the Supabase Vector Store n8n node is correctly configured with your knowledge base table ID and embedding credentials. Telegram Trigger n8n trigger: The entry point of the n8n workflow, configured to listen for new message updates.
Transcribe a recording (OpenAI n8n node): Uses the OpenAI Whisper model to convert audio files received via Telegram into text, enabling voice message handling.
Append row in sheet (Google Sheets n8n node): Saves the user's message, date, and user ID to the 'Msg Retention' sheet for later batch processing.
What to do (If n8n node): Implements the debouncing logic, checking if a user's lastupdated time is older than the wait period (30 seconds) or if the user is not currently marked as iswaiting.
Wait n8n node: Pauses the execution on the batching path for 30 seconds, allowing for additional user messages to arrive and accumulate.
Batch Messages (Code n8n node): Custom JavaScript n8n node responsible for retrieving multiple rows from Google Sheets and concatenating them into a single, cohesive input string for the AI agent.
AI Agent n8n node: The core of the conversational flow. It orchestrates the AI components, including the OpenAI Chat Model, Simple Memory (for context), and the Supabase Vector Store (for RAG context retrieval).
Supabase Vector Store n8n node: Configured as a tool for the AI Agent, allowing the agent to access and retrieve relevant information from an external vector database (RAG knowledge base).
Use this n8n workflow to automatically summarize recent Telegram chat history using an AI agent powered by OpenRouter. This efficient n8n templates solution sends the digest back to the chat.

Secure your internal Telegram bots using this n8n workflow template. It manages user access by checking permissions against a database (like n8n Data Tables) before executing sensitive tasks.

Use this powerful n8n workflow to create a Telegram bot that extracts TikTok and LinkedIn profile data using Dumpling AI, transcribes voice messages, and automatically stores results in Google Sheets. Get started with n8n templates for data mining.

Generate personalized fitness plans using Gemini AI and a Telegram bot. This powerful n8n workflow handles multimodal input (text or photo) for ultimate customization.

Implement a powerful n8n workflow for interior designers. Catalog furniture, document rooms, and generate custom designs using Gemini AI, all controlled via a Telegram bot.

Use this powerful n8n workflow template to create a real-time translation bot. It utilizes the OpenAI n8n node for instant language detection and translation, ensuring seamless communication in multilingual chat groups.









































