{
  "name": "Store variables between workflow runs using data tables as a key-value store",
  "nodes": [
    {
      "id": "f259758f-2df3-4a49-ac03-0dff107d0fb0",
      "name": "Create Globals table",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -272,
        368
      ]
    },
    {
      "id": "33cf6930-8ebe-4942-abe7-a1f26596ff38",
      "name": "Stop and Error",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        -272,
        208
      ]
    },
    {
      "id": "414bec77-24c2-4465-8f7c-996ca981da0e",
      "name": "If not the expected error",
      "type": "n8n-nodes-base.if",
      "position": [
        -496,
        288
      ]
    },
    {
      "id": "da34d122-c0df-41a1-9334-20869f9b64c5",
      "name": "Global found",
      "type": "n8n-nodes-base.if",
      "position": [
        -496,
        736
      ]
    },
    {
      "id": "35df67d3-343f-4c49-9f55-d2b916d6cc76",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -976,
        480
      ]
    },
    {
      "id": "50db41c6-8d8d-456c-9271-5a41025e6a15",
      "name": "Get Global \"your_variable_name\"",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        -752,
        480
      ]
    },
    {
      "id": "380bd9e8-ccf9-452b-83e3-ed21cb0eb407",
      "name": "Set default value",
      "type": "n8n-nodes-base.set",
      "position": [
        -272,
        848
      ]
    },
    {
      "id": "6f19c478-7657-4ea7-a5c6-a57aa486d974",
      "name": "Format value",
      "type": "n8n-nodes-base.set",
      "position": [
        -272,
        624
      ]
    },
    {
      "id": "8306af44-bc85-4c08-80a5-7c6804d865a0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        416
      ],
      "parameters": {
        "width": 224,
        "height": 240,
        "content": "## 1. Get variable"
      }
    },
    {
      "id": "26411923-8894-4eb0-b77c-fe17ed208bb2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        144
      ],
      "parameters": {
        "width": 480,
        "height": 384,
        "content": "## Fallback: Create table if it does not exist\n_Needs to run first if previous node\nfailed - hence it is placed above_"
      }
    },
    {
      "id": "2474eeff-0bc5-4ab1-828c-b48c2f565cf9",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        560
      ],
      "parameters": {
        "width": 480,
        "height": 448,
        "content": "## 2. Define default value if needed"
      }
    },
    {
      "id": "7325803f-d5d0-4597-87de-7d039e50d3ce",
      "name": "Do something",
      "type": "n8n-nodes-base.noOp",
      "position": [
        16,
        736
      ]
    },
    {
      "id": "26fe591d-01fd-4566-9140-034349e1683d",
      "name": "Upsert Global \"your_variable_name\"",
      "type": "n8n-nodes-base.dataTable",
      "position": [
        272,
        736
      ]
    },
    {
      "id": "89dd60b8-25e3-411b-9463-1f883cd08f13",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        656
      ],
      "parameters": {
        "width": 224,
        "height": 256,
        "content": "## 4. Save variable"
      }
    },
    {
      "id": "858ad53d-9f1c-4c0b-99f9-ed070c5ba994",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1680,
        256
      ],
      "parameters": {
        "width": 576,
        "height": 560,
        "content": "## How it works\nA data table is used as a key value store having the two columns “key” and “value”.\n_It is referenced by name, which makes it easier to migrate this workflow to other instances._\n1. At"
      }
    },
    {
      "id": "bcbac038-fa72-42fe-8479-f3edc1da50aa",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        656
      ],
      "parameters": {
        "width": 224,
        "height": 256,
        "content": "## 3. Use variable"
      }
    }
  ],
  "connections": {
    "Do something": {
      "main": [
        [
          {
            "node": "Upsert Global \"your_variable_name\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format value": {
      "main": [
        [
          {
            "node": "Do something",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global found": {
      "main": [
        [
          {
            "node": "Format value",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Set default value",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set default value": {
      "main": [
        [
          {
            "node": "Do something",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Globals table": {
      "main": [
        []
      ]
    },
    "If not the expected error": {
      "main": [
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Globals table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Global \"your_variable_name\"": {
      "main": [
        [
          {
            "node": "Global found",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If not the expected error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get Global \"your_variable_name\"",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}