8
n8n 中文网amn8n.com

23 分析客户终身价值

高级

这是一个Market Research, AI Summarization领域的自动化工作流,包含 20 个节点。主要使用 If, Set, Code, Gmail, McpClientTool 等节点。 使用GPT-4和Bright Data MCP分析与定位高价值客户

前置要求
  • Google 账号和 Gmail API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "wIBHF1QNYzvZZHta",
  "meta": {
    "instanceId": "60046904b104f0f72b2629a9d88fe9f676be4035769f1f08dad1dd38a76b9480",
    "templateCredsSetupCompleted": true
  },
  "name": "23 分析客户终身价值",
  "tags": [],
  "nodes": [
    {
      "id": "a73dd3f9-4d76-46ba-b4bc-9c7035109825",
      "name": "每月运行优惠活动",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8b11a03a-71da-4d82-8891-084adcddfd77",
      "name": "设置客户历史记录 URL",
      "type": "n8n-nodes-base.set",
      "position": [
        200,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b366b00a-ad35-46ab-9722-6478ded6ec91",
              "name": "customer data url",
              "type": "string",
              "value": "example.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "b1f84ba5-90f9-4483-968e-67df657a1936",
      "name": "抓取客户资料和订单(代理)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        0
      ],
      "parameters": {
        "text": "=scrape the customer history url below and extract the key information:\n{{ $json['customer data url'] }}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "5aced094-ac88-4033-8a9b-dfc7b1457a6d",
      "name": "Bright Data MCP 抓取器",
      "type": "n8n-nodes-mcp.mcpClientTool",
      "position": [
        640,
        280
      ],
      "parameters": {
        "toolName": "scrape_as_markdown",
        "operation": "executeTool",
        "toolParameters": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Tool_Parameters', ``, 'json') }}"
      },
      "credentials": {
        "mcpClientApi": {
          "id": "eqq94k789oJCd6jU",
          "name": "MCP Client (STDIO) account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ef9b75c8-1ec6-43ca-9969-909146214422",
      "name": "AI 助手",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        440,
        280
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8sEyPDkC5p4w4Jha",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2d7909b4-333c-46cc-9909-5df7fe9bdeb6",
      "name": "格式化客户信息",
      "type": "n8n-nodes-base.code",
      "position": [
        900,
        0
      ],
      "parameters": {
        "jsCode": "// Get the array inside the 'output' key\nconst customers = items[0].json.output;\n\n// Map each customer to a separate item\nreturn customers.map(customer => {\n  return { json: customer };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "8d562c3e-2e0c-4ba8-8dbe-a89a23ba913b",
      "name": "获取客户订单历史",
      "type": "n8n-nodes-base.code",
      "position": [
        1100,
        0
      ],
      "parameters": {
        "jsCode": "// Loop through all incoming customers\nconst output = [];\n\nfor (const item of items) {\n  const customerName = item.json.customer_name;\n  const customerEmail = item.json.customer_email;  // Added email extraction\n  const orders = item.json.orders;\n\n  for (const order of orders) {\n    output.push({\n      json: {\n        customer_name: customerName,\n        customer_email: customerEmail,  // Added email in output\n        amount: order.amount,\n        date: order.date\n      }\n    });\n  }\n}\n\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "02a09456-b359-4989-99b5-c830e9d6ca2a",
      "name": "客户是否为高价值?",
      "type": "n8n-nodes-base.if",
      "position": [
        1360,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "6725053f-eae9-422c-942d-c82279482697",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $json.amount }}",
              "rightValue": 200
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9a0b0647-1341-4159-b639-5b3581548d74",
      "name": "发送特别优惠邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1580,
        -100
      ],
      "webhookId": "f2c94a4c-06f0-43a0-81db-8c728ef0de2f",
      "parameters": {
        "sendTo": "={{ $json.customer_email }}",
        "message": "write any offer",
        "options": {},
        "subject": "Offer for being out ideal customer"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "AQDSl75AdzK3vmqJ",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3d73fb01-ab20-4be2-97c7-c21d5c95b45f",
      "name": "忽略低价值客户",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1580,
        100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "7f81c4d2-d406-4d58-956e-78bca5a8f861",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -1020
      ],
      "parameters": {
        "color": 2,
        "width": 400,
        "height": 1200,
        "content": "## 🔁 **第一部分:计划与输入设置**"
      },
      "typeVersion": 1
    },
    {
      "id": "de0d7ee1-b627-4f17-b03e-4076b09166a9",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        -900
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 1080,
        "content": "## 🤖 **第二部分:使用代理抓取客户数据**"
      },
      "typeVersion": 1
    },
    {
      "id": "9f5db009-9461-4937-8c88-d55bf47bfe2c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        -760
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 940,
        "content": "## 🧩 **第三部分:数据格式化与订单提取**"
      },
      "typeVersion": 1
    },
    {
      "id": "a46e5710-fb85-46d6-addd-211994597386",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1320,
        -740
      ],
      "parameters": {
        "color": 6,
        "width": 380,
        "height": 1000,
        "content": "## 🎯 **第四部分:优惠决策与行动**"
      },
      "typeVersion": 1
    },
    {
      "id": "e32fb60f-390a-4f16-9b81-6b82fda08328",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1820,
        -740
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 240,
        "content": "## 如果您通过此链接加入Bright Data,我将获得少量佣金——感谢您支持更多免费内容!"
      },
      "typeVersion": 1
    },
    {
      "id": "a31f7eec-c104-4631-86f3-523e68aab57b",
      "name": "便签9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1780,
        -1040
      ],
      "parameters": {
        "color": 4,
        "width": 1300,
        "height": 320,
        "content": "======================================="
      },
      "typeVersion": 1
    },
    {
      "id": "0f4db4d3-102f-4c2c-a456-42bd14e95a76",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1780,
        -700
      ],
      "parameters": {
        "color": 4,
        "width": 1289,
        "height": 2758,
        "content": "# 🎯 **自动化高价值客户定位与优惠活动**"
      },
      "typeVersion": 1
    },
    {
      "id": "e7eec1fb-1a84-44be-8b8c-ab6fa4acbc1c",
      "name": "自动修复输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserAutofixing",
      "position": [
        780,
        280
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "3e4a7bfa-5ba6-4abb-8dac-72eeee8263a4",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        760,
        500
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "8sEyPDkC5p4w4Jha",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6ba75ee7-46ea-4388-b5c2-b5ab2d4aecc1",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        920,
        500
      ],
      "parameters": {
        "jsonSchemaExample": "[\n  {\n    \"customer_name\": \"John Doe\",\n    \"orders\": [\n      {\n        \"amount\": 120,\n        \"date\": \"2024-05-10\"\n      },\n      {\n        \"amount\": 80,\n        \"date\": \"2024-06-15\"\n      }\n    ]\n  },\n  {\n    \"customer_name\": \"Jane Smith\",\n    \"orders\": [\n      {\n        \"amount\": 200,\n        \"date\": \"2024-04-05\"\n      },\n      {\n        \"amount\": 150,\n        \"date\": \"2024-05-01\"\n      },\n      {\n        \"amount\": 180,\n        \"date\": \"2024-06-10\"\n      }\n    ]\n  },\n  {\n    \"customer_name\": \"Michael Johnson\",\n    \"orders\": [\n      {\n        \"amount\": 600,\n        \"date\": \"2024-07-01\"\n      }\n    ]\n  }\n]\n"
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "pinData": {
    "Scrape Customer Profiles & Orders (Agent)": [
      {
        "json": {
          "output": [
            {
              "orders": [
                {
                  "date": "2024-05-10",
                  "amount": 120
                },
                {
                  "date": "2024-06-15",
                  "amount": 80
                }
              ],
              "customer_name": "John Doe",
              "customer_email": "johndoe@gmail.com"
            },
            {
              "orders": [
                {
                  "date": "2024-04-05",
                  "amount": 200
                },
                {
                  "date": "2024-05-01",
                  "amount": 150
                },
                {
                  "date": "2024-06-10",
                  "amount": 180
                }
              ],
              "customer_name": "Jane Smith",
              "customer_email": "johnsmith@gmail.com"
            },
            {
              "orders": [
                {
                  "date": "2024-07-01",
                  "amount": 600
                }
              ],
              "customer_name": "Michael Johnson",
              "customer_email": "michael@gmail.com"
            }
          ]
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f2ffb3ba-6efc-493d-93c6-6a2e99e8c2d8",
  "connections": {
    "AI Assistant": {
      "ai_languageModel": [
        [
          {
            "node": "Scrape Customer Profiles & Orders (Agent)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Format Customer Info": {
      "main": [
        [
          {
            "node": "Get Customer Order History",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bright Data MCP Scraper": {
      "ai_tool": [
        [
          {
            "node": "Scrape Customer Profiles & Orders (Agent)",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Is Customer High-Value?": {
      "main": [
        [
          {
            "node": "Send Special Offer Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ignore Low-Value Customers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set customer history url": {
      "main": [
        [
          {
            "node": "Scrape Customer Profiles & Orders (Agent)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Auto-fixing Output Parser",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Auto-fixing Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Scrape Customer Profiles & Orders (Agent)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Customer Order History": {
      "main": [
        [
          {
            "node": "Is Customer High-Value?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Offer Campaign Monthly": {
      "main": [
        [
          {
            "node": "Set customer history url",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Customer Profiles & Orders (Agent)": {
      "main": [
        [
          {
            "node": "Format Customer Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 市场调研, AI 摘要总结

需要付费吗?

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

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

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

作者
Yaron Been

Yaron Been

@yaron-nofluff

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host If you need any help with Automations, feel free to reach out via linkedin: https://www.linkedin.com/in/yaronbeen/ And check out my Youtube channel: https://www.youtube.com/@YaronBeen/videos

外部链接
在 n8n.io 查看

分享此工作流