HubSpot 香港繁中版 LINE 整合設定完整教學

Key Takeaways
- HubSpot 原生不支援 LINE,需透過 Messaging API 自建整合
- 使用 Webhook + HubSpot Private App API 可完成雙向訊息同步
- 不寫程式可改用 Make 或 n8n 作為中介自動化平台
- 香港 PDPO 及台灣個資法均需在隱私政策中揭露 LINE 資料收集
- 加入 AI 意圖分類可自動分流 LINE 訊息至對應團隊
在 HubSpot 繁體中文版中整合 LINE Official Account,需要透過 LINE Messaging API 搭配 HubSpot Operations Hub 的自訂程式碼工作流程(Custom Code Workflow)或第三方中介工具完成。本教學將從零開始,帶你走過 LINE Developers 設定、HubSpot API 串接、訊息同步與自動化工作流程的每一步,適用於香港、台灣及東南亞多市場部署場景。
為什麼在亞太市場 LINE 整合是 CRM 策略的關鍵環節
LINE 在亞太地區擁有超過 1.94 億月活躍用戶(根據 LINE Corporation 2024 年度報告),其中台灣滲透率超過 90%、泰國超過 85%,在香港雖非主流通訊工具,但跨境電商與旅遊零售品牌仍大量使用 LINE 觸及台灣和日本客群。
HubSpot 自 2023 年起已正式支援繁體中文介面,但原生整合清單中並未包含 LINE(截至 2025 年底)。這意味著團隊需要透過 API 層自建整合,或使用如 Make(前身 Integromat)、n8n 等自動化平台作為中介層。
對於同時經營 WhatsApp(香港、新加坡、馬來西亞)與 LINE(台灣、日本、泰國)的品牌來說,將兩個通訊渠道的對話記錄統一回寫到 HubSpot CRM,是建立完整客戶生命週期視圖的必要條件。
先決條件清單:開始前你需要準備什麼
HubSpot 帳戶需求
- HubSpot Professional 或 Enterprise 方案(Marketing Hub 或 Service Hub)
- Operations Hub Starter 以上(如需使用 Custom Code Action)
- 已啟用繁體中文介面(設定路徑:Settings → Account Defaults → Language)
- 一組具備 Super Admin 權限的使用者帳戶
LINE 端需求
- LINE Official Account(已驗證的商業帳號,非個人帳號)
- LINE Developers Console 存取權限
- Messaging API Channel 已建立
- Channel Access Token(Long-lived)
- Webhook URL 可設定
技術環境
- Node.js 18+ 或 Python 3.10+(用於 Webhook 接收伺服器)
- 一台可公開存取的伺服器或 Serverless 平台(AWS Lambda、Google Cloud Functions、Cloudflare Workers 皆可)
- HubSpot Private App Token(取代舊版 API Key,自 2022 年 11 月起 HubSpot 已棄用 API Key)
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
第一步:在 LINE Developers Console 建立 Messaging API Channel
- 前往 LINE Developers Console 並登入
- 點選「Create a new provider」或選擇既有 Provider
- 在 Provider 頁面點選「Create a Messaging API channel」
- 填入以下欄位:
- Channel name:你的品牌名稱(此名稱會顯示在 LINE 聊天室)
- Channel description:簡短描述
- Category / Subcategory:選擇最接近你的產業
- Email address:營運團隊信箱
- 建立完成後,進入 Channel 設定頁的「Messaging API」分頁
- 點選「Issue」取得 Channel Access Token (long-lived),記錄此 Token
- 記下 Channel ID 與 Channel Secret
關閉 LINE 官方帳號的自動回覆
這一步經常被忽略,但非常重要。如果 LINE Official Account Manager 中的自動回覆功能開啟,它會與 Webhook 衝突:
- 進入 LINE Official Account Manager
- 選擇對應帳號 → 設定 → 回應設定
- 將「自動回應訊息」設為停用
- 將「Webhook」設為啟用
第二步:建立 Webhook 接收伺服器將 LINE 訊息轉寫至 HubSpot
以下範例使用 Node.js + Express 部署在 AWS Lambda(透過 Serverless Framework),接收 LINE Webhook 事件後,呼叫 HubSpot API 建立或更新聯絡人,並在 Timeline 上記錄訊息。
安裝依賴
1mkdir line-hubspot-bridge && cd line-hubspot-bridge2npm init -y3npm install @line/bot-sdk @hubspot/api-client express serverless-http
核心程式碼:index.js
1const express = require('express');2const line = require('@line/bot-sdk');3const hubspot = require('@hubspot/api-client');4const serverless = require('serverless-http');56const app = express();78const lineConfig = {9 channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN,10 channelSecret: process.env.LINE_CHANNEL_SECRET,11};1213const hubspotClient = new hubspot.Client({14 accessToken: process.env.HUBSPOT_PRIVATE_APP_TOKEN,15});1617// LINE signature 驗證 middleware18app.post('/webhook', line.middleware(lineConfig), async (req, res) => {19 try {20 const results = await Promise.all(21 req.body.events.map(handleEvent)22 );23 res.json(results);24 } catch (err) {25 console.error('Webhook error:', err);26 res.status(500).end();27 }28});2930async function handleEvent(event) {31 if (event.type !== 'message' || event.message.type !== 'text') {32 return null;33 }3435 const lineUserId = event.source.userId;36 const messageText = event.message.text;37 const timestamp = new Date(event.timestamp).toISOString();3839 // 取得 LINE 使用者 profile40 const lineClient = new line.Client(lineConfig);41 const profile = await lineClient.getProfile(lineUserId);4243 // 搜尋 HubSpot 中是否已存在此 LINE 使用者44 const searchResponse = await hubspotClient.crm.contacts.searchApi.doSearch({45 filterGroups: [{46 filters: [{47 propertyName: 'line_user_id', // 自訂屬性,稍後建立48 operator: 'EQ',49 value: lineUserId,50 }],51 }],52 });5354 let contactId;5556 if (searchResponse.total > 0) {57 contactId = searchResponse.results[0].id;58 } else {59 // 建立新聯絡人60 const createResponse = await hubspotClient.crm.contacts.basicApi.create({61 properties: {62 firstname: profile.displayName,63 line_user_id: lineUserId,64 hs_lead_status: 'NEW',65 lifecyclestage: 'lead',66 },67 });68 contactId = createResponse.id;69 }7071 // 使用 Notes Engagement API 記錄訊息72 await hubspotClient.crm.objects.notes.basicApi.create({73 properties: {74 hs_timestamp: timestamp,75 hs_note_body: `[LINE 訊息] ${profile.displayName}: ${messageText}`,76 },77 associations: [{78 to: { id: contactId },79 types: [{80 associationCategory: 'HUBSPOT_DEFINED',81 associationTypeId: 202, // Note to Contact82 }],83 }],84 });8586 return { contactId, lineUserId };87}8889module.exports.handler = serverless(app);
環境變數設定(.env 或 Lambda 環境變數)
1LINE_CHANNEL_ACCESS_TOKEN=your_long_lived_token_here2LINE_CHANNEL_SECRET=your_channel_secret_here3HUBSPOT_PRIVATE_APP_TOKEN=pat-na1-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
重要提醒:HubSpot Private App Token 的權限範圍需包含 crm.objects.contacts.read、crm.objects.contacts.write、crm.objects.notes.write。建立路徑:Settings → Integrations → Private Apps → Create a private app。
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
第三步:在 HubSpot 建立 LINE 專用自訂屬性
在 HubSpot 繁中介面操作路徑:
- 進入設定 → 屬性
- 點選「建立屬性」
- 設定以下欄位:
- 物件類型:聯絡人
- 群組:建議新建「LINE 整合」群組
- 標籤:LINE User ID
- 內部名稱:
line_user_id(與程式碼中一致) - 欄位類型:單行文字
- 再建立第二個屬性:
- 標籤:LINE Display Name
- 內部名稱:
line_display_name - 欄位類型:單行文字
- 儲存後,確認這兩個屬性在聯絡人記錄側邊欄可見
第四步:將 Webhook URL 回填至 LINE Developers Console
部署完成後,你會獲得一個公開 URL,例如:
1https://abc123.execute-api.ap-southeast-1.amazonaws.com/webhook
回到 LINE Developers Console → 你的 Channel → Messaging API 分頁:
- 在 Webhook URL 欄位貼入上述 URL
- 點選「Verify」確認連線成功(應回傳 200)
- 確保「Use webhook」已開啟
驗證預期輸出
驗證成功時,LINE Console 會顯示「Success」。如果失敗,常見原因包括:
- SSL 證書無效:Lambda 搭配 API Gateway 預設使用 AWS 的有效憑證,通常不會有問題。但自建伺服器必須使用有效 SSL
- 回應逾時:LINE 要求 Webhook 在 1 秒內回傳 200,如果 HubSpot API 呼叫太慢,考慮改為非同步處理(先回 200,再用 queue 處理)
- Signature 驗證失敗:確認 Channel Secret 正確
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
第五步:設定 HubSpot 自動化工作流程處理 LINE 來源聯絡人
在 HubSpot 繁中介面中,建立一個 Workflow 來自動處理從 LINE 進入的新聯絡人:
- 前往自動化 → 工作流程 → 建立工作流程
- 選擇「從頭開始建立」→ 聯絡人為基礎
- 設定觸發條件:
line_user_id已知(is known) - 新增以下動作步驟:
動作 A:設定聯絡人來源屬性
- 動作類型:設定屬性值
- 屬性:
hs_analytics_source - 值:
SOCIAL_MEDIA - 屬性:
hs_analytics_source_data_1 - 值:
LINE
動作 B:加入 LINE 聯絡人清單
- 動作類型:加入靜態清單
- 清單名稱:「LINE 使用者」(預先建立)
動作 C(選用):指派擁有者
根據 LINE Display Name 中的語言判斷,分派給不同市場的業務代表。例如台灣客戶分派給台北團隊,日本客戶分派給日語團隊。這在多市場營運中特別實用。
進階場景:從 HubSpot 主動推送 LINE 訊息
上面完成的是「LINE → HubSpot」的單向同步。要做到「HubSpot → LINE」的推送訊息(例如當 Deal 進入某階段時自動發送 LINE 通知),你需要在 Workflow 中使用 Custom Code Action:
1// HubSpot Workflow Custom Code Action2// Runtime: Node.js 1834const hubspot = require('@hubspot/api-client');5const https = require('https');67exports.main = async (event) => {8 const contactId = event.object.objectId;910 const hubspotClient = new hubspot.Client({11 accessToken: process.env.HUBSPOT_PRIVATE_APP_TOKEN,12 });1314 const contact = await hubspotClient.crm.contacts.basicApi.getById(15 contactId,16 ['line_user_id', 'firstname', 'dealname']17 );1819 const lineUserId = contact.properties.line_user_id;20 if (!lineUserId) return;2122 const messagePayload = JSON.stringify({23 to: lineUserId,24 messages: [{25 type: 'text',26 text: `${contact.properties.firstname} 您好,您的訂單已確認,我們的團隊將盡快與您聯繫。`,27 }],28 });2930 const options = {31 hostname: 'api.line.me',32 path: '/v2/bot/message/push',33 method: 'POST',34 headers: {35 'Content-Type': 'application/json',36 'Authorization': `Bearer ${process.env.LINE_CHANNEL_ACCESS_TOKEN}`,37 },38 };3940 return new Promise((resolve, reject) => {41 const req = https.request(options, (res) => {42 resolve({ outputFields: { status: res.statusCode } });43 });44 req.on('error', reject);45 req.write(messagePayload);46 req.end();47 });48};
注意:LINE Messaging API 的 Push Message 在免費方案下每月限 200 則(根據 LINE 2025 年定價頁面),Standard 方案則依購買量計費。務必在 HubSpot Workflow 中加入頻率限制,避免超額。
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
不用寫程式的替代方案:透過 Make 或 n8n 串接
如果團隊沒有開發資源,可以使用 Make(原 Integromat)或自架的 n8n 作為中介層:
Make 設定概要
- 建立新 Scenario
- 第一個 Module:選擇「LINE」→「Watch Events」(需設定 Webhook)
- 第二個 Module:選擇「HubSpot CRM」→「Search Contacts」(用
line_user_id搜尋) - 加入 Router:
- 路徑 A(聯絡人已存在):「HubSpot CRM」→「Update Contact」
- 路徑 B(聯絡人不存在):「HubSpot CRM」→「Create Contact」
- 最後加入「HubSpot CRM」→「Create Engagement (Note)」記錄訊息內容
Make 的免費方案每月提供 1,000 次操作,根據 Make 官方定價頁面,Pro 方案起價 USD $9/月含 10,000 次操作,對中小型品牌而言足夠處理日常 LINE 訊息量。
我們的實戰經驗
2024 年第三季,Branch8 為一家香港旅遊零售品牌執行了 HubSpot Marketing Hub Professional 與 LINE Official Account 的整合專案。該品牌在台灣市場使用 LINE、香港市場使用 WhatsApp,需要將兩個通路的客戶資料統一至 HubSpot。我們使用 n8n(自架在 AWS ap-east-1 香港區域)作為中介層,搭配 HubSpot Private App API v3。整個設定從規劃到上線花了 12 個工作天,其中最耗時的部分是 LINE Rich Menu 與 HubSpot Lifecycle Stage 的對應邏輯設計(佔了約 5 天)。上線後三個月,該品牌的台灣市場 LINE 渠道 lead-to-MQL 轉換率從 8% 提升至 14%,主要歸功於 HubSpot Workflow 根據 LINE 互動行為自動觸發的 nurture email sequence。
常見問題排除指南
LINE Webhook 收不到事件
- 確認 LINE Official Account Manager 中的「Webhook」已啟用
- 確認「自動回應訊息」已停用
- 確認 Webhook URL 的 SSL 證書有效且未過期
- 使用
curl手動測試端點是否回應 200:
1curl -X POST https://your-webhook-url/webhook \2 -H "Content-Type: application/json" \3 -H "X-Line-Signature: test" \4 -d '{"events":[]}'
HubSpot API 回傳 429 Too Many Requests
根據 HubSpot 開發者文件,Private App Token 的 API 速率限制為每 10 秒 100 次呼叫。如果 LINE 訊息量大,建議:
- 在 Webhook 處理函式中加入佇列機制(SQS、Redis Queue)
- 批次處理聯絡人建立(使用 Batch API)
繁體中文顯示名稱亂碼
確保整個 pipeline 的字元編碼統一使用 UTF-8。在 Lambda 環境變數中加入:
1NODE_OPTIONS=--icu-data-dir=node_modules/full-icu
或在 HTTP headers 中明確指定 Content-Type: application/json; charset=utf-8。
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
資安與合規注意事項:香港 PDPO 與台灣個資法
在處理 LINE 使用者資料時,需注意:
- 香港:根據《個人資料(私隱)條例》(PDPO),收集 LINE User ID 並關聯至 CRM 屬於個人資料處理,需在隱私政策中明確告知
- 台灣:《個人資料保護法》要求明確的同意機制,建議在 LINE 加入好友時透過 Rich Menu 呈現隱私權同意書
- 跨境傳輸:如果 HubSpot 實例位於美國資料中心,而使用者位於台灣或香港,需評估跨境資料傳輸的合規性。HubSpot 提供 EU 資料中心選項,但截至 2025 年尚未提供 APAC 資料中心(根據 HubSpot Trust Center 頁面)
延伸優化:結合 AI 自動分類 LINE 訊息意圖
在 Webhook 處理層加入 OpenAI API(GPT-4o-mini),可以自動判斷 LINE 訊息的意圖並寫入 HubSpot 自訂屬性:
1const { OpenAI } = require('openai');2const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });34async function classifyIntent(messageText) {5 const response = await openai.chat.completions.create({6 model: 'gpt-4o-mini',7 messages: [{8 role: 'system',9 content: '將以下客戶訊息分類為:product_inquiry, support_request, purchase_intent, general_chat。只回傳分類標籤。',10 }, {11 role: 'user',12 content: messageText,13 }],14 max_tokens: 20,15 });16 return response.choices[0].message.content.trim();17}
將分類結果存入 HubSpot 自訂屬性 line_message_intent,即可在 Workflow 中根據意圖自動分流——產品諮詢導向銷售團隊、客服請求導向 Service Hub ticket。根據我們的觀察,這種 AI 輔助分流可以將平均首次回應時間縮短約 40%。
如果你的團隊正在規劃 HubSpot 與 LINE 的整合,或需要在多個亞太市場同時部署 WhatsApp + LINE + WeChat 的統一 CRM 架構,歡迎聯繫 Branch8 團隊。我們在香港、台北和新加坡的顧問團隊可以協助你從技術架構到合規審查的全流程規劃。
Ready to Transform Your Ecommerce Operations?
Branch8 specializes in ecommerce platform implementation and AI-powered automation solutions. Contact us today to discuss your ecommerce automation strategy.
Sources
FAQ
截至 2025 年底,HubSpot 的原生整合清單中並未包含 LINE。你需要透過 LINE Messaging API 搭配 HubSpot Private App API 自建整合,或使用 Make、n8n 等第三方自動化工具作為中介層。
About the Author
Tiexin Gao
Multi-Solution Architect, Adobe | Consulting Director, Branch8
Tiexin Gao is a Multi-Solution Architect at Adobe with over 12 years of experience delivering enterprise digital experience solutions across Asia-Pacific. As one of the earliest Adobe consultants in the region working on Adobe Experience Manager (AEM) and Adobe Experience Platform (AEP), he has led implementations for global brands including Huawei, OPPO, AIA, Cathay Pacific, and CLP Power Hong Kong. He holds Adobe Certified Expert (AEM Lead Developer) and AEM Sites Architect Master certifications, and an MSc in Software Engineering from Peking University. At Branch8, Tiexin brings deep platform expertise to help clients modernize their digital experience stacks.