8
n8n 中文网amn8n.com

n8n 工作流节点重命名器 by UpFastAI

中级

这是一个Engineering, AI Summarization领域的自动化工作流,包含 12 个节点。主要使用 N8n, Set, Code, ManualTrigger, ChainLlm 等节点。 使用 AI (Gemini/Claude) 自动重命名工作流节点以提高可读性

前置要求
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "",
  "meta": {
    "instanceId": ""
  },
  "name": "n8n 工作流节点重命名器 by UpFastAI",
  "tags": [],
  "nodes": [
    {
      "id": "0cb0ac30-661f-4b18-a915-9205e26816c6",
      "name": "手动启动工作流",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -848,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "3a1a361d-6109-4628-b348-1b6a31d4ee91",
      "name": "AI 生成名称建议",
      "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": "解析 JSON 响应结构",
      "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": "应用名称并更新引用",
      "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": "创建工作流副本",
      "type": "n8n-nodes-base.n8n",
      "position": [
        544,
        400
      ],
      "parameters": {
        "operation": "create",
        "requestOptions": {},
        "workflowObject": "={{ JSON.stringify($json) }}"
      },
      "credentials": {
        "n8nApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae69490d-cf1b-452c-af59-8e7bc452a09b",
      "name": "获取当前工作流 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": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "acf05fbc-83b0-4f27-a73f-ca01c81b3a9a",
      "name": "停用旧工作流",
      "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": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ef0a3ddf-f793-47a9-b6c0-e7105745d88d",
      "name": "激活重命名的工作流",
      "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": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0a965b42-0ac1-4e2e-831e-3db86bb963b2",
      "name": "Gemini AI 模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        32,
        832
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-flash-latest"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e209ba84-7749-4541-9749-a78a53cdd751",
      "name": "Claude Sonnet AI 模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -176,
        624
      ],
      "parameters": {
        "model": "anthropic/claude-sonnet-4.5",
        "options": {
          "temperature": 0
        }
      },
      "credentials": {
        "openRouterApi": {
          "id": "",
          "name": ""
        }
      },
      "typeVersion": 1
    },
    {
      "id": "21e21244-747b-4eed-8b77-c42e7060af45",
      "name": "工作流描述说明",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        0
      ],
      "parameters": {
        "width": 672,
        "height": 320,
        "content": "## **n8n 工作流节点重命名器**"
      },
      "typeVersion": 1
    },
    {
      "id": "b0e9ed90-cc78-4cd3-b7a4-1505102b8476",
      "name": "设置重命名工作流后缀",
      "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,
  "pinData": {},
  "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
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 工程, AI 摘要总结

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量12
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Dr. Christoph Schorsch

Dr. Christoph Schorsch

@upfastai

AI Automations Manager with nature scientific background and experience in haeding departments in R&D.

外部链接
在 n8n.io 查看

分享此工作流