8
n8n 中文网amn8n.com

从JotForm提交创建HubSpot公司和任务,含Google Sheets记录

中级

这是一个自动化工作流,包含 13 个节点。主要使用 Code, Wait, Hubspot, HttpRequest, GoogleSheets 等节点。 从JotForm提交创建HubSpot公司和任务,含Google Sheets记录

前置要求
  • HubSpot API Key
  • 可能需要目标 API 的认证凭证
  • Google Sheets API 凭证

分类

-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "67dd1445921862780ac74448aef33eb969db12b9a6ce95248c7ae86a887cb653",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "0293a49f-3721-456a-9951-3c0c0fc8ba5d",
      "name": "JotForm 触发器",
      "type": "n8n-nodes-base.jotFormTrigger",
      "position": [
        640,
        416
      ],
      "webhookId": "4376713f-865d-4009-abeb-12ebedde63f5",
      "parameters": {
        "form": "252808415357461"
      },
      "credentials": {
        "jotFormApi": {
          "id": "anmQIw1moNILel4d",
          "name": "JotForm account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b85baa2e-77ed-4939-8158-be4da9c49b30",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        1360,
        416
      ],
      "webhookId": "60d74e72-8895-4f22-a546-34f92db6c0cf",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "f4ac75b3-4578-4134-a3da-0d5420d3f578",
      "name": "创建 HubSpot 任务",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        1584,
        416
      ],
      "parameters": {
        "url": "https://api.hubapi.com/crm/v3/objects/tasks",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true,
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"properties\": {\n    \"hs_task_subject\": \"{{ $('Format Jotform Data').item.json.hubspot_task_title || 'Jotform Marketing Query' }}\",\n    \"hs_task_body\": \"{{ \n        'Company: ' + ($('Format Jotform Data').item.json.company_name || 'Unknown Company') + '\\\\n' + \n        'Person: ' + ($('Format Jotform Data').item.json.full_name || 'Unknown') + '\\\\n' + \n        'Email: ' + ($('Format Jotform Data').item.json.email || 'N/A') + '\\\\n' + \n        'LinkedIn: ' + ($('Format Jotform Data').item.json.linkedin_profile || 'N/A') + '\\\\n' + \n        'Domain: ' + ($('Format Jotform Data').item.json.domain || 'N/A') + '\\\\n' + \n        'Marketing Budget (USD): ' + ($('Format Jotform Data').item.json.marketing_budget_usd || 'N/A') + '\\\\n' + \n        'Specific Query: ' + ($('Format Jotform Data').item.json.specific_query || 'No query provided.')\n    }}\",\n    \"hs_task_status\": \"NOT_STARTED\",\n    \"hs_task_priority\": \"HIGH\",\n    \"hs_task_type\": \"CALL\",\n    \"hs_timestamp\": \"{{ $('Format Jotform Data').item.json.task_timestamp || (new Date().toISOString()) }}\",\n    \"hubspot_owner_id\": \"{{ $('Format Jotform Data').item.json.assigned_owner_id || '82654288' }}\"\n  },\n  \"associations\": [\n    {\n      \"to\": {\n        \"id\": \"{{ $('Format Jotform Data').item.json.company_id || '' }}\"\n      },\n      \"types\": [\n        {\n          \"associationCategory\": \"HUBSPOT_DEFINED\",\n          \"associationTypeId\": 192\n        }\n      ]\n    }\n  ]\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <your pat token>"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2b7fc36d-c4ca-485a-88ca-cfa47a5da226",
      "name": "创建公司1",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        912,
        416
      ],
      "parameters": {
        "name": "={{ $json.CompanyName }}",
        "resource": "company",
        "additionalFields": {}
      },
      "credentials": {
        "hubspotApi": {
          "id": "0JXgoSMegjZJIEeR",
          "name": "HubSpot dummy"
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "c17f50ae-ee93-4687-bb76-f9448775e7a0",
      "name": "格式化数据",
      "type": "n8n-nodes-base.code",
      "position": [
        1184,
        416
      ],
      "parameters": {
        "jsCode": "const inputData = $input.all();\nconst formattedData = [];\n\nconst ownerAssignments = {\n  owner1: \"82654288\",\n  owner2: \"944860204\", // Replace with actual ID\n};\n\n// helper: safely unescape quotes if Jotform encodes them\nconst unescapeQuotes = (v) =>\n  typeof v === 'string'\n    ? v.replace(/\\\\'/g, \"'\").replace(/\\\\\"/g, '\"')\n    : v;\n\nfor (const { json: item } of inputData) {\n  // Extract and sanitize fields\n  const firstName       = unescapeQuotes(item[\"First Name\"] || item.first_name || '');\n  const lastName        = unescapeQuotes(item[\"Last Name\"] || item.last_name || '');\n  const fullName        = `${firstName} ${lastName}`.trim() || 'Unknown';\n  const email           = unescapeQuotes(item.Email || item.email || '');\n  const linkedinProfile = unescapeQuotes(item[\"Linkedin Profile\"] || item.linkedin || '');\n  const companyName     = unescapeQuotes(item[\"Company Name\"] || item.company_name || 'Unknown Company');\n  const marketingBudget = unescapeQuotes(item[\"Marketing Budget ( in USD )\"] || item.marketing_budget || '');\n  const domain          = unescapeQuotes(item.Domain || item.domain || '');\n  const specificQuery   = unescapeQuotes(item[\"Any Specific querry ?\"] || item.query || '');\n\n  // Task title\n  const taskTitle = `(Jotform) Marketing Query from ${fullName} (${companyName})`;\n\n  // Owner assignment (basic hash)\n  const companyHash = (companyName || '').length % 2;\n  const assignedOwnerId = companyHash === 0 ? ownerAssignments.owner1 : ownerAssignments.owner2;\n\n  // Timestamp (24 hrs from now)\n  const futureDate = new Date();\n  futureDate.setHours(futureDate.getHours() + 24);\n  const taskTimestamp = futureDate.toISOString();\n\n  // Final formatted structure\n  const formattedItem = {\n    first_name: firstName,\n    last_name: lastName,\n    full_name: fullName,\n    email: email,\n    linkedin_profile: linkedinProfile,\n    company_name: companyName,\n    marketing_budget_usd: marketingBudget,\n    domain: domain,\n    specific_query: specificQuery,\n    hubspot_task_title: taskTitle,\n    task_timestamp: taskTimestamp,\n    assigned_owner_id: assignedOwnerId,\n  };\n\n  formattedData.push({ json: formattedItem });\n}\n\nreturn formattedData;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "da057d1b-4a6e-4e28-8aee-b3636c16831c",
      "name": "存储日志",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2240,
        416
      ],
      "parameters": {
        "columns": {
          "value": {
            "Notes": "=This was created at {{ $json.createdAt }} & was updated at {{ $json.updatedAt }}",
            "domain": "={{ $json.properties.domain }}",
            "company": "={{ $json.properties.name }}",
            "HubspotCompanyID": "={{ $json.id }}"
          },
          "schema": [
            {
              "id": "company",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "company",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "No. of Stores",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "No. of Stores",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "domain",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Notes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "HubspotCompanyID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "HubspotCompanyID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "domain"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1117410898,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ETTxIAb6Kj69V7xInvYEdYqvKcV8mjE3BoT1a7ER5tE/edit#gid=1117410898",
          "cachedResultName": "AlreadyExistingHC"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ETTxIAb6Kj69V7xInvYEdYqvKcV8mjE3BoT1a7ER5tE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ETTxIAb6Kj69V7xInvYEdYqvKcV8mjE3BoT1a7ER5tE/edit?usp=drivesdk",
          "cachedResultName": "Linkedin2Hubspot"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "78jRH4x5Oj2STz8x",
          "name": "Google Sheets dummy"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "a479a00e-a33e-4123-9887-ef98144d0ec3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        16
      ],
      "parameters": {
        "width": 416,
        "height": 624,
        "content": "## 🧾 JOTFORM 触发器"
      },
      "typeVersion": 1
    },
    {
      "id": "ce5c50c0-18f6-45d8-a74b-13c500fb3777",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        16
      ],
      "parameters": {
        "color": 6,
        "width": 416,
        "height": 624,
        "content": "## 🏢 HUBSPOT 公司创建与格式化器"
      },
      "typeVersion": 1
    },
    {
      "id": "3231a6ce-d8f8-434b-af2b-fcb08d4a00ba",
      "name": "设置公司域名",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        2016,
        416
      ],
      "parameters": {
        "url": "=https://api.hubapi.com/crm/v3/objects/companies/{{ $('Loop Over Items3').item.json.company_id }}",
        "method": "PATCH",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "jsonBody": "={\n  \"properties\": {\n    \"domain\": \"{{ $('Loop Over Items3').item.json.domain}}\"\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer < PAT >"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "968e7fc6-65fa-4385-aba8-2933bac8ed02",
      "name": "等待10",
      "type": "n8n-nodes-base.wait",
      "position": [
        1808,
        416
      ],
      "webhookId": "97ecc78e-a2af-485e-883e-48559fe4477b",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "565fce0c-493d-4171-a095-b16d9993b3a3",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 640,
        "content": "## 🔁 HUBSPOT 任务创建"
      },
      "typeVersion": 1
    },
    {
      "id": "a332ddf0-e435-4371-b213-8699c3cf066f",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1744,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 400,
        "height": 640,
        "content": "## 🌐 循环遍历与域名设置"
      },
      "typeVersion": 1
    },
    {
      "id": "62fd01c6-f579-4fb3-9807-f414c2312bed",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2160,
        0
      ],
      "parameters": {
        "color": 2,
        "width": 256,
        "height": 624,
        "content": "## 📊 存储日志"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Create HubSpot Task",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait10": {
      "main": [
        [
          {
            "node": "Set Company Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Formating Data": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JotForm Trigger": {
      "main": [
        [
          {
            "node": "Create a company1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a company1": {
      "main": [
        [
          {
            "node": "Formating Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Company Domain": {
      "main": [
        [
          {
            "node": "Storel Logs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create HubSpot Task": {
      "main": [
        [
          {
            "node": "Wait10",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级

需要付费吗?

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

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

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

作者
Rahi Uppal

Rahi Uppal

@rahiuppal

AI and Automation Consultant with over 1000 hours of experience building, deploying, and solving marketing and sales automation problems. I ship AI products faster by combining business acumen with AI & automation expertise and an engineering mindset. Connect with me on LinkedIn to chat.

外部链接
在 n8n.io 查看

分享此工作流