Skip to main content

๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes

Workflow preview

Workflow preview
100%
๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

How it works This template is a powerful, reusable utility for managing stateful, long running processes . It allows a main workflow to be paused indefinitely at "checkpoints" and then be resumed b...

Best for

  • Engineering automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.filter, n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.splitout, n8n-nodes-base.if, n8n-nodes-base.noop, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Lucas Peyrin.

Original n8n.io source

1.1 Workflow description

Title
๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes
Workflow name
๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes

How it works

This template is a powerful, reusable utility for managing stateful, long-running processes. It allows a main workflow to be paused indefinitely at "checkpoints" and then be resumed by external, asynchronous events.

This pattern is essential for complex automations and I often call it the "Async Portal" or "Teleport" pattern.

The template consists of two distinct parts:

  1. The Main Process (Top Flow): This represents your primary business logic. It starts, performs some actions, and then calls the Portal to register itself before pausing at a Wait node (a "Checkpoint").
  2. The Async Portal (Bottom Flow): This is the state-management engine. It uses Workflow Static Data as a persistent memory to keep track of all paused processes. When an external event (like a new chat message or an approval webhook) comes in with a specific session_id, the Portal looks up the corresponding paused workflow and "teleports" the new data to it by calling its unique resume_url.

This architecture allows you to build sophisticated systems where the state is managed centrally, and your main business logic remains clean and easy to follow.

When to use this pattern

This is an advanced utility ideal for:

  • Chatbots: Maintaining conversation history and context across multiple user messages.
  • Human-in-the-Loop Processes: Pausing a workflow to wait for a manager's approval from an email link or a form submission.
  • Multi-Day Sequences: Building user onboarding flows or drip campaigns that need to pause for hours or days between steps.
  • Any process that needs to wait for an unpredictable external event without timing out.

Set up steps

This template is a utility designed to be copied into your own projects. The workflow itself is a live demonstration of how to use it.

  1. Copy the Async Portal: In your own project, copy the entire Async Portal (the bottom flow, starting with the A. Entry: Receive Session Info trigger) into your workflow. This will be your state management engine.

  2. Register Your Main Process: At the beginning of your main workflow, use an Execute Workflow node to call the Portal's trigger. You must pass it a unique session_id for the process and the resume_url from a Wait node.

  3. Add Checkpoints: Place Wait nodes in your main workflow wherever you need the process to pause and wait for an external event.

  4. Trigger the Portal: Configure your external triggers (e.g., your chatbot's webhook) to call the Portal's entry trigger, not your main workflow's trigger. You must pass the same session_id so the Portal knows which paused process to resume.

To see it in action, follow the detailed instructions in the "How to Test This Workflow" sticky note on the canvas.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - D. TELEPORT: Resume Paused Workflow

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 2 - E. Stop This Execution

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 3 - B. Check if Session is New or Existing

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - F. Prepare Initial Data

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - G. Return Data to Main Workflow

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 6 - C. Route Based on Session State

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 7 - Stop Session On Error ?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 8 - Reset Session

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Respond with Input Items

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 10 - Wait Node Sent Response Items ?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 11 - Send Items From Checkpoint

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 12 - Sticky Note13

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - A. Entry: Receive Session Info

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 14 - 1. Start Main Workflow (Manual)

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 15 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - 2. Call Async Portal

Type / Role
n8n-nodes-base.executeWorkflow - executeWorkflow
Config choices
Version 1.2

Block 18 - 3. Process Initial Data (Before Checkpoint 1)

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - 4. PAUSE at Checkpoint 1

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 20 - 5a. Receive Resumed Data

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 21 - 6. PAUSE at Checkpoint 2

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 22 - 7. Process Final Data (After Checkpoint 2)

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 23 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Sticky Note7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 42 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow ๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes
Complexity advanced
Nodes 42
Categories Engineering
Author Lucas Peyrin
Published 22 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6269/6269.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does ๐Ÿ› ๏ธ State Management System for Long-Running Workflows with Wait Nodes do?

How it works This template is a powerful, reusable utility for managing stateful, long running processes . It allows a main workflow to be paused indefinitely at "checkpoints" and then be resumed b...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.