{
  "name": "🛠️ State Management System for Long-Running Workflows with Wait Nodes",
  "nodes": [
    {
      "id": "66e7d75e-727e-465f-9c8c-d588fb11d9b4",
      "name": "D. TELEPORT: Resume Paused Workflow",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1504,
        1232
      ]
    },
    {
      "id": "274540d6-0664-49e1-b911-aa182a864286",
      "name": "E. Stop This Execution",
      "type": "n8n-nodes-base.filter",
      "position": [
        2128,
        1024
      ]
    },
    {
      "id": "59b743ce-288a-4911-8cf5-7d03e11b4d85",
      "name": "B. Check if Session is New or Existing",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        1440
      ]
    },
    {
      "id": "7be98b11-6330-4e34-b879-de57e04de4ac",
      "name": "F. Prepare Initial Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1504,
        1616
      ]
    },
    {
      "id": "bfac6fb5-81d3-4f1e-97b5-441925e14e10",
      "name": "G. Return Data to Main Workflow",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1728,
        1616
      ]
    },
    {
      "id": "82f05109-74f2-4bcb-af78-f7f044114192",
      "name": "C. Route Based on Session State",
      "type": "n8n-nodes-base.if",
      "position": [
        1168,
        1440
      ]
    },
    {
      "id": "d9ceec07-f1f4-410b-9184-e91169cfc635",
      "name": "Stop Session On Error ?",
      "type": "n8n-nodes-base.if",
      "position": [
        1824,
        1392
      ]
    },
    {
      "id": "905c2e58-88c3-49e5-9297-66554f221c27",
      "name": "Reset Session",
      "type": "n8n-nodes-base.code",
      "position": [
        2064,
        1392
      ]
    },
    {
      "id": "7ff3c03c-92b5-4072-85b9-89d0b6374ed7",
      "name": "Respond with Input Items",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2288,
        1392
      ]
    },
    {
      "id": "7e197e8c-be37-4448-84eb-115443502d88",
      "name": "Wait Node Sent Response Items ?",
      "type": "n8n-nodes-base.if",
      "position": [
        1888,
        944
      ]
    },
    {
      "id": "d0cb7051-f7f3-43d2-a518-30c4152a0ebb",
      "name": "Send Items From Checkpoint",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2128,
        848
      ]
    },
    {
      "id": "692897f1-3648-49c1-8058-cbbb3ba3f3b2",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        288
      ],
      "parameters": {
        "width": 256,
        "height": 272,
        "content": "![Kitch on fire](https://media2.giphy.com/media/v1.Y2lkPWVjZjA1ZTQ3ODFuYjVvdWdicXcwOGxqNmZ2anB0c3J2MjB3ZzlhYWtmYzBtejJ2biZlcD12MV9naWZzX3NlYXJjaCZjdD1n/THUvAWoL80rJgwlucA/giphy.webp)"
      }
    },
    {
      "id": "7b5566b3-d453-4e96-9aa1-e32b94716aa6",
      "name": "A. Entry: Receive Session Info",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        512,
        1440
      ]
    },
    {
      "id": "d574f6b5-5d05-4d53-ae1c-a0c40ebc4f58",
      "name": "1. Start Main Workflow (Manual)",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        512,
        384
      ]
    },
    {
      "id": "67105d44-18eb-4d86-b8a3-8292cbc5de41",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        -320
      ],
      "parameters": {
        "width": 624,
        "height": 640,
        "content": "# The \"Teleport\" Workflow Pattern\n\nThis workflow demonstrates a powerful stateful pattern for managing long-running, multi-step processes that need to be paused and resumed by external events.\n\n**Use "
      }
    },
    {
      "id": "7aa6b48c-c517-4f2d-bbad-8c70261a277b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -320
      ],
      "parameters": {
        "width": 3344,
        "height": 944,
        "content": "## MAIN PROCESS\n### This is your primary business logic. It calls the Portal to register itself, processes some data, and then pauses at a Checkpoint, waiting for another event to resume it."
      }
    },
    {
      "id": "38960902-f86f-45b4-9924-8af6d587d465",
      "name": "2. Call Async Portal",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        832,
        384
      ]
    },
    {
      "id": "c4074066-f74b-458b-8231-603f11065af1",
      "name": "3. Process Initial Data (Before Checkpoint 1)",
      "type": "n8n-nodes-base.set",
      "position": [
        1568,
        384
      ]
    },
    {
      "id": "8bc0d9c4-d276-42b1-9456-40bc296eb770",
      "name": "4. PAUSE at Checkpoint 1",
      "type": "n8n-nodes-base.wait",
      "position": [
        2016,
        384
      ]
    },
    {
      "id": "8aa13a69-0a54-49f6-a358-dd4f47ab1f01",
      "name": "5a. Receive Resumed Data",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2368,
        384
      ]
    },
    {
      "id": "244c7937-bb60-477d-b3fa-07033ba80fea",
      "name": "6. PAUSE at Checkpoint 2",
      "type": "n8n-nodes-base.wait",
      "position": [
        2960,
        384
      ]
    },
    {
      "id": "88751841-891e-42c3-b1d4-fda40c9d0901",
      "name": "7. Process Final Data (After Checkpoint 2)",
      "type": "n8n-nodes-base.set",
      "position": [
        3312,
        384
      ]
    },
    {
      "id": "59679849-6a24-4d24-a3f4-47cb730fb984",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        224
      ],
      "parameters": {
        "width": 384,
        "height": 320,
        "content": "### 1. Start Main Process\n\nThis is the entry point for your stateful process. It could be a webhook, a form submission, or a manual trigger like this one."
      }
    },
    {
      "id": "27ae7dc9-bc93-4426-b7f9-ed0d39c1434f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        96
      ],
      "parameters": {
        "width": 320,
        "height": 464,
        "content": "### 4. PAUSE at Checkpoint 1\n\nThis `Wait` node is a **Checkpoint**. The workflow execution physically stops here and is persisted.\n\nIt generates a unique `resume_url` that is stored by the Portal. The"
      }
    },
    {
      "id": "e6041571-5298-41e2-882a-f91dc7b09aeb",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2256,
        160
      ],
      "parameters": {
        "width": 560,
        "height": 400,
        "content": "### 5. Resumption & Response\n\nWhen the Portal 'teleports' data, this sequence is triggered.\n\n- **5a:** Receives the new data from the body of the resume request.\n- **5b:** Immediately sends a response"
      }
    },
    {
      "id": "9c660804-6d8e-48ac-ba88-ff989a899464",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2848,
        160
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "### 6. PAUSE at Checkpoint 2\n\nThis demonstrates that a single Main Process can have multiple, sequential checkpoints. The Portal will always resume the *latest* Checkpoint that was registered for the "
      }
    },
    {
      "id": "134ff79d-e2ca-4a24-ad5f-2bd54ba468bb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        32
      ],
      "parameters": {
        "width": 384,
        "height": 560,
        "content": "### 2. Call Async Portal\n\nThis is the first and only direct interaction with the Portal. The Main Process sends its `session_id` and its current `resume_url` to register itself.\n\n**Key Setting:** `Wai"
      }
    },
    {
      "id": "fa1833f6-2281-471c-b2dc-6c1ece25580b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        656
      ],
      "parameters": {
        "width": 2256,
        "height": 1280,
        "content": "## ASYNC PORTAL\n### This is the state-management engine. It's a separate, reusable workflow. Its only job is to check if a session is new or existing. If it's existing, it finds the correct paused wor"
      }
    },
    {
      "id": "73190cf8-6b2c-4d61-9c60-4d660464e02d",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        1264
      ],
      "parameters": {
        "width": 384,
        "height": 352,
        "content": "### Portal Entry\n\nThis is the single entry point for the entire state management system. Any external event (a webhook, a form, another workflow) that needs to interact with a stateful session will ca"
      }
    },
    {
      "id": "0e109b16-8a85-49f4-9c56-f2c5f65e14aa",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        1024
      ],
      "parameters": {
        "width": 352,
        "height": 592,
        "content": "### Session State Manager (Code)\n\nThis Code node is the brain of the portal. It uses **Workflow Static Data** (`$getWorkflowStaticData`) as a persistent, shared memory (a \"whiteboard\") to track all ac"
      }
    },
    {
      "id": "dd8043f7-59b4-410a-9d70-4202242fc608",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1056,
        1136
      ],
      "parameters": {
        "width": 304,
        "height": 480,
        "content": "### Route: New vs. Existing Session\n\nThis `IF` node directs traffic based on the output of the State Manager.\n\n- **True (Existing Session):** The flow proceeds to the 'Teleport' node to resume the pau"
      }
    },
    {
      "id": "94c5b95c-89de-4199-87ac-68869c2034b4",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        1184
      ],
      "parameters": {
        "width": 736,
        "height": 368,
        "content": "### Handle Teleport Error\n\nThis is a crucial safety feature. If the 'Teleport' action fails (e.g., the main execution was manually stopped and the `resume_url` is invalid), this branch is triggered.\n\n"
      }
    },
    {
      "id": "94cbe651-8ce0-4107-9f81-322fb9277409",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1376,
        944
      ],
      "parameters": {
        "width": 336,
        "height": 464,
        "content": "### TELEPORT: Resume Paused Process\n\nThis is the \"Teleport\" action. It's triggered only for existing sessions.\n\n**Technical Breakdown:**\nIt takes the `resume_url` retrieved by the State Manager and ma"
      }
    },
    {
      "id": "5bfc19bd-3d06-422e-9b2c-8a4006a16e42",
      "name": "5b. Send Back Data to Portal",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2624,
        384
      ]
    },
    {
      "id": "038f658e-7e78-4088-8e5a-f7d3c5f23796",
      "name": "Response From Checkpoint",
      "type": "n8n-nodes-base.if",
      "position": [
        1168,
        384
      ]
    },
    {
      "id": "fdf121cf-8870-4175-bbc0-adf100116d59",
      "name": "Split Out Teleported Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1456,
        32
      ]
    },
    {
      "id": "289e0b88-3128-406d-bcfc-9dbb541610bc",
      "name": "How to Test",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        352
      ],
      "parameters": {
        "width": 624,
        "height": 704,
        "content": "## How to Test This Workflow\n\nThis pattern requires a special testing method to see it in action.\n\n1.  **Open Two Tabs:** Open this workflow in two separate browser tabs (let's call them **Tab A** and"
      }
    },
    {
      "id": "16bd788f-e207-4e8f-a944-a2e14bfb9aa7",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        -208
      ],
      "parameters": {
        "width": 736,
        "height": 800,
        "content": "### 2a. Handle Portal's Response\n\nThis `IF` node routes the initial execution.\n\n- **False Path (First Run):** When the Portal is first called, it confirms the session is new but sends no special data "
      }
    },
    {
      "id": "5ed49e7d-d8da-4a51-aabd-6f646749d981",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        192
      ],
      "parameters": {
        "width": 384,
        "height": 368,
        "content": "### 3. Process Initial Data\n\nThis is a placeholder for your own business logic. This is where you would perform the first set of actions in your process, like creating a user account, sending a welcom"
      }
    },
    {
      "id": "804d3aaf-0b0a-4c39-9048-7dddc7dfa397",
      "name": "Sticky Note17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3200,
        160
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "### 7. Process Final Data\n\nThis represents the final steps of your process after all checkpoints have been passed. For example, this is where you would mark an order as 'complete' or send a final noti"
      }
    },
    {
      "id": "b933ada8-99e5-48f0-a49b-3cb02751c2d7",
      "name": "Sticky Note18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1872,
        -128
      ],
      "parameters": {
        "width": 1680,
        "height": 720,
        "content": "### Two Types of Checkpoints\n\nThis workflow demonstrates two different ways to use `Wait` nodes as checkpoints.\n\n- **Checkpoint 1 (Two-Way):** This `Wait` node has **`Response Mode`** set to `On Resum"
      }
    },
    {
      "id": "8c57606f-3906-46ed-acc2-6f7407a127a6",
      "name": "Sticky Note20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2528,
        656
      ],
      "parameters": {
        "width": 540,
        "height": 1280,
        "content": "## Was this helpful? Let me know!\n[![clic](https://supastudio.ia2s.app/storage/v1/object/public/assets/n8n/clic_down_lucas.gif)](https://n8n.ac)\n\nI really hope this utility helped you implement asynch"
      }
    }
  ],
  "connections": {
    "Reset Session": {
      "main": [
        [
          {
            "node": "Respond with Input Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Call Async Portal": {
      "main": [
        [
          {
            "node": "Response From Checkpoint",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "F. Prepare Initial Data": {
      "main": [
        [
          {
            "node": "G. Return Data to Main Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop Session On Error ?": {
      "main": [
        [
          {
            "node": "E. Stop This Execution",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Reset Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. PAUSE at Checkpoint 1": {
      "main": [
        [
          {
            "node": "5a. Receive Resumed Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5a. Receive Resumed Data": {
      "main": [
        [
          {
            "node": "5b. Send Back Data to Portal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. PAUSE at Checkpoint 2": {
      "main": [
        [
          {
            "node": "7. Process Final Data (After Checkpoint 2)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond with Input Items": {
      "main": [
        [
          {
            "node": "F. Prepare Initial Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Response From Checkpoint": {
      "main": [
        [
          {
            "node": "Split Out Teleported Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3. Process Initial Data (Before Checkpoint 1)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5b. Send Back Data to Portal": {
      "main": [
        [
          {
            "node": "6. PAUSE at Checkpoint 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "A. Entry: Receive Session Info": {
      "main": [
        [
          {
            "node": "B. Check if Session is New or Existing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Start Main Workflow (Manual)": {
      "main": [
        [
          {
            "node": "2. Call Async Portal",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "C. Route Based on Session State": {
      "main": [
        [
          {
            "node": "D. TELEPORT: Resume Paused Workflow",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "F. Prepare Initial Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Node Sent Response Items ?": {
      "main": [
        [
          {
            "node": "Send Items From Checkpoint",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "E. Stop This Execution",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "D. TELEPORT: Resume Paused Workflow": {
      "main": [
        [
          {
            "node": "Wait Node Sent Response Items ?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop Session On Error ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "B. Check if Session is New or Existing": {
      "main": [
        [
          {
            "node": "C. Route Based on Session State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Process Initial Data (Before Checkpoint 1)": {
      "main": [
        [
          {
            "node": "4. PAUSE at Checkpoint 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}