In a typical WhatsApp conversation, we often receive 2–3 messages in a row that are all part of the same context. Instead of sending each line individually in the Gmail output, I’d like to group them together into a single, consolidated message before sending
Does anyone have advice on which node I should use for this? Ideally, the node would be able to wait for about 90 seconds, store incoming messages during that time, and then combine them into one context before passing them to the next node
PS: I hope I’m explaining this clearly I tried to keep it as simple as possible
A Merge node won’t solve this because each WhatsApp message starts a separate execution. You need a small buffer between the incoming webhook and Gmail.
I’d write each message to Google Sheets with `conversation_id`, `message`, `received_at`, and `processed=false`. Then use a separate Schedule Trigger workflow to find conversations whose latest message is at least 90 seconds old, sort their messages by `received_at`, join the text in a Code node, send one Gmail, and mark those rows processed.
I wouldn’t use `$getWorkflowStaticData(‘global’)` for this. I lost tracking state that way because it doesn’t persist during manual executions and gets wiped when a workflow is re-imported.
Also recheck the latest timestamp immediately before Gmail, otherwise a new message arriving during processing can be split into the wrong batch.
David’s buffer-table approach is the direction I would use too.
The main thing I would add is to treat this as a debounce problem, not a Merge-node problem. Each WhatsApp message is its own execution, so the workflow needs somewhere durable to hold the messages until the conversation goes quiet.
A clean version would be:
Incoming WhatsApp message → store row with conversation_id, message, received_at, processed=false
Then a separate scheduled workflow runs every minute and looks for conversations where the newest unprocessed message is older than 90 seconds.
Before sending Gmail, query those rows again, sort by received_at, join the messages, send one email, then mark those rows processed.
The extra re-check right before Gmail matters because a new WhatsApp message can arrive while the batch is being prepared. Without that guard, you can accidentally split one real conversation into two emails.
Both the buffer table and the debounce framing are right. One failure mode nobody has flagged yet, and it tends to show up in production rather than in testing.
If the schedule workflow ever takes longer to run than its own interval, two executions overlap. Both query for unprocessed conversations, both find the same rows, and your user gets two emails. Marking rows processed after the Gmail send leaves that window wide open, and it widens every time Gmail is slow.
The fix is to claim before you send rather than after. Write a claim to the rows you picked up first (something like processed = sending, plus a run id), re-read to confirm you actually own them, then send, then mark done. It looks like a pointless extra round trip right up until the first time two runs overlap.
The other thing worth deciding early is storage. Sheets is fine at conversation volumes, but it has a per-user write quota that is easy to reach once you are writing every inbound message plus two status updates per batch. If this is heading anywhere near real WhatsApp traffic, the Redis suggestion is the better call, or Postgres if you already run one. Swapping later is more painful than it sounds, because the claim logic changes shape with the storage.
@Maxwell45 This is the classic debounce pattern, and there’s no single built-in node that does it, you need a small combo:
Trigger fires on each incoming message → write it to storage Redis, a Data Table, or even Airtable keyed by the sender’s phone number, appending to a running buffer rather than overwriting.
Wait node set to 90 seconds.
After the wait, check a timestamp, if the buffer’s “last updated” time is still within the last ~5 seconds of when this particular execution started waiting, it means no newer message has come in, so this execution is the “last” one and should proceed. If a newer message arrived during the wait, this execution should just stop (another execution will pick up the final flush).
If proceeding: read the full buffer, join the messages into one string, clear the buffer, and pass it downstream to Gmail.
The reason it’s not simpler: every incoming WhatsApp message triggers its own separate execution in n8n (there’s no native “hold and merge” trigger), so you need external state (Redis is ideal, fast, and has a natural TTL for buffer expiry) to coordinate across those parallel executions and make sure only the last one actually sends.