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

相关推荐
Blossom.1181 小时前
基于深度学习的图像分割:使用DeepLabv3实现高效分割
人工智能·python·深度学习·机器学习·分类·机器人·transformer
张较瘦_2 小时前
[论文阅读] 人工智能 + 软件工程 | 增强RESTful API测试:针对MongoDB的搜索式模糊测试新方法
论文阅读·人工智能·软件工程
墨染枫2 小时前
pytorch学习笔记-自定义卷积
pytorch·笔记·学习
Wendy14413 小时前
【边缘填充】——图像预处理(OpenCV)
人工智能·opencv·计算机视觉
钱彬 (Qian Bin)3 小时前
《使用Qt Quick从零构建AI螺丝瑕疵检测系统》——8. AI赋能(下):在Qt中部署YOLOv8模型
人工智能·qt·yolo·qml·qt quick·工业质检·螺丝瑕疵检测
星月昭铭4 小时前
Spring AI调用Embedding模型返回HTTP 400:Invalid HTTP request received分析处理
人工智能·spring boot·python·spring·ai·embedding
今天也好累4 小时前
C 语言基础第16天:指针补充
java·c语言·数据结构·笔记·学习·算法
大千AI助手5 小时前
直接偏好优化(DPO):原理、演进与大模型对齐新范式
人工智能·神经网络·算法·机器学习·dpo·大模型对齐·直接偏好优化
ReinaXue5 小时前
大模型【进阶】(四)QWen模型架构的解读
人工智能·神经网络·语言模型·transformer·语音识别·迁移学习·audiolm
静心问道5 小时前
Deja Vu: 利用上下文稀疏性提升大语言模型推理效率
人工智能·模型加速·ai技术应用