8
n8n 中文网amn8n.com

20 - HubSpot到Slack联系人卡片

中级

这是一个CRM, Multimodal AI领域的自动化工作流,包含 15 个节点。主要使用 If, Code, Slack, Hubspot, Webhook 等节点。 为销售和支持团队在Slack中快速查找HubSpot联系人

前置要求
  • Slack Bot Token 或 Webhook URL
  • HubSpot API Key
  • HTTP Webhook 端点(n8n 会自动生成)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "PLACEHOLDER_WORKFLOW_ID",
  "meta": {
    "instanceId": "PLACEHOLDER_INSTANCE_ID",
    "templateCredsSetupCompleted": true
  },
  "name": "20 - HubSpot 到 Slack 联系人卡片",
  "tags": [],
  "nodes": [
    {
      "id": "00cc9790-780b-45e8-bb85-1613ef34cd05",
      "name": "🌐 传入斜杠命令",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -900,
        200
      ],
      "webhookId": "hubspot-contact-webhook",
      "parameters": {
        "path": "hubspot-contact-lookup",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "06f703df-a621-4c3b-a860-83859f8db226",
      "name": "🔍 检查消息是否存在",
      "type": "n8n-nodes-base.if",
      "position": [
        -680,
        200
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "ec3773aa-e58f-4743-b2f1-ac508daf3c87",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.text }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2898d6d5-8cd5-4e71-bf09-bc3303dea75b",
      "name": "🛑 停止 - 缺少消息",
      "type": "n8n-nodes-base.stopAndError",
      "position": [
        -460,
        300
      ],
      "parameters": {
        "errorMessage": "No message found"
      },
      "typeVersion": 1
    },
    {
      "id": "b1bbfab9-57d8-4d26-9ab7-95e66dffa40d",
      "name": "✂️ 解析搜索输入",
      "type": "n8n-nodes-base.code",
      "position": [
        -460,
        100
      ],
      "parameters": {
        "jsCode": "const input = $input.first().json.body.text || '';\nconst trimmedInput = input.trim();\n\nif (!trimmedInput) {\n  throw new Error('Please provide an email address or HubSpot contact ID');\n}\n\nconst emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\nconst isEmail = emailRegex.test(trimmedInput);\n\nreturn {\n  searchValue: trimmedInput,\n  searchType: isEmail ? 'email' : 'id',\n  channelId: $json.channel_id,\n  userId: $json.user_id,\n  responseUrl: $json.response_url\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "e05b7063-1779-427d-b23f-b0fc9f6a20ad",
      "name": "🔀 确定搜索类型",
      "type": "n8n-nodes-base.if",
      "position": [
        -240,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "condition1",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.searchType }}",
              "rightValue": "email"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "e19a4c16-c33e-4bb5-8060-12e52e356d71",
      "name": "📧 按邮箱搜索联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        -20,
        0
      ],
      "parameters": {
        "operation": "search",
        "authentication": "appToken",
        "filterGroupsUi": {
          "filterGroupsValues": [
            {
              "filtersUi": {
                "filterValues": [
                  {
                    "value": "={{ $json.searchValue }}",
                    "propertyName": "email|string"
                  }
                ]
              }
            }
          ]
        },
        "additionalFields": {
          "properties": [
            "firstname",
            "lastname",
            "email",
            "phone"
          ]
        }
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot API Credentials"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "47964017-2ed4-4f4a-a180-8f89759a54d0",
      "name": "🆔 按 ID 获取联系人",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        -20,
        200
      ],
      "parameters": {
        "contactId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.searchValue }}"
        },
        "operation": "get",
        "authentication": "appToken",
        "additionalFields": {}
      },
      "credentials": {
        "hubspotAppToken": {
          "id": "YOUR_HUBSPOT_CREDENTIAL_ID",
          "name": "HubSpot API Credentials"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f6fc8617-197a-42da-9d5b-4d42d428b40d",
      "name": "📝 格式化联系人信息(ID 搜索)",
      "type": "n8n-nodes-base.code",
      "position": [
        200,
        200
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nlet contact = null;\n\nif (items.length === 0) {\n  return {\n    success: false,\n    message: 'Contact not found',\n    channelId: $('✂️ Parse Search Input').item.json.channelId,\n    responseUrl: $('✂️ Parse Search Input').item.json.responseUrl\n  };\n}\n\nif (items[0].json.results && items[0].json.results.length > 0) {\n  contact = items[0].json.results[0].properties;\n} else if (items[0].json.properties) {\n  contact = items[0].json.properties;\n} else {\n  return {\n    success: false,\n    message: 'Contact not found',\n    channelId: $('✂️ Parse Search Input').item.json.channelId,\n    responseUrl: $('✂️ Parse Search Input').item.json.responseUrl\n  };\n}\n\nconst firstName = $input.first().json.properties.firstname.value || '';\nconst lastName = $input.first().json.properties.lastname.value || '';\nconst fullName = $input.first().json.properties.hs_full_name_or_email.value || 'N/A';\nconst email = $input.first().json.properties.email.value || 'N/A';\nconst phone = $input.first().json.properties.phone.value || 'N/A';\n\nconst message = `📋 *Contact Information*\\n\\n` +\n  `👤 *Name:* ${fullName}\\n` +\n  `📧 *Email:* ${email}\\n` +\n  `📞 *Phone:* ${phone}`;\n\nreturn {\n  success: true,\n  message: message,\n  channelId: $('✂️ Parse Search Input').item.json.channelId,\n  responseUrl: $('✂️ Parse Search Input').item.json.responseUrl\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "5cb1767c-6d3d-4f08-b486-2cc1a59d2bd2",
      "name": "📝 格式化联系人信息(邮箱搜索)",
      "type": "n8n-nodes-base.code",
      "position": [
        200,
        0
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nlet contact = null;\n\nif (items.length === 0) {\n  return {\n    success: false,\n    message: 'Contact not found'\n  };\n}\n\n// Your input has `properties` directly inside the first item\nif (items[0].json.properties) {\n  contact = items[0].json.properties;\n} else {\n  return {\n    success: false,\n    message: 'Contact not found'\n  };\n}\n\nconst firstName = contact.firstname || '';\nconst lastName = contact.lastname || '';\nconst fullName = [firstName, lastName].filter(Boolean).join(' ') || 'N/A';\nconst email = contact.email || 'N/A';\nconst phone = contact.phone || 'N/A';\nconst company = contact.company || 'N/A';\nconst dealStage = contact.dealstage || 'N/A';\n\n\nconst message = `📋 *Contact Information*\\n\\n` +\n  `👤 *Name:* ${fullName}\\n` +\n  `📧 *Email:* ${email}\\n` +\n  `📞 *Phone:* ${phone}\\n` +\n  `🏢 *Company:* ${company}\\n` +\n  `💼 *Deal Stage:* ${dealStage}`;\n\nreturn {\n  success: true,\n  message\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "2df1ebf2-bda8-4112-994d-352a587ba91d",
      "name": "💬 发送联系人信息到 Slack",
      "type": "n8n-nodes-base.slack",
      "position": [
        420,
        100
      ],
      "webhookId": "slack-send-webhook-placeholder",
      "parameters": {
        "text": "={{ $json.message }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_CHANNEL_ID"
        },
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "id": "YOUR_SLACK_CREDENTIAL_ID",
          "name": "Slack API Credentials"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3fadae4a-a629-4c2a-aa3c-ed5d953ff1a4",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -940,
        -60
      ],
      "parameters": {
        "width": 420,
        "height": 520,
        "content": "## 节点:传入 Webhook (Webhook) + 检查消息是否存在 (If)"
      },
      "typeVersion": 1
    },
    {
      "id": "220b5b75-09af-4315-9844-d0740dc9d1cf",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -500,
        -160
      ],
      "parameters": {
        "color": 5,
        "width": 420,
        "height": 420,
        "content": "## 节点:解析搜索输入 (Parse Input) + 确定搜索类型 (Check Search Type)"
      },
      "typeVersion": 1
    },
    {
      "id": "0aad2c24-807f-4065-a905-19f0489d8bf3",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -420
      ],
      "parameters": {
        "color": 4,
        "width": 190,
        "height": 780,
        "content": "## 节点:按邮箱搜索联系人 (HubSpot) + 按 ID 获取联系人 (Get by ID)"
      },
      "typeVersion": 1
    },
    {
      "id": "9a3e57b1-fc33-411c-8237-5285158a06ad",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -420
      ],
      "parameters": {
        "color": 6,
        "width": 190,
        "height": 780,
        "content": "## 节点:格式化联系人信息"
      },
      "typeVersion": 1
    },
    {
      "id": "2d27ce7f-2d1f-4dbb-8116-225661aa9be4",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -240
      ],
      "parameters": {
        "color": 3,
        "width": 190,
        "height": 600,
        "content": "## 节点:发送联系人信息到 Slack (Send to Slack)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "PLACEHOLDER_VERSION_ID",
  "connections": {
    "🆔 Get Contact by ID": {
      "main": [
        [
          {
            "node": "📝 Format Contact Info (ID Search)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "✂️ Parse Search Input": {
      "main": [
        [
          {
            "node": "🔀 Determine Search Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔀 Determine Search Type": {
      "main": [
        [
          {
            "node": "📧 Search Contact by Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🆔 Get Contact by ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🌐 Incoming Slash Command": {
      "main": [
        [
          {
            "node": "🔍 Check if Message Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📧 Search Contact by Email": {
      "main": [
        [
          {
            "node": "📝 Format Contact Info (Email Search)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔍 Check if Message Exists": {
      "main": [
        [
          {
            "node": "✂️ Parse Search Input",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🛑 Stop – Missing Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📝 Format Contact Info (ID Search)": {
      "main": [
        [
          {
            "node": "💬 Send Contact Info to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📝 Format Contact Info (Email Search)": {
      "main": [
        [
          {
            "node": "💬 Send Contact Info to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 客户关系管理, 多模态 AI

需要付费吗?

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

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

适合有一定经验的用户,包含 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 查看

分享此工作流