8
n8n 中文网amn8n.com

08 - AI驱动的联系人智能分析

中级

这是一个Lead Generation, AI Summarization领域的自动化工作流,包含 15 个节点。主要使用 Code, Filter, Hubspot, Airtable, GoogleSheets 等节点。 使用GPT-4o-mini为Google表格、Airtable和HubSpot分类和丰富联系人信息

前置要求
  • HubSpot API Key
  • Airtable API Key
  • Google Sheets API 凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "name": "08 - AI 驱动的联系人智能分析",
  "tags": [],
  "nodes": [
    {
      "id": "09b19752-a5fe-4786-8477-2e8605d62330",
      "name": "⏰ 每小时运行",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -1880,
        100
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "308fbf64-8376-4168-9ac3-19e1f85fc654",
      "name": "📄 读取待处理联系人",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -1660,
        100
      ],
      "parameters": {
        "options": {
          "returnAllMatches": "returnFirstMatch"
        },
        "filtersUI": {
          "values": [
            {
              "lookupValue": "Pending",
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit",
          "cachedResultName": "Data"
        },
        "combineFilters": "AND"
      },
      "typeVersion": 4
    },
    {
      "id": "a865ab5b-0bf7-4bb9-b2b8-50fd628ed563",
      "name": "🧪 筛选姓名和邮箱",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1440,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "has-name",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.Name }}",
              "rightValue": ""
            },
            {
              "id": "has-email",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.Email }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "990bf325-2704-4fbb-af01-e0c9518b0c4b",
      "name": "🧹 清理联系人数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -1220,
        100
      ],
      "parameters": {
        "jsCode": "const items = [];\n\nfor (const item of $input.all()) {\n  const raw = item.json;\n\n  // Clean up field names by trimming spaces\n  const contact = {};\n  for (const key in raw) {\n    contact[key.trim()] = raw[key];\n  }\n\n  items.push({\n    json: {\n      name: contact.Name || '',\n      email: contact.Email || '',\n      title: contact.Title || 'Not provided',\n      company: contact.Company || 'Not provided',\n      phone: contact.Phone || 'Not provided',\n      linkedin: contact.LinkedIn || 'Not provided',\n      notes: contact.Notes || 'Not provided'\n    }\n  });\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "6a728a8e-d85b-49a1-ae41-a5c086fefbf5",
      "name": "🧠 LLM - GPT-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1000,
        100
      ],
      "parameters": {
        "text": "=You are a professional recruiter assistant. Based on the contact information below, categorize the person by:\n\nfunction (e.g., Sales, Marketing, Engineering, HR, Finance, Product, Customer Support, Executive, Legal, Operations, Other)\n\nseniority (e.g., Entry Level, Junior, Mid Level, Senior Level, Manager, Director, VP, C-Level, Founder)\n\ndepartment if clearly known (else return \"Unknown\")\n\nassign a confidence_score from 0 to 100 (integer) based on how clearly the contact's role can be inferred\n\nexplain your reasoning in 1–2 lines\n\nReturn your response strictly in JSON format like this:\n\n{\n  \"function\": \"Sales\",\n  \"seniority\": \"Manager\",\n  \"department\": \"Revenue\",\n  \"confidence_score\": 87,\n  \"reasoning\": \"Title contains 'Account Manager' which indicates a mid-level sales role.\"\n}\n\nUse this contact data:\n\nName: {{ $json.name }}\n\nEmail: {{ $json.email }}\n\nTitle: {{ $json.title }}\n\nCompany: {{ $json.company }}\n\nPhone: {{ $json.phone }}\n\nLinkedIn: {{ $json.linkedin }}\n\nNotes: {{ $json.notes }}\n",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "bea8cbb6-bc03-4360-94a0-7ede08702e31",
      "name": "🧩 解析或回退角色标签",
      "type": "n8n-nodes-base.code",
      "position": [
        -624,
        100
      ],
      "parameters": {
        "jsCode": "const items = [];\n\nfor (let i = 0; i < $input.all().length; i++) {\n  const aiItem = $input.all()[i];\n  const originalContact = $('🧹 Clean Contact Data').all()[i].json;\n  \n  let analysis;\n  try {\n    // AI Agent returns response in output field\n    const aiResponse = aiItem.json.output || aiItem.json.text || '';\n    \n    // Try to extract JSON from the response\n    const jsonMatch = aiResponse.match(/\\{[^}]+\\}/s);\n    if (jsonMatch) {\n      analysis = JSON.parse(jsonMatch[0]);\n    } else {\n      throw new Error('No JSON found in response');\n    }\n  } catch (error) {\n    console.log('Failed to parse AI Agent response:', error);\n    console.log('AI Response:', aiItem.json);\n    \n    // Fallback analysis based on title keywords\n    const title = originalContact.title.toLowerCase();\n    let fallbackFunction = 'Other';\n    let fallbackSeniority = 'Mid Level';\n    \n    // Simple keyword matching for fallback\n    if (title.includes('sales') || title.includes('account')) fallbackFunction = 'Sales';\n    else if (title.includes('marketing')) fallbackFunction = 'Marketing';\n    else if (title.includes('engineer') || title.includes('developer')) fallbackFunction = 'Engineering';\n    else if (title.includes('hr') || title.includes('people')) fallbackFunction = 'HR';\n    else if (title.includes('finance') || title.includes('accounting')) fallbackFunction = 'Finance';\n    \n    if (title.includes('ceo') || title.includes('cto') || title.includes('cfo')) fallbackSeniority = 'C-Level';\n    else if (title.includes('vp') || title.includes('vice president')) fallbackSeniority = 'VP';\n    else if (title.includes('director')) fallbackSeniority = 'Director';\n    else if (title.includes('manager')) fallbackSeniority = 'Manager';\n    else if (title.includes('senior')) fallbackSeniority = 'Senior Level';\n    else if (title.includes('junior') || title.includes('entry')) fallbackSeniority = 'Entry Level';\n    \n    analysis = {\n      function: fallbackFunction,\n      seniority: fallbackSeniority,\n      department: 'Unknown',\n      confidence_score: 0.3,\n      reasoning: 'Fallback analysis due to AI parsing error'\n    };\n  }\n  \n  const enrichedContact = {\n    ...originalContact,\n    function: analysis.function || 'Other',\n    seniority: analysis.seniority || 'Mid Level',\n    department: analysis.department || 'Unknown',\n    confidence_score: analysis.confidence_score || 0.5,\n    reasoning: analysis.reasoning || '',\n    analyzed_at: new Date().toISOString()\n  };\n  \n  items.push({ json: enrichedContact });\n}\n\nreturn items;"
      },
      "typeVersion": 2
    },
    {
      "id": "7a092066-611a-49ce-8b0e-97645761372f",
      "name": "🧠 分类角色与资历",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -912,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "4ec658e5-df8a-4cec-ba25-a6b0db684c7b",
      "name": "📊 在表格中更新联系人",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -404,
        -100
      ],
      "parameters": {
        "columns": {
          "value": {
            "Email": "={{ $('📄 Read Pending Contacts').item.json.Email }}",
            "Status": "Reviewed",
            "Function": "={{ $json.function }}",
            "Seniority": "={{ $json.seniority }}",
            "Confidence Score": "={{ $json.confidence_score }}"
          },
          "schema": [
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Phone ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "LinkedIn",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Function",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Function",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Seniority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Confidence Score",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Confidence Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEET_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEET_ID/edit",
          "cachedResultName": "Data"
        }
      },
      "typeVersion": 4
    },
    {
      "id": "ad2c304c-c36c-4be0-80cd-726baa0b2e47",
      "name": "🔁 同步到 Airtable",
      "type": "n8n-nodes-base.airtable",
      "position": [
        -404,
        100
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_BASE_ID",
          "cachedResultUrl": "https://airtable.com/YOUR_AIRTABLE_BASE_ID",
          "cachedResultName": "Your Airtable Base"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_AIRTABLE_TABLE_ID",
          "cachedResultUrl": "https://airtable.com/YOUR_AIRTABLE_BASE_ID/YOUR_AIRTABLE_TABLE_ID",
          "cachedResultName": "Your Table"
        },
        "columns": {
          "value": {
            "Name": "={{ $json.name }}",
            "Email": "={{ $json.email }}",
            "Phone": "={{ $json.phone }}",
            "Title": "={{ $json.title }}",
            "Company": "={{ $json.company }}",
            "Function": "={{ $json.function }}",
            "LinkedIn": "={{ $json.linkedin }}",
            "Seniority": "={{ $json.seniority }}",
            "Department": "={{ $json.department }}",
            "Confidence Score": "={{ $json.confidence_score }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Title",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Phone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "LinkedIn",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "LinkedIn",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Function",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Function",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Seniority",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Seniority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Department",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Department",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Confidence Score",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Confidence Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "upsert",
        "authentication": "appToken"
      },
      "typeVersion": 2
    },
    {
      "id": "29fd44b3-50ae-4259-a70f-101c3ed62a81",
      "name": "📬 推送到 HubSpot",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        -404,
        300
      ],
      "parameters": {
        "email": "={{ $json.email }}",
        "options": {},
        "authentication": "appToken",
        "additionalFields": {}
      },
      "typeVersion": 2
    },
    {
      "id": "56bf9c8a-37b3-4d7e-8bbb-27b14ba9a3dd",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1940,
        -120
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 460,
        "content": "## 步骤 1"
      },
      "typeVersion": 1
    },
    {
      "id": "2dd459b2-a6dc-49e6-ae65-8b9f82c42599",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1700,
        -120
      ],
      "parameters": {
        "color": 2,
        "width": 420,
        "height": 460,
        "content": "## 步骤 2"
      },
      "typeVersion": 1
    },
    {
      "id": "8a157923-e604-4a67-80be-a1f66922a5ff",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1260,
        -120
      ],
      "parameters": {
        "color": 3,
        "width": 200,
        "height": 460,
        "content": "## 步骤 3"
      },
      "typeVersion": 1
    },
    {
      "id": "d43ba817-75fc-4064-8d7a-9adeea81fe4c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -120
      ],
      "parameters": {
        "color": 4,
        "width": 540,
        "height": 600,
        "content": "## 步骤 4"
      },
      "typeVersion": 1
    },
    {
      "id": "4189b779-9569-4890-aadd-d88b046d4e33",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        -260
      ],
      "parameters": {
        "color": 6,
        "width": 460,
        "height": 740,
        "content": "## 步骤 5"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "⏰ Run Every Hour": {
      "main": [
        [
          {
            "node": "📄 Read Pending Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧠 LLM - GPT-4o-mini": {
      "main": [
        [
          {
            "node": "🧩 Parse or Fallback Role Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧹 Clean Contact Data": {
      "main": [
        [
          {
            "node": "🧠 LLM - GPT-4o-mini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧪 Filter Name & Email": {
      "main": [
        [
          {
            "node": "🧹 Clean Contact Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📄 Read Pending Contacts": {
      "main": [
        [
          {
            "node": "🧪 Filter Name & Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🧠 Classify Role & Seniority": {
      "ai_languageModel": [
        [
          {
            "node": "🧠 LLM - GPT-4o-mini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "🧩 Parse or Fallback Role Tags": {
      "main": [
        [
          {
            "node": "📊 Update Contact in Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "🔁 Sync to Airtable",
            "type": "main",
            "index": 0
          },
          {
            "node": "📬 Push to HubSpot",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量15
分类2
节点类型9
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Avkash Kakdiya

Avkash Kakdiya

@itechnotion

🚀 Founder of iTechNotion — we build custom AI-powered automation workflows for startups, agencies, and founders. 💡 Specializing in agentic AI systems, content automation, sales funnels, and digital workers. 🔧 14+ years in tech | Building scalable no-code/low-code solutions using n8n, OpenAI, and other API-first tools. 📬 Let’s automate what slows you down.

外部链接
在 n8n.io 查看

分享此工作流