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

相关推荐
2401_8315017312 分钟前
Python学习之day01学习(变量定义和数据类型使用)
开发语言·python·学习
山海青风28 分钟前
藏语自然语言处理入门 - 3 找关键词
人工智能·自然语言处理
Java与Android技术栈30 分钟前
AI Coding 让我两天完成图像编辑器 Monica 的国际化与多主题
人工智能
wwwzhouhui30 分钟前
85-dify案例分享-不用等 OpenAI 邀请,Dify+Sora2工作流实测:写实动漫视频随手做,插件+教程全送
人工智能·音视频·sora2
Testopia39 分钟前
AI与敏捷开发管理系列3:敏捷方法在AI项目中的应用案例
人工智能·ai编程·敏捷流程·#人工智能学习
倔强青铜三40 分钟前
苦练Python第61天:logging模块——让Python日志“有迹可循”的瑞士军刀
人工智能·python·面试
Testopia42 分钟前
AI与敏捷开发管理1:传统方法失灵?人工智能项目的新法则
人工智能·项目管理·敏捷开发·敏捷流程
倔强青铜三43 分钟前
苦练Python第60天:json模块——让Python和JSON“无缝互译”的神兵利器
人工智能·python·面试
straw_hat.1 小时前
PCB学习——STM32F103VET6-STM32主控部分
stm32·嵌入式硬件·学习
蒙奇D索大2 小时前
【数据结构】数据结构秘籍:如何衡量“查找”的快慢?ASL是关键!
数据结构·笔记·学习·考研