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

相关推荐
渲吧云渲染13 小时前
SaaS模式重构工业软件竞争规则,助力中小企业快速实现数字化转型
大数据·人工智能·sass
算家云13 小时前
DeepSeek-OCR本地部署教程:DeepSeek突破性开创上下文光学压缩,10倍效率重构文本处理范式
人工智能·计算机视觉·算家云·模型部署教程·镜像社区·deepseek-ocr
AgeClub13 小时前
1.2亿老人需助听器:本土品牌如何以AI破局,重构巨头垄断市场?
人工智能
再睡一夏就好14 小时前
【C++闯关笔记】详解多态
c语言·c++·笔记·学习·语法·1024程序员节
与己斗其乐无穷14 小时前
C++学习记录(22)异常
学习·1024程序员节
PPIO派欧云15 小时前
PPIO上线Qwen-VL-8B/30B、GLM-4.5-Air等多款中小尺寸模型
人工智能
chenchihwen16 小时前
AI代码开发宝库系列:FAISS向量数据库
数据库·人工智能·python·faiss·1024程序员节
张登杰踩16 小时前
工业产品表面缺陷检测方法综述:从传统视觉到深度学习
人工智能·深度学习
sponge'16 小时前
opencv学习笔记6:SVM分类器
人工智能·机器学习·支持向量机·1024程序员节