8
n8n 中文网amn8n.com

Set节点教程工作流

高级

这是一个Miscellaneous领域的自动化工作流,包含 19 个节点。主要使用 If, Set, Merge, Start, ManualTrigger 等节点。 通过完整Set节点指南掌握数据转换

前置要求
  • 无特殊前置要求,导入即可使用

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "WNu97ohWDOaqPXwj",
  "meta": {
    "instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc"
  },
  "name": "Set 节点教程工作流",
  "tags": [],
  "nodes": [
    {
      "id": "945ccba0-646e-4559-b674-d9df83157aa3",
      "name": "开始 (手动触发器)",
      "type": "n8n-nodes-base.start",
      "notes": "This node serves as your manual trigger. Click 'Execute Workflow' to start the tutorial. It passes a basic 'welcome' message.",
      "position": [
        -512,
        464
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0cd6c126-3320-4084-9ebf-65ba2e2ef95e",
      "name": "教程介绍",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        96
      ],
      "parameters": {
        "width": 400,
        "height": 424,
        "content": "## 🎯 Set 节点教程工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "64d5550c-af2c-4cb5-bb5f-db92c0de7688",
      "name": "1. 设置基本值",
      "type": "n8n-nodes-base.set",
      "notes": "This demonstrates setting basic data types:\n- Strings for text data\n- Numbers for integers and decimals\n- Booleans for true/false values",
      "position": [
        -288,
        464
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "f14ff918-718e-4d77-a9a8-5446f47c59d1",
      "name": "基础设置注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 240,
        "content": "## 📝 基础设置操作"
      },
      "typeVersion": 1
    },
    {
      "id": "31e36bb6-f39f-4d6b-b2e4-f5a35d18098a",
      "name": "2. 使用表达式设置",
      "type": "n8n-nodes-base.set",
      "notes": "This shows how to use expressions in Set nodes:\n- Reference previous data with $json\n- Use JavaScript expressions with ={{ }}\n- Access built-in functions like $now\n- Perform calculations and string interpolation",
      "position": [
        -64,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "a886eb9a-26fb-4510-bef2-761188994246",
      "name": "表达式注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        16
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "## 🔧 表达式魔法"
      },
      "typeVersion": 1
    },
    {
      "id": "2fabf9a9-47e9-4248-aa51-7d01fde8773b",
      "name": "3. 设置复杂数据",
      "type": "n8n-nodes-base.set",
      "notes": "This demonstrates setting complex data structures:\n- Objects with nested properties\n- Arrays with mixed data types\n- Combining static values with dynamic expressions\n- Building hierarchical data structures",
      "position": [
        160,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d559b4bd-a32c-4d33-8b3f-782dad7034d7",
      "name": "复杂数据注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        48
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "## 🏗️ 复杂数据结构"
      },
      "typeVersion": 1
    },
    {
      "id": "6aba6d91-55be-4042-87bb-ffdaafe7625b",
      "name": "4. 设置干净输出",
      "type": "n8n-nodes-base.set",
      "notes": "This shows the 'Keep Only Set' option:\n- When enabled, only the newly set values are kept\n- Previous data from the workflow is removed\n- Useful for cleaning up data and creating final outputs\n- Notice how we reference nested object properties",
      "position": [
        384,
        272
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "48f1a5f2-cfbd-439b-8093-ba04aea5eac4",
      "name": "仅保留注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1008,
        48
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "## 🧹 仅保留已设置选项"
      },
      "typeVersion": 1
    },
    {
      "id": "1f99d00d-dc21-4ff1-a48c-a70cc5d316a5",
      "name": "年龄检查",
      "type": "n8n-nodes-base.if",
      "notes": "Branching logic to demonstrate conditional Set nodes",
      "position": [
        -64,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition-1",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.user_age }}",
              "rightValue": 25
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e2dcd60e-246e-4f1b-80e4-e50b1d08e7b9",
      "name": "5a. 设置成人数据",
      "type": "n8n-nodes-base.set",
      "notes": "Conditional Set node for adults (age > 25)\nShows how Set nodes work in different branches",
      "position": [
        160,
        464
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "dc01d597-9b1e-454e-b4fa-fdb81571b44d",
      "name": "5b. 设置年轻成人数据",
      "type": "n8n-nodes-base.set",
      "notes": "Conditional Set node for young adults (age <= 25)\nShows different values based on conditions",
      "position": [
        160,
        656
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "c31f2f39-ad3a-4207-809c-722445703135",
      "name": "条件注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        480
      ],
      "parameters": {
        "width": 320,
        "height": 240,
        "content": "## 🔀 条件性 Set 节点"
      },
      "typeVersion": 1
    },
    {
      "id": "3ae0a260-db4b-4ac4-8b71-3c5d1e952676",
      "name": "合并分支",
      "type": "n8n-nodes-base.merge",
      "notes": "Merge the conditional branches back together",
      "position": [
        384,
        560
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "mergeByFields": {
          "values": [
            {}
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "2ed81df9-7a96-483b-b736-012e89e08595",
      "name": "6. 教程总结",
      "type": "n8n-nodes-base.set",
      "notes": "Final summary of the Set node tutorial with all key concepts covered",
      "position": [
        608,
        560
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "a630ce01-86c0-44c8-82f8-5e4f790a936a",
      "name": "完成注释",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        688
      ],
      "parameters": {
        "width": 400,
        "height": 376,
        "content": "## 🎓 教程完成!"
      },
      "typeVersion": 1
    },
    {
      "id": "42624e8d-e79c-4064-a999-59fff9b684f9",
      "name": "0. 测试数据输入",
      "type": "n8n-nodes-base.set",
      "notes": "🔧 **ALTERNATIVE START NODE** - Use this instead of 'Start (Manual Trigger)' for testing!\n\n**How to switch to test data:**\n1. **Disconnect** the line from 'Start (Manual Trigger)' to '1. Set Basic Values'\n2. **Connect** this node to '1. Set Basic Values'\n3. **Execute workflow** to see different results\n\n**Test different scenarios by changing:**\n- user_age (try 20 vs 30 for different branches)\n- score values\n- boolean flags\n\n**This node already has sample data ready to go!**",
      "position": [
        -288,
        800
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "d9932d91-1f9f-40d0-b83f-6891be6bfa19",
      "name": "点击\"执行工作流\"时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -512,
        768
      ],
      "parameters": {},
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "0. Test Data Input": [
      {
        "json": {
          "score": 75,
          "user_age": 20,
          "is_active": false,
          "user_name": "Bob",
          "user_email": "bob@example.com",
          "order_value": 150.75,
          "preferences": {
            "theme": "dark",
            "notifications": {
              "sms": false,
              "email": true
            }
          },
          "items_purchased": [
            "item_A",
            "item_C",
            "item_F"
          ],
          "product_interest": "Automation Software",
          "newsletter_subscribed": true
        }
      }
    ],
    "Start (Manual Trigger)": [
      {
        "json": {
          "message": "Welcome to the Set Node Tutorial!",
          "timestamp": "2025-01-01T10:00:00.000Z"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7a423cd7-82f0-4193-8203-0d7c1afa258f",
  "connections": {
    "Age Check": {
      "main": [
        [
          {
            "node": "5a. Set Adult Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5b. Set Young Adult Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Branches": {
      "main": [
        [
          {
            "node": "6. Tutorial Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0. Test Data Input": {
      "main": [
        []
      ]
    },
    "5a. Set Adult Data": {
      "main": [
        [
          {
            "node": "Merge Branches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Set Basic Values": {
      "main": [
        [
          {
            "node": "2. Set with Expressions",
            "type": "main",
            "index": 0
          },
          {
            "node": "Age Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Set Complex Data": {
      "main": [
        [
          {
            "node": "4. Set Clean Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start (Manual Trigger)": {
      "main": [
        [
          {
            "node": "1. Set Basic Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. Set with Expressions": {
      "main": [
        [
          {
            "node": "3. Set Complex Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5b. Set Young Adult Data": {
      "main": [
        [
          {
            "node": "Merge Branches",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "0. Test Data Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 杂项

需要付费吗?

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

工作流信息
难度等级
高级
节点数量19
分类1
节点类型6
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

外部链接
在 n8n.io 查看

分享此工作流