【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文件,导入。

相关推荐
测试员周周4 小时前
【Appium 系列】第16节-WebView-H5上下文切换 — 混合应用的自动化难点
运维·开发语言·人工智能·功能测试·appium·自动化·测试用例
K姐研究社6 小时前
怎么用AI制作电商口播视频,开拍APP一键生成
人工智能·音视频
LaughingZhu6 小时前
Product Hunt 每日热榜 | 2026-05-21
前端·人工智能·经验分享·chatgpt·html
辰海Coding6 小时前
MiniSpring框架学习笔记-解决循环依赖的简化IoC容器
笔记·学习
晓梦林6 小时前
cp520靶场学习笔记
android·笔记·学习
传说故事6 小时前
【论文阅读】MotuBrain: An Advanced World Action Model for Robot Control
论文阅读·人工智能·具身智能·wam
北京耐用通信7 小时前
全域适配工业场景耐达讯自动化Modbus TCP 转 PROFIBUS 网关轻松实现以太网与现场总线互通
网络·人工智能·网络协议·自动化·信息与通信
火山引擎开发者社区7 小时前
TRAE × 火山引擎 Supabase:为你的 AI 应用装上“数据引擎”
人工智能
小a彤7 小时前
GE 在 CANN 五层架构中的位置
人工智能·深度学习·transformer
心中有国也有家8 小时前
cann-recipes-infer:昇腾 NPU 推理的“菜谱集合”
经验分享·笔记·学习·算法