Message-Batching Buffer Workflow (n8n) This workflow implements a lightweight message-batching buffer using Redis for temporary storage and a JavaScript consolidation function to merge messages. It collects incoming user messages per session, waits for a configurable inactivity window or batch size threshold, consolidates buffered messages via custom code, then clears the buffer and returns the combined response—all without external LLM calls. --- 🔑 Key Features Redis-backed buffer queues incom

Message-Batching Buffer Workflow (n8n) This workflow implements a lightweight message-batching buffer using Redis for temporary storage and a JavaScript consolidation function to merge messages. It collects incoming user messages per session, waits for a configurable inactivity window or batch size threshold, consolidates buffered messages via custom code, then clears the buffer and returns the combined response—all without external LLM calls. --- 🔑 Key Features Redis-backed buffer queues incoming messages per contextid. Centralized Config Parameters node to adjust thresholds and timeouts in one place. Dynamic wait time based on message length (configurable minWords, waitLong, waitShort). Batch trigger fires on inactivity timeout or when buffercount ≥ batchThreshold. Zero-cost consolidation via built-in JavaScript Function (consolidate buffer)—no GPT-4 or external API required. --- ⚙️ Setup Instructions 1. Extract Session & Message Trigger: When chat message received (webhook) or When clicking ‘Test workflow’ (manual). Map inputs: set variables contextid and message into a Set node named Mock input data (for testing) or a proper mapping node in production. 2. Config Parameters Add a Set node Config Parameters with: All downstream nodes reference these JSON values dynamically. 3. Determine Wait Time Node: get wait seconds (Code) JS code: 4. Buffer Message in Redis Buffer messages: LPUSH bufferin:{{$json.contextid}} with payload {text, timestamp}. Set buffer\count increment: INCR buffercount:{{$json.contextid}} with TTL {{$json.waitSeconds + 60}}. Set last\seen: record lastseen:{{$json.contextid}} timestamp with same TTL. 5. Check & Set Waiting Flag Get waiting\reply: if null, Set waiting\reply to true with TTL {{$json.waitSeconds}}; else exit. 6. Wait for Inactivity WaitSeconds (webhook): pauses for {{$json.waitSeconds}} seconds before batch evaluation. 7. Check Batch Trigger Get last\seen and Get buffer\count. IF (now - lastseen) ≥ waitSeconds 1000 OR buffercount ≥ batchThreshold, proceed; else use Wait node to retry. 8. Consolidate Buffer consolidate buffer (Code): 9. Cleanup & Respond Delete Redis keys: bufferin, buffercount, waitingreply, lastseen (for the contextid). Return consolidated message to the user via your chat integration. --- 🛠 Customization Guidance Adjust thresholds by editing the Config Parameters node. Change concatenation (e.g., line breaks) by modifying the join separator in the consolidation code. Add filters (e.g., ignore empty or system messages) inside the consolidation Function. Monitor performance: for very high volume, consider sharding Redis keys by date or user segments. --- © 2025 Innovatex • Automation & AI Solutions • innovatexiot.carrd.co • LinkedIn
Download the workflow JSON file after purchase.
Open n8n → click the menu → Import from File.
Select the downloaded JSON and import.
Set up credentials for each node that requires them.
Click Execute Workflow to test, then activate.
Setup guide included
Purchase to unlock the full step-by-step guide
No reviews yet
Be the first to buy and share your experience.
Leave a review
Sign in to share your experience with this workflow.
Create a free account to purchase workflows.
Need help setting this up?
Book a 3-hour live setup session with an Agility consultant.