8
n8n 中文网amn8n.com

通过 AI 解析收件箱邮件更新 Hubspot 互动

中级

这是一个Sales, AI, Marketing, IT Ops领域的自动化工作流,包含 13 个节点。主要使用 If, Set, Hubspot, EmailReadImap, ChainLlm 等节点,结合人工智能技术实现智能自动化。 通过 AI 解析收件箱邮件更新 Hubspot 互动

前置要求
  • HubSpot API Key
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "nodes": [
    {
      "id": "9f2dc93f-bae5-4419-8411-d2fff4b31f5e",
      "name": "创建邮件互动记录",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        916,
        -260
      ],
      "parameters": {
        "type": "email",
        "metadata": {
          "html": "={{ $('When an email is received').item.json.textHtml || $('When an email is received').item.json.textPlain}}",
          "subject": "={{ $('When an email is received').item.json.subject }}",
          "toEmail": [
            "={{ $('When an email is received').item.json.to }}"
          ],
          "fromEmail": "={{ $('When an email is received').item.json.from }}"
        },
        "resource": "engagement",
        "authentication": "oAuth2",
        "additionalFields": {
          "associations": {
            "contactIds": "={{ $json.vid }}"
          }
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "JxzF93M0SJ00jDD9",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a56ec28-afc6-40a9-bf42-4d8742e48eb4",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -140,
        -40
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "1IOLtYX7aTspCAN8",
          "name": "OpenAI Pollup"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "8e53aeb6-7d84-4739-b482-b8cd844b89ac",
      "name": "通过电子邮件搜索联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        256,
        -260
      ],
      "parameters": {
        "operation": "search",
        "authentication": "oAuth2",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ $json.output.contact_info.email }}",
                    "propertyName": "email|string"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {}
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "JxzF93M0SJ00jDD9",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.1,
      "alwaysOutputData": true
    },
    {
      "id": "19e54445-d0cb-40f2-a11f-5e4cb22ad7ec",
      "name": "使用AI解析邮件",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -120,
        -260
      ],
      "parameters": {
        "text": "=Get all important info from this email like first name, last name, email, phone number, name of the company, country, Postal code, city, etc. Return it as a json.  The email content:  {{ $json.textHtml || $json.textPlain}} \nFrom: {{ $json.from }} \nSubject: {{ $json.subject }}\nDate sent:  {{ $json.date }}",
        "messages": {
          "messageValues": [
            {
              "message": "=You are a professional Email parser"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "8b257214-0001-46aa-84df-cad844e3130b",
      "name": "当收到邮件时",
      "type": "n8n-nodes-base.emailReadImap",
      "position": [
        -340,
        -260
      ],
      "parameters": {
        "options": {
          "forceReconnect": 3
        }
      },
      "credentials": {
        "imap": {
          "id": "g7C5Z9V9vQUbsLIw",
          "name": "IMAP account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "32820b69-3918-4951-9ddc-45bdbcb60aca",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -400
      ],
      "parameters": {
        "color": 4,
        "width": 280,
        "height": 300,
        "content": "## 设置接收邮箱账户"
      },
      "typeVersion": 1
    },
    {
      "id": "adbed044-08ae-4744-9b0c-09a225860267",
      "name": "设置输出JSON",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        80,
        -40
      ],
      "parameters": {
        "jsonSchemaExample": "{\"contact_info\": \n{\n\"first name\": \n\"Thomas\",\n\"last name\": \"Vie\",\n\"position\": \n\"CTO\",\n\"company\": \n\"Pollup Data Services\",\n\"email\": \n\"Thomas@pollup.net\",\n\"phone\": \n\"+34 673626552\",\n\"website\": \n\"https://pollup.net\",\n\"address\": \n{\n\"street\": \n\"Oppelner Str. 32\",\n\"postal_code\": \n\"10997\",\n\"city\": \n\"Berlin\",\n\"country\": \n\"Germany\"\n}}}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "e58575ee-6ac8-4de1-b4db-8525146efd74",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -140,
        -400
      ],
      "parameters": {
        "color": 4,
        "width": 320,
        "height": 300,
        "content": "## 升级提示词!"
      },
      "typeVersion": 1
    },
    {
      "id": "23465910-0a89-45f7-9bbf-fb17abadc5de",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        -400
      ],
      "parameters": {
        "color": 4,
        "width": 840,
        "height": 400,
        "content": "## Hubspot集成"
      },
      "typeVersion": 1
    },
    {
      "id": "f5573c22-85f3-4eda-ba5a-172567827991",
      "name": "联系人是否存在?",
      "type": "n8n-nodes-base.if",
      "position": [
        476,
        -260
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "554c2aa3-dbdb-4955-8510-6b09bc762f63",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "914f2e6b-7a5f-4c9c-bd3b-4bfb2693728d",
      "name": "编辑字段",
      "type": "n8n-nodes-base.set",
      "position": [
        696,
        -360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "75c8fc2d-dc8e-4b6c-a853-1dbd8d72f779",
              "name": "vid",
              "type": "string",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "4c8fa2d1-e3b4-4323-bdc8-3a4e2bbc706d",
      "name": "创建联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        696,
        -160
      ],
      "parameters": {
        "email": "={{ $('Parse the mail with AI').item.json.output.contact_info.email }}",
        "options": {},
        "authentication": "oAuth2",
        "additionalFields": {
          "city": "={{ $('Parse the mail with AI').item.json.output.contact_info.address.city }}",
          "country": "={{ $('Parse the mail with AI').item.json.output.contact_info.address.country }}",
          "jobTitle": "={{ $('Parse the mail with AI').item.json.output.contact_info.position }}",
          "lastName": "={{ $('Parse the mail with AI').item.json.output.contact_info['last name'] }}",
          "postalCode": "={{ $('Parse the mail with AI').item.json.output.contact_info.address.postal_code }}",
          "websiteUrl": "={{ $('Parse the mail with AI').item.json.output.contact_info.website }}",
          "companyName": "={{ $('Parse the mail with AI').item.json.output.contact_info.company }}",
          "phoneNumber": "={{ $('Parse the mail with AI').item.json.output.contact_info.phone }}",
          "streetAddress": "={{ $('Parse the mail with AI').item.json.output.contact_info.address.street }}"
        }
      },
      "credentials": {
        "hubspotOAuth2Api": {
          "id": "JxzF93M0SJ00jDD9",
          "name": "HubSpot account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "5f94ba18-49db-4bc0-9f0a-16a9d05ca6b0",
      "name": "便签7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -440,
        -620
      ],
      "parameters": {
        "width": 460,
        "height": 200,
        "content": "## 联系我"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Creates an email engagement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Creates contact": {
      "main": [
        [
          {
            "node": "Creates an email engagement",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "contact exists?": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Creates contact",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Parse the mail with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set the output Json": {
      "ai_outputParser": [
        [
          {
            "node": "Parse the mail with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Parse the mail with AI": {
      "main": [
        [
          {
            "node": "Search for the contact via email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When an email is received": {
      "main": [
        [
          {
            "node": "Parse the mail with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search for the contact via email": {
      "main": [
        [
          {
            "node": "contact exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 销售, 人工智能, 营销, IT 运维

需要付费吗?

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

工作流信息
难度等级
中级
节点数量13
分类4
节点类型8
难度说明

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

作者
PollupAI

PollupAI

@zeerobug

We create bespoke AI solutions, automations and agents that help your business as it scales.

外部链接
在 n8n.io 查看

分享此工作流