8
n8n 中文网amn8n.com

PQL + Amplitude

高级

这是一个Lead Generation, AI Summarization领域的自动化工作流,包含 21 个节点。主要使用 Set, Code, Merge, Slack, Filter 等节点。 使用 Amplitude、Claude 和 PDL 评估产品合格潜在客户,用于销售路由

前置要求
  • Slack Bot Token 或 Webhook URL
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • Anthropic API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "42b2652ebb0a87755df4710a5630695eec8e35cb0ce04a63b0e25751b1f044f1"
  },
  "name": "PQL + Amplitude",
  "tags": [],
  "nodes": [
    {
      "id": "66726c2e-0b01-4ea8-8024-a25221b0544d",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        48
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 340,
        "content": "## 🎯 PQL 评分工作流"
      },
      "typeVersion": 1
    },
    {
      "id": "665675ed-22b2-4bc6-b420-0ad5d7c26826",
      "name": "Amplitude 群组 Webhook",
      "type": "n8n-nodes-base.webhook",
      "notes": "Fires instantly when user enters PQL cohort",
      "position": [
        -784,
        400
      ],
      "webhookId": "10ba6cb2-f402-43d4-a721-1d38f5073745",
      "parameters": {
        "path": "amplitude-pql-cohort",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "99c46018-357d-488e-8a19-9621b79a0167",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        560
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 260,
        "content": "## 📡 Amplitude 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "aa33ad91-737f-4aeb-af6e-ea803e43e8af",
      "name": "解析 Webhook 数据",
      "type": "n8n-nodes-base.code",
      "notes": "Extracts user data + usage metrics from webhook",
      "position": [
        -576,
        400
      ],
      "parameters": {
        "jsCode": "// Parse Amplitude cohort webhook payload\nconst payload = $json;\n\n// Extract first user from the batch (webhooks can send multiple)\nconst users = payload.users || [];\n\nif (users.length === 0) {\n  throw new Error('No users in webhook payload');\n}\n\n// Process each user in the batch\nreturn users.map(user => {\n  const email = user.user_id || user.user_properties?.email;\n  \n  if (!email) {\n    throw new Error('No email found for user');\n  }\n  \n  // Validate email\n  const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n  if (!emailRegex.test(email)) {\n    throw new Error(`Invalid email: ${email}`);\n  }\n  \n  const domain = email.split('@')[1];\n  const isFreeEmail = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com'].includes(domain);\n  \n  return {\n    json: {\n      // User info\n      email: email,\n      name: user.user_properties?.name || user.user_properties?.full_name,\n      userId: user.user_id,\n      domain: domain,\n      isFreeEmail: isFreeEmail,\n      \n      // Cohort context\n      cohortName: payload.cohort_name,\n      cohortId: payload.cohort_id,\n      inCohort: payload.in_cohort,\n      computedTime: payload.computed_time,\n      \n      // Usage data from Amplitude user properties\n      usageData: {\n        sessionCount: user.user_properties?.session_count || 0,\n        lastSeen: user.user_properties?.last_seen,\n        daysSinceSignup: user.user_properties?.days_since_signup,\n        planType: user.user_properties?.plan_type || 'free',\n        featuresUsed: user.user_properties?.features_used || [],\n        teamSize: user.user_properties?.team_size || 1,\n        apiCalls: user.user_properties?.api_calls_last_7d || 0,\n        pricingPageViews: user.user_properties?.pricing_page_views || 0,\n        teamInvitesSent: user.user_properties?.team_invites_sent || 0\n      },\n      \n      timestamp: new Date().toISOString(),\n      validationPassed: true\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "41bd0754-df78-4b46-b5fd-c70a08c21ab7",
      "name": "过滤:仅限进入群组",
      "type": "n8n-nodes-base.filter",
      "notes": "Only process users ENTERING cohort, not exiting",
      "position": [
        -384,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "191ec8a1-8105-4e08-9b75-a03c6a514c80",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.inCohort }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "7a7929ef-e675-4840-977e-f2d5a859e8d0",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        96
      ],
      "parameters": {
        "color": 6,
        "width": 300,
        "height": 280,
        "content": "## 🔍 PDL 数据丰富"
      },
      "typeVersion": 1
    },
    {
      "id": "64c56856-0127-492d-b455-c109c145b072",
      "name": "PDL 数据丰富",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Enriches with company/person data",
      "position": [
        -192,
        400
      ],
      "parameters": {
        "url": "https://api.peopledatalabs.com/v5/person/enrich",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.email }}"
            },
            {
              "name": "pretty",
              "value": "true"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "JAhnxxCoDQgWyILm",
          "name": "Serp AI API"
        }
      },
      "typeVersion": 4.2,
      "continueOnFail": true
    },
    {
      "id": "e87ac8db-48d1-4f05-b0b4-dcca9f848329",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -48
      ],
      "parameters": {
        "color": 2,
        "width": 280,
        "height": 304,
        "content": "## 🔎 公司调研"
      },
      "typeVersion": 1
    },
    {
      "id": "c775f858-6e66-4716-9d86-6b3d6bea7823",
      "name": "公司研究",
      "type": "n8n-nodes-base.perplexity",
      "position": [
        48,
        272
      ],
      "parameters": {
        "options": {},
        "messages": {
          "message": [
            {
              "content": "=Research {{ $json.data.job_company_name }} for product-led growth context.\n\nFocus on:\n1. Company growth stage and funding\n2. Tech stack and product complexity\n3. Team size and structure\n4. Expansion signals (hiring, new offices)\n5. Budget indicators\n\nProvide under 150 words.\n\nFormat:\n**COMPANY STAGE:** [Growth stage, funding, maturity]\n**TECH SOPHISTICATION:** [Tech stack, product complexity]\n**EXPANSION SIGNALS:** [Hiring, growth indicators]\n**BUDGET INDICATORS:** [High/Medium/Low likelihood to pay]"
            }
          ]
        },
        "requestOptions": {}
      },
      "credentials": {
        "perplexityApi": {
          "id": "zcUXOu9Mm9oaXJep",
          "name": "Perplexity account"
        }
      },
      "typeVersion": 1,
      "continueOnFail": true
    },
    {
      "id": "0fca7a25-1940-4643-a699-33482bebd526",
      "name": "合并所有来源",
      "type": "n8n-nodes-base.merge",
      "position": [
        288,
        384
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "dec4ca1e-0f6a-4382-8d3a-85565dc94ce7",
      "name": "合并 PQL 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        384
      ],
      "parameters": {
        "jsCode": "// MERGE USAGE + ENRICHMENT DATA\nconst inputs = $input.all();\n\nconst enrichedPQL = {\n  user: {\n    email: null,\n    name: null,\n    userId: null\n  },\n  usage: {},\n  enrichment: {\n    pdl: {},\n    company: {}\n  },\n  cohort: {\n    name: null,\n    id: null\n  },\n  metadata: {\n    enrichmentTimestamp: new Date().toISOString(),\n    sourcesSuccessful: [],\n    sourcesFailed: []\n  }\n};\n\ninputs.forEach((input, index) => {\n  const data = input.json;\n  \n  // Input 0: Company research\n  if (index === 0 && data.choices?.[0]?.message?.content) {\n    const content = data.choices[0].message.content;\n    enrichedPQL.enrichment.company = {\n      rawResearch: content,\n      companyStage: extractSection(content, 'COMPANY STAGE'),\n      techSophistication: extractSection(content, 'TECH SOPHISTICATION'),\n      expansionSignals: extractSection(content, 'EXPANSION SIGNALS'),\n      budgetIndicators: extractSection(content, 'BUDGET INDICATORS')\n    };\n    enrichedPQL.metadata.sourcesSuccessful.push('Company Research');\n  }\n  \n  // Input 1: PDL data\n  else if (index === 1 && data && !data.error) {\n    const pdl = data.data || data;\n    enrichedPQL.enrichment.pdl = {\n      fullName: pdl.full_name,\n      jobTitle: pdl.job_title,\n      companyName: pdl.job_company_name,\n      companySize: pdl.job_company_size,\n      industry: pdl.job_company_industry,\n      seniorityLevel: pdl.job_title_levels,\n      linkedinUrl: pdl.linkedin_url,\n      location: pdl.location_name\n    };\n    enrichedPQL.user.name = pdl.full_name;\n    enrichedPQL.metadata.sourcesSuccessful.push('PDL');\n  }\n  \n  // Input 2: Amplitude webhook data\n  else if (index === 2 && data.validationPassed) {\n    enrichedPQL.user.email = data.email;\n    enrichedPQL.user.userId = data.userId;\n    enrichedPQL.user.name = enrichedPQL.user.name || data.name;\n    enrichedPQL.usage = data.usageData;\n    enrichedPQL.cohort = {\n      name: data.cohortName,\n      id: data.cohortId\n    };\n    enrichedPQL.metadata.sourcesSuccessful.push('Amplitude');\n  }\n});\n\nconst qualityScore = calculateQuality(enrichedPQL);\nenrichedPQL.metadata.dataQualityScore = qualityScore;\n\nfunction extractSection(text, header) {\n  const regex = new RegExp(`\\\\*\\\\*${header}:\\\\*\\\\*\\\\s*([^\\\\n*]+)`, 'i');\n  const match = text.match(regex);\n  return match ? match[1].trim() : 'N/A';\n}\n\nfunction calculateQuality(data) {\n  let score = 0;\n  if (data.enrichment.pdl.fullName) score += 25;\n  if (data.usage.sessionCount > 0) score += 25;\n  if (data.enrichment.company.companyStage !== 'N/A') score += 25;\n  if (data.enrichment.pdl.companySize) score += 25;\n  return score;\n}\n\nreturn [{ json: enrichedPQL }];"
      },
      "typeVersion": 2
    },
    {
      "id": "1ac94f52-f1db-4cd3-b015-d6170dd10cdb",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 340,
        "height": 364,
        "content": "## 🤖 AI 评分代理"
      },
      "typeVersion": 1
    },
    {
      "id": "07721f11-f4ae-49cb-905c-aa8a876a2d78",
      "name": "PQL 评分代理",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        592,
        384
      ],
      "parameters": {
        "text": "=You are a PQL (Product-Qualified Lead) scoring AI with access to usage data and ICP rules.\n\nCRITICAL: Use the Google Docs tool to fetch the PQL criteria document before scoring.\n\nPQL Data:\n{{ JSON.stringify($json, null, 2) }}\n\nSCORING PROCESS:\n1. Fetch PQL criteria from the doc\n2. Score each component:\n   - Usage Intensity (0-3): Based on session count, feature adoption, engagement\n   - ICP Fit (0-3): Company size, industry, seniority match\n   - Intent Signals (0-2): Pricing page views, team invites, integration usage\n   - Timing (0-2): Recent activity spikes, expansion signals\n3. Calculate pqlScore = usageIntensity + icpFit + intentSignals + timing\n4. Determine routing:\n   - 8-10 = \"hot\" (immediate sales handoff)\n   - 5-7 = \"warm\" (SDR nurture sequence)\n   - 0-4 = \"cold\" (automated education drip)\n\nReturn ONLY valid JSON (no markdown):\n{\n  \"email\": \"extract from user.email\",\n  \"name\": \"extract from enrichment.pdl.fullName\",\n  \"title\": \"extract from enrichment.pdl.jobTitle\",\n  \"companyName\": \"extract from enrichment.pdl.companyName\",\n  \"companySize\": \"extract from enrichment.pdl.companySize\",\n  \"industry\": \"extract from enrichment.pdl.industry\",\n  \"usageIntensity\": \"high|medium|low\",\n  \"usageSummary\": \"Brief summary of product usage\",\n  \"pqlScore\": sum of breakdown scores,\n  \"scoreBreakdown\": {\"usageIntensity\": 0-3, \"icpFit\": 0-3, \"intentSignals\": 0-2, \"timing\": 0-2},\n  \"icpMatch\": {\"companySizeMatch\": true/false, \"industryMatch\": true/false},\n  \"keyInsights\": [\"insight1\", \"insight2\"],\n  \"handoffRecommendation\": \"specific sales advice\",\n  \"conversationStarters\": [\"starter1\", \"starter2\"],\n  \"redFlags\": [\"flag1\"] or [],\n  \"nextAction\": \"immediate_sales_call|sdr_nurture|education_drip\",\n  \"confidenceLevel\": \"high|medium|low\",\n  \"routingCategory\": \"hot\" if 8-10, \"warm\" if 5-7, \"cold\" if 0-4\n}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7213fb59-b881-45a8-81ac-d8a230e39487",
      "name": "思考",
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "position": [
        704,
        608
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "49a71d70-2f0f-4253-832d-1f57e06e0012",
      "name": "Anthropic 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        592,
        592
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude 4 Sonnet"
        },
        "options": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "072fa1a8-88fd-4e71-957b-85ee27ac5fdf",
      "name": "解析和结构化 PQL",
      "type": "n8n-nodes-base.set",
      "position": [
        880,
        384
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{ $json.output }}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "ab8e61f7-75ad-4c3f-afef-ea6d015bb897",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        768
      ],
      "parameters": {
        "width": 496,
        "height": 388,
        "content": "## 📋 ICP 标准文档"
      },
      "typeVersion": 1
    },
    {
      "id": "27896435-f5a1-4495-959e-1928f0584fc2",
      "name": "格式化热门 PQL Slack",
      "type": "n8n-nodes-base.set",
      "position": [
        1072,
        384
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c1d2e3f4",
              "name": "prompt",
              "type": "string",
              "value": "=Format this PQL alert for Slack:\n\n{{ JSON.stringify($json, null, 2) }}\n\nCreate an engaging alert with:\n- 🔥 emoji for hot leads (score 8-10)\n- ⚡ emoji for warm leads (score 5-7)\n- Lead name, company, title\n- PQL score and key insights\n- Conversation starters for sales\n- Next action recommendation\n\nUse Slack markdown (bold with *text*, bullets with •)"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8bc7b1ef-3ef2-4bf2-9c67-661a8a56bdda",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 340,
        "height": 348,
        "content": "## 💬 Slack 提醒"
      },
      "typeVersion": 1
    },
    {
      "id": "98c21e06-e44d-4298-add2-f8f78892fcc7",
      "name": "发送热门 PQL 提醒",
      "type": "n8n-nodes-base.slack",
      "notes": "⚠️ UPDATE CHANNEL ID: Replace YOUR_SLACK_CHANNEL with your actual Slack channel ID",
      "position": [
        1248,
        384
      ],
      "webhookId": "a9aab25e-dacf-4875-8047-c332367c3684",
      "parameters": {
        "text": "={{ $json.content.parts[0].text }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SLACK_CHANNEL"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "1f833363-5bea-4023-a403-f09f07c77374",
      "name": "ICP 指南",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        816,
        608
      ],
      "parameters": {
        "operation": "get"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "UxwVvTjaY2WY3bMb",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Think": {
      "ai_tool": [
        [
          {
            "node": "PQL Scoring Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "PDL Enrich": {
      "main": [
        [
          {
            "node": "Company Research",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge All Sources",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "ICP Guidelines": {
      "ai_tool": [
        [
          {
            "node": "PQL Scoring Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Merge PQL Data": {
      "main": [
        [
          {
            "node": "PQL Scoring Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Company Research": {
      "main": [
        [
          {
            "node": "Merge All Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Sources": {
      "main": [
        [
          {
            "node": "Merge PQL Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PQL Scoring Agent": {
      "main": [
        [
          {
            "node": "Parse & Structure PQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Webhook Data": {
      "main": [
        [
          {
            "node": "Filter: Entering Cohort Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "PQL Scoring Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Format Hot PQL Slack": {
      "main": [
        [
          {
            "node": "Send Hot PQL Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse & Structure PQL": {
      "main": [
        [
          {
            "node": "Format Hot PQL Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Amplitude Cohort Webhook": {
      "main": [
        [
          {
            "node": "Parse Webhook Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter: Entering Cohort Only": {
      "main": [
        [
          {
            "node": "PDL Enrich",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 潜在客户开发, AI 摘要总结

需要付费吗?

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

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

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

作者
Connor Provines

Connor Provines

@connorprovines

Over the past 10+ years, I've led marketing initiatives for B2B SaaS companies at every stage, from initial market entry (0→1) through scaled growth (1→10). My approach is grounded in a simple principle: strategic thinking paired with hands-on execution. I focus on building sustainable growth engines, not just campaigns. Whether it's positioning a new product, optimizing conversion funnels, or scaling demand generation, I bring both the framework and the tactical expertise to move fast and win.

外部链接
在 n8n.io 查看

分享此工作流