I would like to make the bot wait 30 seconds when receiving a text message. Within 30 seconds it will be in the mode of receiving new messages.
And after 30 seconds, if it has received several text messages, it will merge them into one, then the message will go to the nodes.
What’s the problem I want to solve:
There are users who write their request with multiple messages rather than one in a short period of time:
Message from user: Hi
Message from user: I would like
Message from user: your
Message from user: address
Right now I have this as 4 separate requests, and the bot responds to each of them.
I would like this kind of requests to be merged into one within those 30 seconds and the output would be:
Message from user: Hi I would like your address
Telegram Workflow — Local & Resilient Design (n8n)
Hey everyone,
Here’s a quick explanation of a Telegram-based workflow I created in n8n (self-hosted).
First, apologies: some nodes are named in French, as I’m a French user. Feel free to rename everything to English if needed — the logic is universal.
Goal
The idea was to collect and merge multiple Telegram messages sent in a short period, and process them as a single block — without using any external database or persistent state system.
No External DB
Instead of relying on Supabase, Redis, or even n8n variables, I use a simple local file to store the timestamp of the last processed message.
This allows the workflow to:
Block execution if it was triggered less than 60 seconds ago.
Otherwise, wait a few seconds, collect additional messages, merge them, and mark them as read.
How it works (simplified)
Workflow is triggered by a message on Telegram.
We check the last timestamp stored in a local file (/tmp/tmp_verroutelegram.txt).
If the message is too recent (less than 60s), the workflow stops.
If allowed:
We store the new timestamp (from Telegram’s message.date field).
We wait a few seconds (e.g., 10s).
We retrieve all unread messages from the same user via getUpdates.
Merge them into a single block (with formatting).
Mark all messages as read.
Advantages
Self-contained: No need for external tools or state.
Clean: Nothing is stored long term, just a temp file.
Reusable: Easy to share or adapt for any n8n user.
What you need to change
If you want to reuse it:
Modify the Telegram bot token in the HTTP Request nodes.
Adjust the chat ID filter or authorized ID in the validation node.
Let me know if you want the full workflow JSON — happy to share!