處理流程(P2-A / B / C)
P2-A | 音檔下載器
Section titled “P2-A | 音檔下載器”觸發:每天 4 輪 09:00 / 13:00 / 17:00 / 21:00(cron
0 9,13,17,21 * * *) 檔案:P2-A_v3_with_owner.json職責:Genesys → GCS → HubSpot pending Call
| # | 節點 | 做什麼 |
|---|---|---|
| 1 | Schedule | 每天 4 輪(09/13/17/21:00)觸發 |
| 2 | Get Genesys Token | OAuth 取 access token |
| 3 | Calculate Time Range | 算最近 25 小時區間(1500 分鐘) |
| 4 | Query Conversations | 撈時間範圍內所有 conversation |
| 5 | Filter > 5s | 過濾未接 / 誤撥 |
| 6 | Batch Dedup Check | IN batch search HubSpot,過濾已建 Call |
| 7 | Get Recordings | Single Shot 模式:1 次 fetch + AbortController 5s |
| 8 | Skip if not ready | 沒拿到錄音 → skip + 下個 cron 重試 |
| 9 | Download ch0/ch1 | 下載雙軌音檔 |
| 10 | Upload to GCS | YYYY-MM-DD/HHMM_DIR_PHONE_CONVID/ch0.mp3 |
| 11 | Extract Call Info | 抽方向、電話、業務員 ID |
| 12 | Map Owner | Genesys agent → HubSpot Owner ID |
| 13 | Create HubSpot Call | status = pending |
- Single Shot vs Polling:原 polling 設計(4 retry × 3 wait)對「HTTP 200 + empty body」會 hang 撞 60s task timeout,改 Single Shot + AbortController 5s + 下個 cron 自動補抓,所有失敗路徑統一為 skip + next cron
- Batch Dedup:用 HubSpot Search IN batch 一次檢查 100 通,省 API quota
- 時間窗 25 小時:涵蓋整天 + 1 小時 buffer,跨日通話不會漏
P2-B | 轉錄器
Section titled “P2-B | 轉錄器”觸發:每天 4 輪 09:30 / 13:30 / 17:30 / 21:30(cron
30 9,13,17,21 * * *) 檔案:P2-B_v3.1_transcribe_only.json職責:呼叫 VM/transcribe→ 寫 transcript_raw
| # | 節點 | 做什麼 |
|---|---|---|
| 1 | Schedule | 每天 4 輪(09/13/17/21:30)觸發 |
| 2 | Search Pending Calls | 撈 transcribe_status = pending(limit 50) |
| 3 | Lock as Transcribing | PATCH status = transcribing |
| 4 | Get GCS URLs | 拿 ch0 / ch1 signed URLs |
| 5 | Call /transcribe | POST 到 VM endpoint(含 ffmpeg 切片) |
| 6 | Merge Channels | 雙軌穿插時間排序 |
| 7 | Update HubSpot Call | PATCH transcript_raw + status = transcribed |
- VM endpoint:
http://35.221.152.147:8081/transcribe,自架避開 Whisper API 直接呼叫的延遲 - ffmpeg chunkSeconds = 60:v3.1 從 300 改為 60,避免 Whisper 對長片段產生 hallucination
- 並行 Whisper:ch0 / ch1 同時送 Whisper,2x 加速
- 雙軌時間穿插格式:
[MM:SS speaker] text,給 P2-C 萃取用
P2-C | 摘要 + CRM 寫回
Section titled “P2-C | 摘要 + CRM 寫回”觸發:每天 4 輪 10:00 / 14:00 / 18:00 / 22:00(cron
0 10,14,18,22 * * *) 檔案:P2-C_v3_summarize_only.json職責:OpenAI 摘要 → HubSpot Call + Contact
| # | 節點 | 做什麼 |
|---|---|---|
| 1 | Schedule | 觸發 |
| 2 | Search Transcribed Calls | 撈 transcribe_status = transcribed(limit 50) |
| 3 | Extract Call Context | 抽方向、電話、normalize TW phone |
| 4 | Lock as Summarizing | PATCH status = summarizing |
| 5 | Has Transcript? | 過濾未接通 / [UNANSWERED] |
| 6 | OpenAI Summarize | gpt-4o-mini + json_schema response format |
| 7 | Parse OpenAI | 解析 JSON、防呆 |
| 8 | Build Call Update Body | 組 hs_call_body(5 點摘要 + 待辦 + 雙軌逐字稿) |
| 9 | Update HubSpot Call | PATCH summarized |
| 10 | Search Contact by Phone | 4 種號碼格式 OR 查詢 |
| 11 | Contact Found? | 分支:找到→Update / 沒找到→Create |
| 12 | Build Contact Patch | fill-only-empty 邏輯 |
| 13 | Update / Create Contact | PATCH or POST |
| 14 | Associate Call ↔ Contact | HubSpot v4 associations API |
- OpenAI response_format = json_schema:strict 模式保證結構化輸出,省 parse error
- fill-only-empty:業務手寫資料永遠優先,AI 只補空白欄位
- 4 種電話格式 OR 查詢:E.164、本地、mobilephone 等都查,提高 Contact 匹配率
- multi-select 結帳方式:v3.2 新增「刷卡」選項
- 意圖標籤嚴格 4 選 1:詢價 / 售後 / 抱怨 / 一般諮詢,AI 不自創
Error Notifier
Section titled “Error Notifier”觸發:任一 workflow 失敗時自動呼叫 檔案:
P2-Error-Notifier_v2_2026-05-04.json
收到失敗 webhook → 整理錯誤訊息 → 寄 Email / LINE 通知 Ray,包含:
- 失敗 workflow 名稱
- 失敗 node
- 錯誤訊息
- HubSpot Call ID(如有)
限制與配額(n8n Cloud Starter)
Section titled “限制與配額(n8n Cloud Starter)”| 限制 | 上限 | 目前用量 | Buffer |
|---|---|---|---|
| Executions / 月 | 2,500 | ~90 | 96% |
| Workflow execution time | 60 分鐘 | ~30 分鐘最壞 | 50% |
| Code node task runner | 60 秒 | < 5 秒 | 92% |
| HTTP Request timeout | 300 秒 | ~3 秒 | 99% |
| Concurrent workflow runs | 5 | 1(cron 錯開) | 80% |
| Active workflows | 15 | 5(A/B/C + P1 + Error) | 67% |
| HubSpot Search secondly | 5 req/10s | 1 req/cron | 80% |
| HubSpot daily call limit | 250,000 | ~2,400 | 99% |
真正撞牆量級:5h 內 150+ 通真實接通(≈ 一天 600 通),屬 Phase 2 規模化議題。