← All N8N workflows
AI & researchChat TriggerCodeExecute Workflow TriggerIfInformation Extractor

⏳ Inactivity & Threshold Check

Configured with Chat Trigger, Execute Workflow Trigger, Information Extractor, OpenAI Chat Model, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen clicking ‘Testworkflow’Manual TriggerRoutingNo Operation, donothing1No OpAI & modelsInformation ExtractorInformation ExtractorAI & modelsOpenAI Chat ModelOpenAI Chat ModelCodeget wait secondsCodeData storeSet last_seenRedisData storeGet waiting_replyRedisTransformMod inputEdit FieldsRoutingwaiting_reply?IfTriggerWhen chat messagereceivedChat TriggerData storeSet waiting_replyRedisData storeGet bufferRedisData storeDelete buffer_inRedisData storeDelete waiting_replyRedisWaitWaitSecondsWaitData storeBuffer messagesRedisData storeSet buffer_countincrementRedisData storeGet last_seenRedisData storeGet buffer_countRedisTransformMap ouputEdit FieldsRoutingCheck Inactivity +CountIfData storeDelete waiting_reply1RedisRoutingNo Operation, donothing2No OpWaitWaitWaitTriggerWhen Executed byAnother WorkflowExecute Workflow TriggerTransformMock input dataEdit FieldsRoutingNo Operation, donothing3No Op

Node categories in this workflow

  • Trigger
  • Routing
  • AI & models
  • Code
  • Data store
  • Transform
  • Wait

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
When clicking ‘Test workflow’TriggerManual TriggerSee node parameters
No Operation, do nothing1RoutingNo OpSee node parameters
Information ExtractorAI & modelsInformation ExtractorSee node parameters
OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
get wait secondsCodeCodeSee node parameters
Set last_seenData storeRedisset
Get waiting_replyData storeRedisget
Mod inputTransformEdit FieldsSee node parameters
waiting_reply?RoutingIfSee node parameters
When chat message receivedTriggerChat TriggerSee node parameters
Set waiting_replyData storeRedisset
Get bufferData storeRedisget
Delete buffer_inData storeRedisdelete
Delete waiting_replyData storeRedisdelete
WaitSecondsWaitWaitSee node parameters
Buffer messagesData storeRedispush
Set buffer_count incrementData storeRedisincr
Get last_seenData storeRedisget
Get buffer_countData storeRedisget
Map ouputTransformEdit FieldsSee node parameters
Check Inactivity + CountRoutingIfSee node parameters
Delete waiting_reply1Data storeRedisdelete
No Operation, do nothing2RoutingNo OpSee node parameters
WaitWaitWaitSee node parameters
When Executed by Another WorkflowTriggerExecute Workflow TriggerSee node parameters
Mock input dataTransformEdit FieldsSee node parameters
No Operation, do nothing3RoutingNo OpSee node parameters

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • openAiApi
  • redis

Workflow notes

🧹 Buffer Cleanup

🧹 Buffer Cleanup

After consolidation and reply:

  • DELETE keys:

    • buffer_in:{{context_id}}
    • buffer_count:{{context_id}}
    • waiting_reply:{{context_id}}
📥 Input Buffer

📥 Input Buffer

  1. Save incoming message

    • Push the new message into Redis list buffer_in:{{context_id}}.
  2. Update metadata

    • Set last_seen:{{context_id}} to the current timestamp (with a TTL of waitSeconds + 60).
    • INCR the counter key buffer_count:{{context_id}} (also expiring after waitSeconds + 60).
  3. Check “waiting” flag

    • GET waiting_reply:{{context_id}}.
    • If it’s null (no batch in flight), SET it to true with TTL waitSeconds to block concurrent triggers.
⏳ Inactivity & Threshold Check

⏳ Inactivity & Threshold Check

  1. Fetch state

    • GET last_seen:{{context_id}} (when the last message arrived)
    • GET buffer_count:{{context_id}} (how many messages are queued)
  2. Evaluate trigger

    • Inactivity: (now – last_seen) ≥ waitSeconds * 1000
    • Or threshold: buffer_count ≥ 1 (or your desired batch size)
  3. Branch

    • True: proceed to “Get buffer” and consolidate.
    • False: exit (noOp) and let the waiting‐node/flag mechanism retry later.
⏳ Inactivity & Threshold Check

⏳ Inactivity & Threshold Check

Purpose and structure

This folder contains the ⏳ Inactivity & Threshold Check workflow. Its executable nodes use chatTrigger, code, executeWorkflowTrigger, if, informationExtractor, lmChatOpenAi, manualTrigger, noOp, redis, set, wait. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

When clicking ‘Test workflow’, When chat message received, When Executed by Another Workflow

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Wait/0903_Wait_Redis_Automate_Triggered.json MIT; preserve source notices.

More in AI & research