【n8n】如何跟着AI学习n8n【02.5】:第一部分总练习

前言

n8n的系统性学习,对各知识点地毯式学习🔍~

前面课程

定制n8n的AI老师,有AI老师制定学习大纲,参考之前的文档(本系列n8n学习大纲,也在这里):

【n8n】如何跟着AI学习n8n_01:定制AI老师-CSDN博客

第一课开始基础知识学习

【n8n】如何跟着AI学习n8n【02】:基础节点学习-CSDN博客

👌好了,下面是第一课的大练习💪


🧭 Day 6:实战项目练习 ------ 构建用户注册自动审核流程

🧩 项目背景:用户注册自动审核流程

当用户注册后,系统自动判断其年龄是否大于 18 岁:

  • ✅ 如果大于 18 岁:发送欢迎邮件(或 Slack 消息)
  • ❌ 如果小于 18 岁:发送审核通知,并等待人工审核
  • 🧠 最终合并两个分支,输出注册流程总结

🧪 实战任务:构建完整流程

创建一个自动化流程,实现以下逻辑:

Start → Set(模拟注册数据)

IF(判断 age > 18)

├─ Yes → Function(生成欢迎语)

└─ No → Function(生成审核提示)→ Wait(等待 3 秒)

Merge(合并两个分支)

Function(流程总结)

🧰 实战练习答案

小伙伴们,学完第一课,自己做一下,再看答案哦*。***

工作流设计图:

json代码:

复制代码
{
  "name": "练习:邮件4",
  "nodes": [
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "name",
              "value": "John"
            }
          ],
          "number": [
            {
              "name": "age",
              "value": 16
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        -580,
        -180
      ],
      "id": "687e513f-cb0b-4f9d-b3a9-3d9ab07bd81d"
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.age }}",
              "operation": "larger",
              "value2": 18
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        -420,
        -180
      ],
      "id": "d910c94b-3e05-4462-bb22-dba6daa9c29f"
    },
    {
      "parameters": {
        "functionCode": "const name = $input.item.json.name;\nreturn [{ json: { message: `Welcome, ${name}! You are an adult.` } }];"
      },
      "name": "Welcome Message",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -260,
        -260
      ],
      "id": "061141c3-609f-4ca9-8af0-c4f4152302b5"
    },
    {
      "parameters": {
        "functionCode": "const name = $input.item.json.name;\nreturn [{ json: { message: `Hi ${name}, we need to review your registration.` } }];"
      },
      "name": "Need Review",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -260,
        -60
      ],
      "id": "61c172e4-92d4-4da7-9def-c6a29749bb1f"
    },
    {
      "parameters": {
        "functionCode": "const branch1 = $input.item.pairedItem ? $input.item.pairedItem.message : null;\nconst branch2 = $input.item.pairedItem ? $input.item.pairedItem.message : null;\n\nconst summary = {\n  adultMessage: branch1,\n  reviewMessage: branch2,\n  finalStatus: branch1 ? 'Approved' : 'Pending Review'\n};\n\nreturn [{ json: summary }];"
      },
      "name": "Summary",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        120,
        -260
      ],
      "id": "136fc016-bae9-4dc3-b0ed-a67cdc680eae"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -760,
        -180
      ],
      "id": "96463165-296d-4e66-8f8d-97754b1d9daa",
      "name": "When clicking 'Test workflow'"
    },
    {
      "parameters": {
        "amount": 3,
        "unit": "seconds"
      },
      "name": "Wait 3s",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        -40,
        -80
      ],
      "id": "19a53a37-9124-44bf-ac50-709ca2f8f43f",
      "webhookId": "ce0dd3af-9f3c-4a10-8895-1d8b6edcfb86"
    }
  ],
  "pinData": {},
  "connections": {
    "Set": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Welcome Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Need Review",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Need Review": {
      "main": [
        [
          {
            "node": "Wait 3s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Welcome Message": {
      "main": [
        [
          {
            "node": "Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking 'Test workflow'": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3s": {
      "main": [
        [
          {
            "node": "Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "63042f5a-5bd8-4127-8fef-6daea259f9dc",
  "meta": {
    "instanceId": "70694156c5a96e4fa7ffae62a18b0c6b4ad4724f1ccc008ab89d5c4dcc7c8b4d"
  },
  "id": "BveqapjozzHygXiO",
  "tags": []
}

提示:

工作流导入json:新建一个工作流,直接把json代码拷贝到工作流面板,字段解析为工作流程,或者把上面代码存在.json文件,导入。

相关推荐
用泥种荷花1 小时前
【LangChain学习笔记】Message
人工智能
阿里云大数据AI技术1 小时前
一套底座支撑多场景:高德地图基于 Paimon + StarRocks 轨迹服务实践
人工智能
云擎算力平台omniyq.com1 小时前
CES 2026观察:从“物理AI”愿景看行业算力基础设施演进
人工智能
想用offer打牌1 小时前
一站式了解Spring AI Alibaba的流式输出
java·人工智能·后端
黑符石1 小时前
【论文研读】Madgwick 姿态滤波算法报告总结
人工智能·算法·机器学习·imu·惯性动捕·madgwick·姿态滤波
JQLvopkk1 小时前
智能AI“学习功能”在程序开发部分的逻辑
人工智能·机器学习·计算机视觉
我的offer在哪里1 小时前
Hugging Face:让大模型触手可及的魔法工厂
人工智能·python·语言模型·开源·ai编程
收获不止数据库1 小时前
黄仁勋2026CES演讲复盘:旧世界,裂开了!
大数据·数据库·人工智能·职场和发展
老胡全房源系统1 小时前
房产中介管理系统哪一款性价比高
大数据·人工智能·房产经纪人培训