8
n8n 中文网amn8n.com

动态Hubspot线索路由与GPT-4和Airtable销售团队分配

高级

这是一个CRM, AI RAG领域的自动化工作流,包含 18 个节点。主要使用 Code, Gmail, Slack, Hubspot, Airtable 等节点。 使用GPT-4和Airtable销售团队分配实现动态Hubspot线索路由

前置要求
  • Google 账号和 Gmail API 凭证
  • Slack Bot Token 或 Webhook URL
  • HubSpot API Key
  • Airtable API Key
  • OpenAI API Key
  • Google Gemini API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "58401078fca0e18615dacf21a41e6807e184a744cb02c0f2b253f92dbf04c0e8",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5c09bdc4-4447-4f89-bdf8-785b1d4f562b",
      "name": "HubSpot 触发器",
      "type": "n8n-nodes-base.hubspotTrigger",
      "position": [
        1712,
        80
      ],
      "webhookId": "5f24ac4f-904e-4dd2-b249-aa5e2eedaf3d",
      "parameters": {
        "eventsUi": {
          "eventValues": [
            {}
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotDeveloperApi": {
          "id": "ZmdJO4a0TLh0dPq6",
          "name": "HubSpot Developer account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ccb53df7-842e-412e-b57c-d5c988ee32b4",
      "name": "获取联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        1952,
        80
      ],
      "parameters": {
        "contactId": {
          "__rl": true,
          "mode": "id",
          "value": "296267253463"
        },
        "operation": "get",
        "authentication": "oAuth2",
        "additionalFields": {
          "propertiesCollection": {
            "propertiesValues": {
              "properties": [
                "firstname",
                "lastname",
                "email",
                "company",
                "company_website",
                "descriptions",
                "mobilephone",
                "jobtitle",
                "team_size",
                "aindustry",
                "createdate"
              ],
              "propertyMode": "valueOnly"
            }
          }
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "rZSiaJnA0L7A3Iuz",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d8f0393c-4c5c-4290-8cae-aab4bcd94998",
      "name": "JavaScript代码",
      "type": "n8n-nodes-base.code",
      "position": [
        2176,
        80
      ],
      "parameters": {
        "jsCode": "\nconst data = $input.first().json;\n\nconst get = (path, fallback = null) => {\n  try {\n    return path.split('.').reduce((obj, key) => obj && obj[key], data) ?? fallback;\n  } catch {\n    return fallback;\n  }\n};\nconst lead = {\n  \"Record ID\": get('vid'), \n  \"First Name\": get('properties.firstname.value'),\n  \"Last Name\": get('properties.lastname.value'),\n  \"Email\": get('properties.email.value'),\n  \"Phone Number\": get('properties.phone.value'),\n  \"Description\": get('properties.descriptions.value'),\n  \"Job Title\": get('properties.jobtitle.value'),\n  \"Team Size\": get('properties.team_size.value'),\n\n  \"Industry\":\n    get('properties.aIndustry.value') ||\n    get('associated-company.properties.aIndustry.value') ||\n    get('properties.industry.value') ||\n    get('associated-company.properties.industry.value') ||\n    get('properties.hs_industry.value') ||\n    get('associated-company.properties.hs_industry.value') ||\n    get('properties.aindustry.value'),\n\n  \"Company Website\":\n    get('associated-company.properties.website') ||\n    get('properties.company_website.value'),\n\n  \"Company Name\": get('associated-company.properties.name'),\n};\n\nconst cleanLead = Object.fromEntries(\n  Object.entries(lead).filter(([_, v]) => v && v !== 'null' && v !== 'undefined' && v !== '')\n);\n\nfor (const key of Object.keys(lead)) {\n  if (!cleanLead[key]) cleanLead[key] = \"N/A\";\n}\n\nreturn [{ json: cleanLead }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "ff7fd69e-be53-4cff-a118-9fb538518047",
      "name": "创建记录",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2416,
        80
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appcEbIlJr6Vce1R7",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7",
          "cachedResultName": "Growify"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblYq8AAcldI4TZKP",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7/tblYq8AAcldI4TZKP",
          "cachedResultName": "Leads"
        },
        "columns": {
          "value": {
            "Email": "={{ $json.Email }}",
            "Job Title": "={{ $json['Job Title'] }}",
            "Last Name": "={{ $json['Last Name'] }}",
            "TEAM SIZE": "={{ $json['Team Size'] }}",
            "aIndustry": "={{ $json.Industry }}",
            "First Name": "={{ $json['First Name'] }}",
            "Company Name": "={{ $json['Company Name'].value }}",
            "Descriptions": "={{ $json.Description }}",
            "Phone Number": "={{ $json['Phone Number'] }}",
            "Record ID (HS)": "={{ $json['Record ID'] }}",
            "Company Website": "={{ $json['Company Website'].value }}"
          },
          "schema": [
            {
              "id": "Record ID (HS)",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Record ID (HS)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Last Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Phone Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Descriptions",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Descriptions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Job Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TEAM SIZE",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "11 - 50",
                  "value": "11 - 50"
                },
                {
                  "name": "51 - 200",
                  "value": "51 - 200"
                }
              ],
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "TEAM SIZE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "aIndustry",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "aIndustry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Website",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Company Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Company Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Persona (AI)",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Persona (AI)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Assigned to",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Assigned to",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Status",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Lead Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Create Date",
              "type": "dateTime",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Create Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create",
        "authentication": "airtableOAuth2Api"
      },
      "credentials": {
        "airtableOAuth2Api": {
          "id": "EbaOFDh1VDUEmgbD",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "cbdf53aa-982a-4616-aa25-090bddf3c9d7",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2736,
        80
      ],
      "parameters": {
        "text": "={\n  \"First Name\": {{ $json.fields['First Name'] }},\n  \"Last Name\": {{ $json.fields['Last Name'] }},\n  \"Job Title\": {{ $json.fields['Job Title'] }},\n  \"Team Size\": {{ $json.fields['TEAM SIZE'] }},\n  \"Industry\": {{ $json.fields.aIndustry }},\n  \"Region\": {{ $('Get a contact').item.json.properties.ip_state.value }},\n  \"Description\": {{ $json.fields.Descriptions }}\n}",
        "options": {
          "systemMessage": "=You are Growify AI — an intelligent routing agent for marketing automation.\n\nYou receive lead data from HubSpot and can access the Airtable tool named \"TeamDatabase\".\n\nWhen asked to analyze or match a lead, you must use the \"TeamDatabase\" tool to retrieve all team records.\n\nLead Routing Logic\n\nUse the following strict, numbered logic for all lead matching:\n\nAnalyze the incoming lead data, focusing on:\n\nIndustry\n\nRegion (matching IP city/country)\n\nTeam size\n\nDescription (primary needs)\n\nUse the TeamDatabase tool to find a record that matches the following criteria:\n\nSimilar or exact industry in the “Focus Industries” column.\n\nMatching or nearby region in the “Region” column.\n\nTeam still under Max Leads (capacity check).\n\nCompare multiple possible matches and choose the best one based on the closest match in both Industry and Region.\n\nRespond only after retrieving data from the TeamDatabase.\n\nRequired Output Format\n\nReturn your final answer as strict JSON with the following keys. All fields in the recommended_team, slack_notification, and email_notification objects must be populated.\n\n{\n  \"lead_persona\": {\n    \"summary\": \"A concise, single-sentence summary of the lead (Name, Company, Size, Region).\",\n    \"primary_needs\": \"The specific pain point or solution requested (from the description field).\"\n  },\n  \"recommended_team\": {\n    \"team_name\": \"The name of the assigned team.\",\n    \"contact_person\": \"The assigned team's contact person's name.\",\n    \"email\": \"The assigned contact person's email address.\",\n    \"reason_for_match\": \"The rationale for the team match (e.g., region and industry fit, and capacity).\",\n    \"slack_channel\": \"The Slack channel to post the notification to (e.g., #squad-innovate-eu).\"\n  },\n  \"slack_notification\": {\n    \"message\": \"A brief, urgent summary message to send to the Slack channel.\",\n    \"ping\": \"The assigned contact person's Slack handle (e.g., <@Maria Rossi>).\"\n  },\n  \"email_notification\": {\n    \"subject\": \"The subject line for the internal email.\",\n    \"body\": \"The full body of the email to the assigned contact person, detailing the lead and their specific need.\"\n  }\n}\n\n\nIf the TeamDatabase cannot be accessed or no suitable team match is found after checking capacity, return the following response:\n\n{\n  \"message\": \"No suitable team found in TeamDatabase.\"\n}\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "f4daa29b-5357-4dcf-bc72-a57111d275ed",
      "name": "简单记忆",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2352,
        320
      ],
      "parameters": {
        "sessionKey": "data",
        "sessionIdType": "customKey",
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "8b66f010-f6b4-4b65-b43b-6aaecbb66931",
      "name": "结构化输出解析器",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2608,
        320
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\n  \"lead_persona\": {\n    \"summary\": \"Arjun Mehta, Founder of a mid-size SaaS company (11-50 employees) located in the Netherlands (Europe), submitted a form.\",\n    \"primary_needs\": \"The lead is actively looking for a CRM automation and sales tracking solution with a direct integration for WhatsApp.\"\n  },\n  \"recommended_team\": {\n    \"team_name\": \"InnovateEU\",\n    \"contact_person\": \"Maria Rossi\",\n    \"email\": \"maria.rossi@growify.ai\",\n    \"reason_for_match\": \"Best regional fit (Europe) and primary industry match (SaaS), with current team capacity (3/7 leads).\",\n    \"slack_channel\": \"#squad-innovate-eu\"\n  },\n  \"slack_notification\": {\n    \"message\": \"New **HOT** Lead for InnovateEU! SaaS Founder Arjun Mehta is looking for a WhatsApp-integrated CRM/Sales Tracker. High intent. Please review and take action in HubSpot.\",\n    \"ping\": \"<@Maria Rossi>\"\n  },\n  \"email_notification\": {\n    \"subject\": \"[ACTION REQUIRED] High-Intent SaaS Lead Routed to You: Arjun Mehta @ TechVerse Pvt Ltd\",\n    \"body\": \"Hi Maria,\\n\\nA new high-priority lead has been automatically routed to you.\\n\\n**Lead Name:** Arjun Mehta (Founder)\\n**Company:** TechVerse Pvt Ltd (SaaS, 11-50 employees)\\n**Region:** Netherlands (Europe)\\n**Need:** Looking for CRM automation and sales tracking with **WhatsApp integration**.\\n\\nThis is a high-intent inquiry. Please review the full contact record in HubSpot and follow up immediately.\\n\\nThank you,\\nGrowify AI\"\n  }\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "5cc3faf8-318f-4bd8-bf42-38124b9479e5",
      "name": "TeamDatabase",
      "type": "n8n-nodes-base.airtableTool",
      "position": [
        2480,
        320
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appcEbIlJr6Vce1R7",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7",
          "cachedResultName": "Growify"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblmrChZlAaJSSVQq",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7/tblmrChZlAaJSSVQq",
          "cachedResultName": "Growify Sales Teams"
        },
        "options": {},
        "operation": "search",
        "authentication": "airtableOAuth2Api",
        "descriptionType": "manual",
        "toolDescription": "This Airtable contains team data: Team Name, Focus Industries, Region, Contact Person, Email, Max Leads, Strengths, Slack Channel."
      },
      "credentials": {
        "airtableOAuth2Api": {
          "id": "EbaOFDh1VDUEmgbD",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "23e2d128-e95e-45ae-8171-66ad12494240",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2224,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "wtMTeV2emnQK9uBx",
          "name": "n8n free OpenAI API credits"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8527eb51-7452-469a-a53b-4167f3d0f9b6",
      "name": "Google Gemini聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        2880,
        320
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "id": "Xhx7m5cwgQRZYO4I",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9503f3eb-3722-4662-8a23-3ea06fd7f0ea",
      "name": "更新记录",
      "type": "n8n-nodes-base.airtable",
      "position": [
        2016,
        480
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appcEbIlJr6Vce1R7",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7",
          "cachedResultName": "Growify"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblYq8AAcldI4TZKP",
          "cachedResultUrl": "https://airtable.com/appcEbIlJr6Vce1R7/tblYq8AAcldI4TZKP",
          "cachedResultName": "Leads"
        },
        "columns": {
          "value": {
            "Email": "={{ $('Code in JavaScript').item.json.Email }}",
            "Assigned to": "={{ $json.output.recommended_team.team_name }}",
            "Lead Status": "=Asigned to {{ $json.output.recommended_team.contact_person }}",
            "Persona (AI)": "={{ $json.output.lead_persona.summary }} {{ $json.output.lead_persona.primary_needs }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "Record ID (HS)",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Record ID (HS)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "First Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "First Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Last Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone Number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Phone Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Descriptions",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Descriptions",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Job Title",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Job Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "TEAM SIZE",
              "type": "options",
              "display": true,
              "options": [
                {
                  "name": "11 - 50",
                  "value": "11 - 50"
                },
                {
                  "name": "51 - 200",
                  "value": "51 - 200"
                }
              ],
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "TEAM SIZE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "aIndustry",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "aIndustry",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Website",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Company Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Company Name",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Company Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Persona (AI)",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Persona (AI)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Assigned to",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Assigned to",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Status",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Lead Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Create Date",
              "type": "dateTime",
              "display": true,
              "removed": true,
              "readOnly": false,
              "required": false,
              "displayName": "Create Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "authentication": "airtableOAuth2Api"
      },
      "credentials": {
        "airtableOAuth2Api": {
          "id": "EbaOFDh1VDUEmgbD",
          "name": "Airtable Personal Access Token account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1a6694ca-c981-4c27-bf19-b1248e6363a2",
      "name": "发送消息",
      "type": "n8n-nodes-base.slack",
      "position": [
        2256,
        480
      ],
      "webhookId": "4835d7da-d91f-43ce-a5df-d104c6d37fa9",
      "parameters": {
        "text": "={{ '@' + $('AI Agent').item.json.output.slack_notification.ping.replace('<@', '').replace('>', '').split(' ')[0] }} {{ $('AI Agent').item.json.output.slack_notification.message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $('AI Agent').item.json.output.recommended_team.slack_channel }}"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "id": "voioQ8kPnYUdOCh4",
          "name": "Slack account"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "f0cd8dd3-476a-4586-a171-2b5294061628",
      "name": "发送消息1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2464,
        480
      ],
      "webhookId": "24a2c864-d5c1-404e-a024-a82242ec927c",
      "parameters": {
        "sendTo": "={{ $('AI Agent').item.json.output.recommended_team.email }}",
        "message": "={{ $('AI Agent').item.json.output.email_notification.body }}",
        "options": {
          "senderName": "n8n Automation"
        },
        "subject": "={{ $('AI Agent').item.json.output.email_notification.subject }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "hnkmY7w8jrSeQt8m",
          "name": "Gmail account_n8n_verified"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "d18b2263-97cf-4501-b863-5b7ec99e5f51",
      "name": "创建或更新联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        2656,
        480
      ],
      "parameters": {
        "email": "={{ $('Create a record').item.json.fields.Email }}",
        "options": {},
        "authentication": "oAuth2",
        "additionalFields": {
          "status": "active",
          "message": "=Lead assigned to {{ $('AI Agent').item.json.output.recommended_team.team_name }} ({{ $('AI Agent').item.json.output.recommended_team.contact_person }})",
          "persona": "={{ $('AI Agent').item.json.output.lead_persona.primary_needs }} {{ $('AI Agent').item.json.output.lead_persona.summary }} "
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "rZSiaJnA0L7A3Iuz",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b4511869-c295-44a1-8995-f90ef00f6f48",
      "name": "无操作,不执行任何操作",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2864,
        480
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5006a018-c511-493f-a762-c08f74a809a3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        16
      ],
      "parameters": {
        "width": 1488,
        "height": 672,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "8f8c3d03-3ef9-404c-b663-87156bbc0750",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        816,
        -240
      ],
      "parameters": {
        "width": 752,
        "height": 928,
        "content": "# 🤖 AI驱动的线索路由与销售团队分配系统"
      },
      "typeVersion": 1
    },
    {
      "id": "ee45d4a7-2072-426a-a444-f65da9b227b0",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        -240
      ],
      "parameters": {
        "color": 6,
        "width": 464,
        "height": 928,
        "content": "![Manish Kumar](https://i.ibb.co/Z1hJmL6T/Gemini-Generated-Image-ewsigewsigewsige.png)"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "AI Agent": {
      "main": [
        [
          {
            "node": "Update record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "TeamDatabase": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get a contact": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Update record": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a record": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HubSpot Trigger": {
      "main": [
        [
          {
            "node": "Get a contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message1": {
      "main": [
        [
          {
            "node": "Create or update a contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Create a record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Create or update a contact": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 客户关系管理, AI RAG 检索增强

需要付费吗?

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

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

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

作者
MANISH KUMAR

MANISH KUMAR

@manipritraj

Automation Architect | n8n Expert I turn repetition into magic! Building workflows for: - Content creation (YouTube/social media) - Business ops (CRM/data pipelines) - Personal productivity (AI/smart home) Superpowers: API integrations • Debugging • Scalable solutions Featured: YouTube Shorts Automator • AI Report Generator • Custom ChatGPT+n8n "Automation should adapt to humans" 📧 manipritraj@gmail.com Fun fact: Automated my coffee+news+cat feeder! ☕🐈

外部链接
在 n8n.io 查看

分享此工作流