{
  "id": "",
  "name": "n8n Workflow Node Renamer by UpFastAI",
  "tags": [],
  "nodes": [
    {
      "id": "0cb0ac30-661f-4b18-a915-9205e26816c6",
      "name": "Start Workflow Manually",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -848,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3a1a361d-6109-4628-b348-1b6a31d4ee91",
      "name": "AI Generate Name Suggestions",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -144,
        400
      ],
      "parameters": {
        "text": "=# **Role:**\nYou are an experienced n8n workflow expert with a focus on **clear and efficient node naming**.\n\n# **Task:**\nI will upload an n8n workflow (in JSON format). Analyze the contained nodes and for each node, propose a **concise and meaningful new title** that makes its function immediately understandable.\n\nTo determine the node's function accurately, pay close attention to its `type` (e.g., `n8n-nodes-base.code`) and its specific `parameters`. Consider the node's position within the workflow and its connections to other nodes to ensure the new name reflects the node's specific role in the overall process.\n\n# **Constraints:**\n*   New titles must be unique within the workflow.\n*   New titles must be short, user-friendly, and a maximum of five words.\n*   Emojis are forbidden.\n\n# **CRITICAL OUTPUT FORMAT:**\nYour entire output must be a single JSON array. Each object in the array represents a single node and must contain two string pairs. This format is specifically designed to be used for a \"find and replace\" operation on the raw JSON file.\n\n1.  The key for the original name must be `\"originalName\"`. Its value must be a string containing the *entire original name property*, for example: `\"\\\"name\\\": \\\"Google Sheets1\\\"\"`.\n2.  The key for the new name must be `\"newName\"`. Its value must be a string containing the *entire new name property*, for example: `\"\\\"name\\\": \\\"Read New Customer Data\\\"\"`.\n\n## **Example JSON Output:**\n```json\n[\n  {\n    \"originalName\": \"\\\"name\\\": \\\"Set1\\\"\",\n    \"newName\": \"\\\"name\\\": \\\"Prepare Welcome Email Content\\\"\"\n  },\n  {\n    \"originalName\": \"\\\"name\\\": \\\"Send Email1\\\"\",\n    \"newName\": \"\\\"name\\\": \\\"Send Welcome Email to Customer\\\"\"\n  }\n]\n```\n\n# **Goal:**\nTo produce a clean JSON output that provides a direct mapping from the old name property to the new name property. This allows a developer to easily perform a find-and-replace operation on the workflow's JSON file to update all node titles efficiently.\n\n# **uploaded n8n workflow**\n{{ JSON.stringify($('Get Current Workflow JSON').first().json, null, 2) }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "c0461ef0-bbe8-48d1-8a3d-3756a49ac6ff",
      "name": "Parse JSON Response Structure",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -48,
        624
      ],
      "parameters": {
        "autoFix": true,
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"array\",\n  \"items\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"originalName\": {\n        \"type\": \"string\",\n        \"description\": \"The entire original name property as a string, e.g., '\\\"name\\\": \\\"Old Name\\\"'\"\n      },\n      \"newName\": {\n        \"type\": \"string\",\n        \"description\": \"The entire new name property as a string, e.g., '\\\"name\\\": \\\"New Name\\\"'\"\n      }\n    },\n    \"required\": [\n      \"originalName\",\n      \"newName\"\n    ]\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "349ddcbd-96a8-4a39-b77b-7d86cd9c6158",
      "name": "Apply Names and Update References",
      "type": "n8n-nodes-base.code",
      "position": [
        320,
        400
      ],
      "parameters": {
        "jsCode": "const originalWorkflow = $('Get Current Workflow JSON').first().json;\nconst nameMappings = $('AI Generate Name Suggestions').first().json.output;\nconst suffix = $('Set Renamed Workflow Suffix').first().json.workflowNameSuffix;\n\nconst nameMap = {};\nfor (const mapping of nameMappings) {\n  try {\n    const oldName = mapping.originalName.match(/\"name\":\\s*\"(.*?)\"/)[1];\n    const newName = mapping.newName.match(/\"name\":\\s*\"(.*?)\"/)[1];\n    nameMap[oldName] = newName;\n  } catch (e) {\n    console.warn(\"Konnte ein Mapping nicht parsen:\", mapping);\n  }\n}\n\nlet updatedWorkflow = JSON.parse(JSON.stringify(originalWorkflow));\n\nfor (const node of updatedWorkflow.nodes) {\n  if (nameMap[node.name]) {\n    node.name = nameMap[node.name];\n  }\n}\n\nconst newConnections = {};\nfor (const oldStartNodeName in updatedWorkflow.connections) {\n  const newStartNodeName = nameMap[oldStartNodeName] || oldStartNodeName;\n  const connectionTypes = updatedWorkflow.connections[oldStartNodeName];\n  newConnections[newStartNodeName] = {};\n  for (const connectionType in connectionTypes) {\n    const targets = connectionTypes[connectionType];\n    const updatedTargets = targets.map(targetGroup =>\n      targetGroup.map(target => ({ ...target, node: nameMap[target.node] || target.node }))\n    );\n    newConnections[newStartNodeName][connectionType] = updatedTargets;\n  }\n}\nupdatedWorkflow.connections = newConnections;\n\nfunction escapeRegExp(string) {\n  return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction updateAllReferences(obj) {\n  for (const key in obj) {\n    if (typeof obj[key] === 'string') {\n      let value = obj[key];\n      if (value.includes('$(') || value.includes('$items(')) {\n        for (const oldName in nameMap) {\n          const newName = nameMap[oldName];\n          const escapedOldName = escapeRegExp(oldName);\n          const patterns = [\n            { regex: new RegExp(`\\\\$\\\\('${escapedOldName}'\\\\)`, 'g'), replacement: `$('${newName}')` },\n            { regex: new RegExp(`\\\\$\\\\(\"${escapedOldName}\"\\\\)`, 'g'), replacement: `\\$(\"${newName}\")` },\n            { regex: new RegExp(`\\\\$items\\\\('${escapedOldName}'\\\\)`, 'g'), replacement: `$items('${newName}')` },\n            { regex: new RegExp(`\\\\$items\\\\(\"${escapedOldName}\"\\\\)`, 'g'), replacement: `$items(\"${newName}\")` }\n          ];\n          for (const pattern of patterns) {\n            value = value.replace(pattern.regex, pattern.replacement);\n          }\n        }\n        obj[key] = value;\n      }\n    } else if (typeof obj[key] === 'object' && obj[key] !== null) {\n      updateAllReferences(obj[key]);\n    }\n  }\n}\nupdateAllReferences(updatedWorkflow.nodes);\n\nconst finalWorkflowForApi = {\n  name: originalWorkflow.name + suffix,\n  nodes: updatedWorkflow.nodes,\n  connections: updatedWorkflow.connections,\n  settings: {\n    executionOrder: originalWorkflow.settings.executionOrder,\n    timezone: originalWorkflow.settings.timezone,\n    errorWorkflow: originalWorkflow.settings.errorWorkflow,\n  },\n  tags: originalWorkflow.tags || []\n};\n\nreturn [{\n  json: finalWorkflowForApi\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "b84867d7-c1a5-4c97-bd5e-85696ac4820d",
      "name": "Create New Workflow Copy",
      "type": "n8n-nodes-base.n8n",
      "position": [
        544,
        400
      ],
      "parameters": {
        "operation": "create",
        "requestOptions": {},
        "workflowObject": "={{ JSON.stringify($json) }}"
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae69490d-cf1b-452c-af59-8e7bc452a09b",
      "name": "Get Current Workflow JSON",
      "type": "n8n-nodes-base.n8n",
      "position": [
        -400,
        400
      ],
      "parameters": {
        "operation": "get",
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "W9Zl6OSnvKpmCbPr",
          "cachedResultName": "Prompting Redaktionsplan (#W9Zl6OSnvKpmCbPr)"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "acf05fbc-83b0-4f27-a73f-ca01c81b3a9a",
      "name": "Deactivate Old Workflow",
      "type": "n8n-nodes-base.n8n",
      "onError": "continueRegularOutput",
      "position": [
        768,
        400
      ],
      "parameters": {
        "operation": "deactivate",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Get Current Workflow JSON').item.json.id }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ef0a3ddf-f793-47a9-b6c0-e7105745d88d",
      "name": "Activate Renamed Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        992,
        400
      ],
      "parameters": {
        "operation": "activate",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create New Workflow Copy').item.json.id }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0a965b42-0ac1-4e2e-831e-3db86bb963b2",
      "name": "Gemini AI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        32,
        832
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-flash-latest"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e209ba84-7749-4541-9749-a78a53cdd751",
      "name": "Claude Sonnet AI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -176,
        624
      ],
      "parameters": {
        "model": "anthropic/claude-sonnet-4.5",
        "options": {
          "temperature": 0
        }
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "21e21244-747b-4eed-8b77-c42e7060af45",
      "name": "Workflow Description Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        0
      ],
      "parameters": {
        "width": 672,
        "height": 320,
        "content": "## **n8n Workflow Node Renamer**\n\nThis n8n workflow automates the process of renaming nodes for clarity. It uses AI to analyze each node's function and assigns a concise, descriptive name, significantly improving the readability and maintainability of your workflows.\n\n### **How to use it:**\n1.  (Optional) Customize the name suffix in the \"Set Renamed Workflow Suffix\" node.\n2.  Enter the ID of the workflow you want to rename in the \"Get Current Workflow JSON\" node.\n3.  Ensure your AI model credentials are correctly set up.\n4.  Run the workflow manually.\n\nPowered by **UpFastAI - Automating Intelligence**"
      },
      "typeVersion": 1
    },
    {
      "id": "b0e9ed90-cc78-4cd3-b7a4-1505102b8476",
      "name": "Set Renamed Workflow Suffix",
      "type": "n8n-nodes-base.set",
      "position": [
        -624,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2fe31286-e0ce-4bd5-bdf5-7903a51da3ad",
              "name": "workflowNameSuffix",
              "type": "string",
              "value": " - new node names"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "timezone": "",
    "errorWorkflow": "",
    "executionOrder": "v1"
  },
  "versionId": "f0208b1f-9b7b-4d32-8bbd-cd80d6de32aa",
  "connections": {
    "Gemini AI Model": {
      "ai_languageModel": [
        [
          {
            "node": "Parse JSON Response Structure",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Claude Sonnet AI Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Generate Name Suggestions",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Deactivate Old Workflow": {
      "main": [
        [
          {
            "node": "Activate Renamed Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow Manually": {
      "main": [
        [
          {
            "node": "Set Renamed Workflow Suffix",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Workflow Copy": {
      "main": [
        [
          {
            "node": "Deactivate Old Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Current Workflow JSON": {
      "main": [
        [
          {
            "node": "AI Generate Name Suggestions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Renamed Workflow Suffix": {
      "main": [
        [
          {
            "node": "Get Current Workflow JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Generate Name Suggestions": {
      "main": [
        [
          {
            "node": "Apply Names and Update References",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse JSON Response Structure": {
      "ai_outputParser": [
        [
          {
            "node": "AI Generate Name Suggestions",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Apply Names and Update References": {
      "main": [
        [
          {
            "node": "Create New Workflow Copy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}