8
n8n 中文网amn8n.com

使用 GPT-4o-mini 代理自动进行潜在客户资格认定与客户支持

高级

这是一个Lead Nurturing, AI Chatbot领域的自动化工作流,包含 16 个节点。主要使用 If, Set, Code, ManualTrigger, Agent 等节点。 使用 GPT-4o-mini 代理自动进行潜在客户资格认定与客户支持

前置要求
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "efb474b59b0341d7791932605bd9ff04a6c7ed9941fdd53dc4a2e4b99a6f9439"
  },
  "nodes": [
    {
      "id": "9b686668-2c0e-4c1d-908f-c2954e67b0da",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        20,
        580
      ],
      "webhookId": "e104e40e-6134-4825-a6f0-8a646d882662",
      "parameters": {
        "public": true,
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "851344f4-1862-4bc6-9ea6-1f17831a706f",
      "name": "点击“测试工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a6e3505c-3e7d-43d1-bfb4-b3c2b0a44e46",
      "name": "OpenAI 聊天模型1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        400,
        300
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "243b3744-ada2-4eaa-bcaf-3ae91e3a4441",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        600,
        300
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"Name\": \"Alex Chen\",\n  \"Is Good Lead\": \"No\",\n  \"Reasoning\": \"The customer is interested in buying a single item for personal use.\"\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "5177741d-236d-47a6-9ac8-9cb46ba1a3f1",
      "name": "编辑字段1",
      "type": "n8n-nodes-base.set",
      "position": [
        780,
        40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "948759d1-4c0c-4751-a83d-9daa1ec3bb1c",
              "name": "Name",
              "type": "string",
              "value": "={{$json[\"output\"][\"Name\"]}}"
            },
            {
              "id": "91dbdf7b-8f0d-4ae2-ab36-701b01b581e2",
              "name": "Good Lead",
              "type": "string",
              "value": "={{$json[\"output\"][\"Is Good Lead\"]}}"
            },
            {
              "id": "5d38cd05-eb1a-4734-83d2-cdd5ee973ea7",
              "name": "Reasoning",
              "type": "string",
              "value": "={{ $json.output.Reasoning }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7261e97b-e056-44f5-a98e-b62641ed137e",
      "name": "OpenAI聊天模型2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        240,
        800
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "ghJTvay8CvwXDsXz",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a9207b97-4599-44d4-9cfe-a38d6a5976c0",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        420,
        820
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "162bcc59-f8ac-4468-900a-a65f52320ec8",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        -60
      ],
      "parameters": {
        "width": 1300,
        "height": 500,
        "content": "## 潜在客户筛选助手"
      },
      "typeVersion": 1
    },
    {
      "id": "45e03054-92b4-4fbb-a9f0-a65bd024f972",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -180,
        460
      ],
      "parameters": {
        "color": 5,
        "width": 1300,
        "height": 540,
        "content": "## 电商聊天机器人"
      },
      "typeVersion": 1
    },
    {
      "id": "19c265f1-ac38-472f-a975-4674a42f89ef",
      "name": "创建示例数据",
      "type": "n8n-nodes-base.code",
      "position": [
        200,
        40
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      name: \"Jordan Lee\",\n      transcript: \"Hi, I'm looking to place a large order of custom mugs for an upcoming corporate event. Probably around 300 units.\"\n    }\n  },\n  {\n    json: {\n      name: \"Alex Chen\",\n      transcript: \"Do you sell just one of these backpacks? I’m shopping for my daughter.\"\n    }\n  },\n  {\n    json: {\n      name: \"Samira Patel\",\n      transcript: \"We’re exploring gifts for our team and might want to add a logo. What's your bulk pricing on notebooks?\"\n    }\n  },\n  {\n    json: {\n      name: \"Marcus Grant\",\n      transcript: \"Just checking shipping times for a single product before I order. Thanks.\"\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "dbf6ef88-e1c3-4cd7-95e9-9fa47b2d81b4",
      "name": "潜在客户筛选助手",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        400,
        40
      ],
      "parameters": {
        "text": "=Name: {{$json[\"name\"]}}\nTranscript: {{$json[\"transcript\"]}}\n",
        "options": {
          "systemMessage": "You are a lead qualification assistant for an ecommerce store. Your job is to determine if a customer from a phone call is a good lead for a **bulk order**.\n\nIf they mention:\n- large quantities\n- logos\n- team gifts\n- events\n- wholesale\n- or any indication of buying in bulk\n\nThen classify them as a **good lead**. Otherwise, mark them as not a good lead.\n\nRespond only in valid JSON with:\n- \"Name\": customer’s name\n- \"Is Good Lead\": Yes or No\n- \"Reasoning\": short one-sentence reason"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "ef1d7730-6945-4dc6-b8d1-0d8b48c29b10",
      "name": "电商聊天机器人",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        300,
        580
      ],
      "parameters": {
        "options": {
          "systemMessage": "👋 Hi there! I'm your personal assistant here to help you with anything related to our ecommerce store.\n\nI can assist you with:\n- Product information\n- Bulk orders\n- Pricing questions\n- Customization options (like adding a logo)\n- Shipping times and return policies\n\nHere’s how I work:\n- I know the details of our products, pricing, and bulk order discounts.\n- I respond politely, professionally, and clearly.\n- If you're placing a bulk order, I’ll ask for the quantity you need, when you need it, and whether you have your artwork or logo ready.\n\n## Product Pricing (Standard Retail):\n- **Custom Notebook**: $12.00 each  \n- **Eco Water Bottle**: $15.00 each  \n- **Enamel Mug**: $10.00 each  \n- **Canvas Tote Bag**: $14.00 each\n\n## Bulk Discount Tiers:\n- 50+ units: 10% off  \n- 100+ units: 15% off  \n- 250+ units: 20% off  \n- 500+ units: 25% off  \n*Discounts apply per product type and are automatically calculated.*\n\n## Shipping & Returns:\n- Standard shipping: 3–5 business days  \n- Bulk orders may take 7–14 business days depending on customization\n- Returns accepted within 30 days for non-customized items\n\n## Rules:\n- Be honest and helpful\n- Never make up data or offer discounts outside the tiers above\n- If unsure about something, say a team member will follow up\n- If the customer mentions a bulk order, ask how many units they need and if they have artwork ready\n\n\n- if the customer has confirmed they want to place an order output ***** along with the response. \n\nJust ask your question, and I’ll take it from there!\n"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "052a2f31-f0fa-41ff-be09-121b7ac2f9f1",
      "name": "测试对话是否完成",
      "type": "n8n-nodes-base.if",
      "position": [
        640,
        600
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a3eb2967-e920-4342-ad2b-a2ae3b972955",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "*****"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "973fc612-a2ff-4105-8b58-ab1c22f171ba",
      "name": "回复用户",
      "type": "n8n-nodes-base.noOp",
      "position": [
        860,
        720
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e7401017-be65-4e75-8cd3-1af132116108",
      "name": "结束对话",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        500
      ],
      "parameters": {
        "jsCode": "let text = \"Your order has been placed\"\n\nreturn {text}\n \n "
      },
      "typeVersion": 2
    },
    {
      "id": "d2055f0c-81ce-4b83-9541-12634e4fc75c",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -900,
        -60
      ],
      "parameters": {
        "color": 4,
        "width": 680,
        "height": 1060,
        "content": "### 需要帮助?"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Ecommerce Chatbot",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Ecommerce Chatbot": {
      "main": [
        [
          {
            "node": "Test if conversation is complete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Sample Data": {
      "main": [
        [
          {
            "node": "Lead Qualifier Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Lead Qualifier Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Ecommerce Chatbot",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Lead Qualifier Agent": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Lead Qualifier Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Ecommerce Chatbot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Test if conversation is complete": {
      "main": [
        [
          {
            "node": "End the Conversation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Create Sample Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 客户培育, AI 聊天机器人

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类2
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Robert Breen

Robert Breen

@rbreen

Professional services consultant with over 10 years of experience solving complex business problems across industries. I specialize in n8n and process automation—designing custom workflows that integrate tools like Google Calendar, Airtable, GPT, and internal systems. Whether you need to automate scheduling, sync data, or streamline operations, I build solutions that save time and drive results.

外部链接
在 n8n.io 查看

分享此工作流