{
  "name": "Convert n8n tags into folders and move workflows",
  "nodes": [
    {
      "id": "fd4629a6-f7c3-4927-a3da-767d8206b486",
      "name": "set credentials",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        300
      ]
    },
    {
      "id": "877bbd5c-fb57-4fa4-9d0a-113270113f31",
      "name": "login n8n",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        180,
        300
      ]
    },
    {
      "id": "41effdd0-ffad-439c-aa33-39f9cc13f6f9",
      "name": "get tags",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        800,
        300
      ]
    },
    {
      "id": "8fd2e71d-8da6-4f28-a377-56ef12c50c33",
      "name": "my-projects",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        340,
        300
      ]
    },
    {
      "id": "6bbd2296-fe2b-40d2-8e6c-d04b0987b1c6",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        480,
        300
      ]
    },
    {
      "id": "28a1f311-37fd-45be-aac4-684de800f099",
      "name": "filter owned projects",
      "type": "n8n-nodes-base.filter",
      "position": [
        640,
        300
      ]
    },
    {
      "id": "0362220f-ebb7-4fa0-b204-ec45f9b20cf4",
      "name": "Get folders",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1440,
        480
      ]
    },
    {
      "id": "b03373b9-ff14-4e8f-8d00-96755390d252",
      "name": "Split Out2",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1800,
        380
      ]
    },
    {
      "id": "00ad1ad3-5c55-40e9-8209-2c60fb8b5a0a",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        2140,
        380
      ]
    },
    {
      "id": "ac6c24e3-f095-48e2-a007-e5f07b7ff2a0",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1240,
        320
      ]
    },
    {
      "id": "bcb53003-7473-47ec-82c3-2e954ae26e90",
      "name": "get workflows",
      "type": "n8n-nodes-base.n8n",
      "position": [
        3040,
        720
      ]
    },
    {
      "id": "ddf83b3b-dffb-46b8-ab4b-38d19e1672b7",
      "name": "Move workflow to folder",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3240,
        720
      ]
    },
    {
      "id": "a611394f-418d-42d5-b26c-095c17043a86",
      "name": "Normalize names",
      "type": "n8n-nodes-base.set",
      "position": [
        1980,
        380
      ]
    },
    {
      "id": "e351c926-cf6e-4f61-9a7a-46338368c66e",
      "name": "Limit1",
      "type": "n8n-nodes-base.limit",
      "position": [
        2420,
        380
      ]
    },
    {
      "id": "c5d0c6b1-e478-40da-b9b7-15a60d3439dc",
      "name": "Create folders",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2260,
        640
      ]
    },
    {
      "id": "e7ab539f-6795-45eb-b23d-11ee13d3a17e",
      "name": "set folder name + id",
      "type": "n8n-nodes-base.set",
      "position": [
        2800,
        640
      ]
    },
    {
      "id": "8daa7475-4ac3-46b4-9681-b4c80002db06",
      "name": "set folder name + id1",
      "type": "n8n-nodes-base.set",
      "position": [
        2780,
        360
      ]
    },
    {
      "id": "688107fc-03e4-4e7f-9e51-ad8d30822566",
      "name": "set global",
      "type": "n8n-nodes-base.set",
      "position": [
        3020,
        480
      ]
    },
    {
      "id": "39027caf-6097-47cf-86c5-70882c45062d",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        2280,
        380
      ]
    },
    {
      "id": "1fcaf2d9-4aef-435d-968f-b8ecfea8a1ea",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1820,
        640
      ]
    },
    {
      "id": "1dea92e4-9b93-4b7e-8496-020731864219",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -160,
        300
      ]
    },
    {
      "id": "926f64a9-e5ef-4f99-8938-83b09c7cc13c",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        360,
        580
      ]
    },
    {
      "id": "4c3b4a14-d0ec-449d-b222-cd4a7c05b2bb",
      "name": "If no folder",
      "type": "n8n-nodes-base.if",
      "position": [
        1620,
        480
      ]
    },
    {
      "id": "a29325c5-5543-463c-9dc9-ec572afc0b82",
      "name": "If folder exists",
      "type": "n8n-nodes-base.if",
      "position": [
        2580,
        380
      ]
    },
    {
      "id": "d65e17fb-8c4b-4412-8d81-b7fa0d540b81",
      "name": "set name",
      "type": "n8n-nodes-base.set",
      "position": [
        2020,
        640
      ]
    },
    {
      "id": "104af4eb-f087-4c4f-ad69-058f7fbe5407",
      "name": "end import",
      "type": "n8n-nodes-base.form",
      "position": [
        1660,
        160
      ]
    },
    {
      "id": "31441d1e-8675-4a6b-bf3d-5f7230a6c173",
      "name": "pass all items",
      "type": "n8n-nodes-base.set",
      "position": [
        1480,
        160
      ]
    },
    {
      "id": "287704cc-7a43-4ffc-873e-b19920764b1e",
      "name": "select tags to move",
      "type": "n8n-nodes-base.form",
      "position": [
        580,
        580
      ]
    },
    {
      "id": "df8831e6-d587-4220-b602-8c06b3627d11",
      "name": "extract name from form",
      "type": "n8n-nodes-base.set",
      "position": [
        1020,
        320
      ]
    },
    {
      "id": "6340d3b0-9059-463c-bd78-2789156f47a8",
      "name": "Split Out the tags",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        780,
        580
      ]
    },
    {
      "id": "5f6dc440-7be1-432f-88c5-f05f5f3939b1",
      "name": "tags to string",
      "type": "n8n-nodes-base.set",
      "position": [
        140,
        580
      ]
    },
    {
      "id": "8784bdaf-0100-4f91-8631-b4ad4518fa33",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        220
      ],
      "parameters": {
        "width": 960,
        "height": 260,
        "content": "## Step 1\nLogin to n8n, and get the tags we have for our personal owned projects"
      }
    },
    {
      "id": "f27df4ec-c415-4077-8037-0bfe573aa4bf",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        500
      ],
      "parameters": {
        "width": 960,
        "height": 280,
        "content": "## Step 2\nExtract the tags as a json string, and format this into a suitable format for our response form for user to select the tags they want to work with"
      }
    },
    {
      "id": "8966e043-e358-4ba3-bc12-406c104b7dd1",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        240
      ],
      "parameters": {
        "width": 420,
        "height": 260,
        "content": "## Step 3\nExtract the form details and loop over each tag to process"
      }
    },
    {
      "id": "8b0bdded-cbeb-471a-ba74-ca7c6aaa34f2",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        380
      ],
      "parameters": {
        "width": 340,
        "height": 240,
        "content": "## Step 3\nWe search for the folders and filter based on the number of folders found"
      }
    },
    {
      "id": "be088523-e64a-4251-9c5c-355342c3ba98",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1780,
        300
      ],
      "parameters": {
        "width": 940,
        "height": 220,
        "content": "## Step 4 a) \nIf more than 1 folder is found, we dedupe the tags and limit to one, then use that as the folder"
      }
    },
    {
      "id": "6b08db71-dca5-4bb8-bb0c-4599c8e53bb1",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1780,
        560
      ],
      "parameters": {
        "width": 680,
        "height": 220,
        "content": "## Step 4 b) \nIf no folder is found, we create a new folder "
      }
    },
    {
      "id": "f96f9211-e076-472c-a7cd-abf58b4662ff",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2740,
        260
      ],
      "parameters": {
        "width": 420,
        "height": 480,
        "content": "## Step 5\n\nMerge the paths so we use one workflow"
      }
    },
    {
      "id": "f7f253bd-0b3a-48bb-97f5-1a8cf82b9b7e",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2960,
        660
      ],
      "parameters": {
        "width": 480,
        "height": 240,
        "content": "## Step 6\nGet the workflows and move them to the respective folders"
      }
    },
    {
      "id": "1d10ecf9-48e4-47d9-9d79-69ac1e375827",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        80
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "## Step 7\nRespond with a success message"
      }
    }
  ],
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "select tags to move",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Limit1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit1": {
      "main": [
        [
          {
            "node": "If folder exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get tags": {
      "main": [
        [
          {
            "node": "tags to string",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set name": {
      "main": [
        [
          {
            "node": "Create folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "filter owned projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "login n8n": {
      "main": [
        [
          {
            "node": "my-projects",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out2": {
      "main": [
        [
          {
            "node": "Normalize names",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set global": {
      "main": [
        [
          {
            "node": "get workflows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "set name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get folders": {
      "main": [
        [
          {
            "node": "If no folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "my-projects": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If no folder": {
      "main": [
        [
          {
            "node": "Split Out2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get workflows": {
      "main": [
        [
          {
            "node": "Move workflow to folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create folders": {
      "main": [
        [
          {
            "node": "set folder name + id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "pass all items": {
      "main": [
        [
          {
            "node": "end import",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "tags to string": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "pass all items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize names": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set credentials": {
      "main": [
        [
          {
            "node": "login n8n",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If folder exists": {
      "main": [
        [
          {
            "node": "set folder name + id1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "set name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "set credentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out the tags": {
      "main": [
        [
          {
            "node": "extract name from form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "select tags to move": {
      "main": [
        [
          {
            "node": "Split Out the tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set folder name + id": {
      "main": [
        [
          {
            "node": "set global",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter owned projects": {
      "main": [
        [
          {
            "node": "get tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "set folder name + id1": {
      "main": [
        [
          {
            "node": "set global",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "extract name from form": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move workflow to folder": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}