總覽

從零認識 ContactLoop

這份指南把新人從「不知道 ContactLoop 是什麼」一路帶到「能在 stg 環境建一個帳號、跑出一套測試」。內容來自實際 repo(samurai-world、ava、auto_cl)的程式碼與內部文件,不是憑空想像。

2 個核心系統 3 個環境 40+ 個頁面 2 條上手路線

兩大系統各做什麼

ContactLoop 由兩個互相呼叫的系統組成,合起來才是一個完整的「名單 → 觸發 → 對話 → 回寫」迴圈(Contact Loop 由此得名)。

Samurai World

SW Manager(策略中樞)

Contact 的主檔:匯入、清洗、分群(Segment)、觸發(Trigger)、素材(Asset)、App Integration(接 Ava)。決定「什麼時候、對誰、做什麼」。前端 samurai-world-client(Next.js),後端 samurai-world-backend

Ava

Ava Messenger(互動引擎)

實際執行對話與通話:Conversation、Call、Bot 回覆、IVR、排程通話。決定「怎麼跟對方講話」。前端 ava-client,後端 ava(Laravel)。整合 Twilio / Quo / Pusher / Elasticsearch。

資料怎麼流(迴圈)

外部名單 ─► SW 建檔/清洗/分群
            │
            ▼
SW Trigger / App Integration ─► 呼叫 Ava API(以 Ava Account ID 為對接鍵)
            │
            ▼
Ava 建立 Lead / Journey ─► 發第一則訊息(Welcome / SendFirstMessageJob)
            │
            ▼
客戶回覆 ─► Ava ReplyMessageJob(AI 意圖偵測 → 一般回覆 / 預約通話)
            │
            ▼
Ava 透過 Webhook 回寫 SW(Journey Log / Opt-out)─► SW 顯示在 Contact Activities
🔑

對接鍵是 Ava Account ID。SW 在 App Integration 設定裡用 config.api_key 存 Ava account ID 來列 Ava Campaign;Contact 透過 external_lead_entity_idtraffic_source 同步到 Ava 成為 Lead。雙向事件閉環,就是 ContactLoop。

Opt-out(退訂)層級對應

退訂在三個層級各自獨立,跨系統要對齊:

Ava 層級對應到 SW影響範圍
account opt-outContactLead opt-out單一 Ava 帳號下的該聯絡人
organization opt-outContact opt-out整個組織下的該聯絡人
global opt-out同號碼的所有 Contact opt-out該電話號碼全面退出

總覽

三個環境:stg / cl1 / prod

ContactLoop 有三個獨立部署的環境,各自有獨立的 SW 與 Ava、獨立的帳號與 Account ID。新人一律先在 stg 練習。

環境SW Manager URLAva Messenger URL用途 / 風險
stg Staging staging.sw.onramplab.com staging.ava.onramplab.com 開發整合測試、QA 跑測試的主要環境。🟢 低風險,可亂搞。
cl1 CL1 manager-cl1.contactloop.com messenger-cl1.contactloop.com Pre-prod / 客戶預覽。🟡 中風險,部分新版頁面可能還沒跟上 stg。
prod Production manager.contactloop.com messenger.contactloop.com 正式流量、真實客戶資料。🔴 高風險,勿任意匯入或觸發。
⚠️

每個環境的 Account ID 都不同。例如 stg 的 sw_nucleus.account_id=93,cl1 是 38,prod 是 361。把 stg 的設定直接搬到 prod 一定對不上——所有設定以 conftest.pyENV_CONFIG 為準。

環境版本會落差(常見困惑來源)

stg 通常是最新版,cl1 / prod 的前端部署會晚一點跟上。例如 2026-08 實測:stg 的 Contacts 系列已改打 /api/contacts/grid,但 cl1 的 Marketing Sources / Endpoint Attributes / Technographics 三頁還在打舊版 /api/contacts?…size=500。測試裡這類情況會標成 xfail(預期失敗),部署跟上後自動轉 XPASS。看到 xfail 不是壞掉,是「已知環境落差」。

總覽

兩條上手路線,挑你那條

新人不一定都是工程師。這份指南分兩條路線,各自走完就能上工:

路線 A

產品使用者 / 營運

目標:從 Ava Messenger 建立一個新帳號、開出 API Key,一路接到 SW Manager、匯入名單、把 Segment 設到完成。不碰測試程式碼。

→ 前往「從 Ava 建帳號到 SW Segment」

路線 B

QA / 測試工程師

目標:把 auto_cl 測試專案跑起來,在 stg 跑出一套綠綠的 E2E 報告。需要會一點 Python / 終端。

→ 前往「從 0 跑測試」

兩條路線都建議先讀上面的「ContactLoop 是什麼」與「三個環境」,後面的頁面功能章節則是共用參考。

SW 登入後導覽

登入 SW Manager 後,畫面長這樣Inside SW Manager after you log in

這一章帶你走一次登入後的整體畫面,再由上到下把左側選單的每個項目逐一介紹。選單結構取自 samurai-world-clientsrc/app/configs/routes.tsx;有 需 system-admin功能旗標開發中 標記的項目,在某些環境或帳號會看不到,屬正常。

① 整體畫面:頂部列 + 左側選單 + 主內容

🏠 左上 Logo回首頁 ▸ 帳號選單切 Organization / Account ⛶⚙🔔 工具列全螢幕 / 設定 / 通知 JK 右上頭像使用者選單與登出

② 頂部列三個區塊細講

🏠 左上 Logo BrandHomeLink
點擊 → /
左上角的 samurai vector logo。點下去會回首頁(/);若人在 Admin (All Organizations) 檢視中,點 logo 是一個「真正的頁面載入」離開 admin 檢視,不是前端切換。手機版側選單裡也有同一份 logo。
▸ Account / Organization 選單 OrgBreadcrumbSwitcher
頂部列中段
logo 右邊的麵包屑選單,顯示目前 Organization ▸ Account。點開可:選別的 Organization、在某 Org 下選某個 Account、或選「All Accounts」(看整個 Org 的彙總)。換 Account 會停留在同一頁並重抓該帳號資料;換 Organization 會回到首頁的 Org 彙總檢視。Admin 檢視中會改顯示 AdminBreadcrumb。三代 UI 相容(crumb-account-button / BreadcrumbTrigger / 舊版 Ant Select)。The breadcrumb switcher right of the logo, showing the current Organization ▸ Account. Open it to: pick another Organization, pick an Account within an Org, or choose "All Accounts" for an org-wide aggregate. Switching Account stays on the same page and re-fetches for that account; switching Organization lands on Home's org-aggregate view. Inside an admin view it becomes AdminBreadcrumb. Three UI generations coexist (crumb-account-button / BreadcrumbTrigger / legacy Ant Select).
⛶ ⚙ 🔔 工具列
頂部列右側
三個圖示:全螢幕切換(⛶ Maximize/Minimize,手機版隱藏)、設定(⚙ 打開右側 Settings 抽屜,可收合側選單 / 暗色側選單 / Dark mode)、通知(🔔,目前為預留槽)。Three icons: fullscreen toggle (⛶, hidden on mobile), settings (⚙ opens a right-hand Settings drawer — collapse sidebar / dark sidebar / dark mode), notifications (🔔, currently a placeholder).
JK 右上頭像 UserNameIcon + AccountMenuContent
頂部列最右
右上角顯示你的名字 + 大頭貼(沒照片時用姓名縮寫,顏色依名字 hash)。點開帳號選單:上方顯示姓名 / email,中間列出你所屬的 Organization(可由此切換),最下方是紅色 Sign out 登出。登出會呼叫 auth.logout() 再導向 /Top-right: your name + avatar (initials with a name-hashed color when no photo). The account menu shows your name/email, lists your Organizations (switchable from here), and a red Sign out at the bottom. Sign-out calls auth.logout() then redirects to /.
💡

左右選單的關係:左側選單的內容會依「目前選的 Account / Org」與你的角色動態變動——例如 system-admin 才看得到 Configuration / Settings / Admin;Conversion Tracking 要帶 conversion_tracking 旗標且在具體 Account 下才出現;Partnership conduit 只有帳號 31 看得到。所以「我選單比同事少幾項」通常是 scope 或權限差異,不是 bug。

③ 左側選單逐項(由上到下)

🏠Home /

登入後的第一個畫面。儀表板顯示 Ava journey 報表與 contacts 概覽(HomeDashboard),進頁打 /ava_journey_reports/api/contacts。若在 Org 彙總 scope 下進入,會讀 ?organization_id= 顯示整個 Org 的彙總。

📒Contacts 群組

聯絡人系列。主列表是 Contacts-27;其餘是依維度拆分的 thin-clone、對外 API 文件、CSV 匯入,以及保留的舊版列表。子項目順序如下。

Contacts-27 新版
/contacts-27
主要聯絡人列表,ag-grid 風格,打 /api/contacts/grid,回應 data.rows / data.lastRow。2026-08 起前端改版,日常操作用這頁。
Marketing Sources
/contacts-marketing-sources
Contacts-27 的 thin-clone,以行銷/歸因欄位的 Saved Views + Segment GROUP BY 呈現。對外 production 隱藏(WIP)。A Contacts-27 thin-clone surfacing marketing/attribution fields via Saved Views + Segment GROUP BY. Hidden on external production (WIP).
Contacts (All Orgs) Organizations
/contacts-org
跨帳號的聯絡人彙總,只在 Organizations 旗標開啟且 Org/All-Accounts scope 下出現;單一 Account 下方隱藏。Org scope 下會被釘在群組最上,並可能改名為 Contacts (All Account)。Cross-account contacts roll-up; appears only with the Organizations flag and at org / All-Accounts scope, hidden under a single account. Pinned to the top of the group at org scope, may be relabeled Contacts (All Account).
Endpoint Attributes
/contacts-endpoint-attributes
依 endpoint 屬性(Carrier / Line Type / Email Provider 等)拆分的 thin-clone。真實欄位仍 TBD,目前先鏡射 Contacts-27。cl1 尚未跟上新版。Thin-clone splitting by endpoint attributes (Carrier / Line Type / Email Provider …). Real columns still TBD; mirrors Contacts-27 for now. cl1 hasn't caught up.
Technographics
/contacts-technographics
依裝置/瀏覽器/OS 屬性拆分的 thin-clone,同樣鏡射 Contacts-27。cl1 尚未跟上。Thin-clone splitting by device/browser/OS attributes; also mirrors Contacts-27. cl1 hasn't caught up.
Import Contact 新分頁
/contacts/import
CSV 匯入聯絡人,以新分頁開啟。欄位:phone, first_name, last_name, email, external_lead_id, traffic_source。template 類型帳號會隱藏此入口。CSV contact import, opens in a new tab. Fields: phone, first_name, last_name, email, external_lead_id, traffic_source. Hidden on template-type accounts.
API 文件 新分頁
/doc/contacts-v2
Add Contact V2 的對外 API 參考頁(MDX 手維護),給客戶看的 API 契約,欄位必須與 backend 一致。Public API reference for Add Contact V2 (hand-maintained MDX) — the customer-facing API contract; fields must match the backend.
Contacts (old) 舊版
/contacts
舊版列表,size=20 分頁,回應 data.result.contacts / meta。保留但建議改用 Contacts-27。Legacy list, size=20 pagination, returns data.result.contacts / meta. Retained; prefer Contacts-27.
Contacts Grid (old) 舊版
/contacts-grid
舊版 ag-grid(SSRM),同樣打 /api/contacts/gridLegacy ag-grid (SSRM), also calls /api/contacts/grid.
Contacts-26 (old) 舊版
/contacts-2026
舊版,打 size=500,結構與 Contacts-27 相同。對外 production 隱藏(WIP)。Legacy, calls size=500, same structure as Contacts-27. Hidden on external production (WIP).

💬Messenger /messenger MESSENGER_URL

CL Messenger 的對話歷史入口(獨立頁,Phase 1)。只有部署環境有設 MESSENGER_URL 才會出現;CLO 對外 production 另由 WIP 機制隱藏。未設定 = 功能不存在,整個入口不渲染。Entry to CL Messenger conversation history (standalone page, Phase 1). Appears only when the deployment sets MESSENGER_URL; CLO external production is also WIP-hidden. Unset = the feature doesn't exist and the entry isn't rendered.

Actions 群組

Ava journey 報表(Ava 互動紀錄)系列。主頁打 /ava_journey_reports,回應含 meta.totalsmeta.completeness;注意 Total: Filtered 大範圍會被 ES bucket 截斷。整個群組在 CLO 對外 production 隱藏。The Ava journey report (Ava interaction logs) family. The main page calls /ava_journey_reports; the response carries meta.totals and meta.completeness — note a broad Total: Filtered gets truncated by the ES bucket. The whole group is hidden on CLO external production.

Actions
/actions
主報表頁。在 Org/All-Accounts scope 下,群組會收斂成只剩彙總項;選「All Account」時此項改名 Actions (All Account)。Main report page. At org / All-Accounts scope the group collapses to just the roll-up; selecting "All Account" relabels this entry to Actions (All Account).
Actions (All Orgs) Organizations
/actions-org
跨 Org 的 actions 彙總,只在 Organizations 旗標開啟時出現;Org/All-Accounts scope 下為唯一顯示項。Cross-org actions roll-up; appears only with the Organizations flag, and is the sole item shown at org / All-Accounts scope.
Marketing Sources
/actions-marketing-sources
依行銷/歸因維度拆 actions 指標。Actions metrics grouped by marketing/attribution dimensions.
Assets (coming soon) 開發中
導覽預留槽,目前停用不可點。頻道報表未來會以 Actions 頁的 "By Channel" 檢視呈現,而非獨立項目。A disabled nav placeholder. Channel reporting will surface as a "By Channel" view of the Actions page, not a separate item.
Endpoint Breakdowns
/actions-endpoint-attributes
依 endpoint segment(Carrier / Phone Line Type / Litigator Risk / Email Provider / Email Verification)拆 actions,走共享的 Segment GROUP BY。Actions grouped by endpoint segments (Carrier / Phone Line Type / Litigator Risk / Email Provider / Email Verification) via the shared Segment GROUP BY.
Technographics
/actions-technographics
依裝置屬性拆 actions。Actions grouped by device attributes.
Action Deep Dive
/actions-deep-dive
Actions 報表的全欄位變體(群組最末項)。All-columns variant of the Actions report (last item in the group).

📊Unified Activity /unified-activity MESSENGER_URL

內嵌 CL Messenger 的 Conversations(embed 模式),緊接 Actions 群組之後。同 Messenger 入口的 gating:MESSENGER_URL 未設則不出現;CLO 對外 production 隱藏。對所有登入者可見(不分角色)。Embeds CL Messenger's Conversations, placed right after the Actions group. Same gating as the Messenger entry: hidden when MESSENGER_URL is unset, and WIP-hidden on CLO external production. Visible to all logged-in users regardless of role.

🖥️Admin 群組 system-admin

Admin (All Organizations) 管理殼,只有 system-admin 看得到。後端/API policy 是最終防線(直接打 URL 也會擋)。前三項是跨 Org 彙總,會被提升到 admin 導覽頂端。The Admin (All Organizations) management shell, visible only to system-admins. Backend/API policy is the final enforcement (direct URL hits are blocked too). The first three are cross-org roll-ups promoted to the top of the admin nav.

Dashboard
/admin
Admin (All Organizations) 的儀表板落地頁。The Admin (All Organizations) dashboard landing page.
Contacts by Org
/admin/contacts
system-admin 彙總:Contacts 依 Organization 分組。system-admin roll-up: Contacts grouped by Organization.
Actions by Org
/admin/actions
system-admin 彙總:Actions 依 Organization 分組。有自己的獨立路由(URL 可達、reload-stable)。system-admin roll-up: Actions grouped by Organization. Has its own dedicated route (URL-reachable, reload-stable).
Organizations
/organizations
組織管理。Organization management.
Feature Flags
/feature-flags
功能旗標管理(控制前述 flag 項目的開關)。Feature flag management (controls the flag-gated items above).
Org Maintenance
/organization-maintenance
組織維護作業。Organization maintenance operations.
Users
/users
使用者管理。User management.
User Circles
/user-circles
使用者群組 / 權限圈。User groups / permission circles.

📈Reports 群組

舊版報表。Legacy reports.

Action Report
/reports/action
舊版,打 /ava_journey_reports
Contact Report
/reports/contact
舊版,打 /contact_reports。週視圖以週日起算(對齊 CLM)。
Visitor Report
/reports/visitor
舊版,打 /visitor_reports。週視圖同樣週日起算。

🎯Conversion Tracking 群組 conversion_tracking 僅 Account scope

轉換追蹤。整個群組由 conversion_tracking 旗標 + 具體 Account scope 控制(Org/All-Accounts 下整群隱藏,因為定義是 account-level NOT NULL account_id)。沒帶旗標的環境看不到此群組。Conversions 與 Google Offline Conversions 已接真實後端,Meta 為預留槽。Conversion tracking. The whole group is gated by the conversion_tracking flag AND concrete-account scope (hidden at org/All-Accounts scope, since definitions are account-level with NOT NULL account_id). Envs without the flag see no group. Conversions and Google Offline Conversions read the real backend; Meta is a placeholder.

Conversions
/conversions
轉換追蹤設定。G2 setup card 以 "this account" 為 scope,Google 匯出每帳號一份 Sheet。Conversion tracking settings. The G2 setup card scopes a configuration to "this account"; the Google export produces one Sheet per account.
Google Offline Conversions
/google-offline-conversions
Google 離線轉換整合。
Meta Offline Conversions (coming soon) 開發中
僅導覽預留槽,不可點。A nav slot only, not clickable.

🎛️Configuration 群組 system-admin

策略設定模組,僅 system-admin。決定「對誰做什麼」的核心。Strategy settings, system-admin only. The core of "to whom, what."

Segments
/segments
聯絡人分群規則。計數 API:/api/accounts/{aid}/segments/{sid}/get-segment-contact-count;匯入命中規則的聯絡人會讓 count +1。Contact segmentation rules. Count API: /api/accounts/{aid}/segments/{sid}/get-segment-contact-count; importing a contact that matches a rule makes count +1.
Assets
/assets
訊息/內容素材(「發什麼」)。每個 Asset 隸屬一個 App Integration;選 Ava 整合時帶出 Interaction Type(Message/Call)、Campaign(backend 用 API Key 向 Ava 查)、Template(可插變數)。表單驗證用 Ant v4 語法。Message/content assets (the "what to send"). Each Asset belongs to an App Integration; selecting an Ava integration surfaces Interaction Type (Message/Call), Campaign (backend queries Ava with the API Key), and a Template (with variable substitution). Form validation uses Ant v4 syntax.
RCS Assets rcs
/rcs-assets
RCS 訊息素材。只在 rcs 旗標開啟時出現(插在 Assets 之後),目前仍在 backend 整合/mock 階段。RCS message assets. Appears only with the rcs flag (inserted after Assets); still in backend-integration / mock stage.

⚙️Settings / Admin 群組 system-admin

營運/合規與帳號設定,僅 system-admin(整群 gate 也會連帶隱藏沒有自身 role 的 App Integrations)。Ops/compliance and account settings, system-admin only (the section-level gate also hides App Integrations, which has no per-item role of its own).

App Integrations 關鍵
/app-integrations
接 Ava 的橋樑。以 API Key(非 OAuth)認證,存的就是 Ava account ID。欄位清單透過 backend 中轉查詢,避免 key 暴露前端。The bridge to Ava. Authenticates with an API Key (not OAuth) and stores the Ava account ID. Field lists are proxied through the backend so the key is never exposed to the frontend.
AI Variables
/ai-variables
AI 回覆變數設定,供 Ava Bot 使用。AI reply variable settings, used by the Ava Bot.
Custom Fields
/custom-fields
自訂欄位,透過 API Key 動態從 CLM 取得,非硬編碼。Custom fields, fetched dynamically from CLM via the API Key — not hardcoded.
Holiday Settings
/holiday-settings
假日設定。
TCPA Restrictions
/tcpa-restrictions
電話行銷合規限制。Telemarketing compliance restrictions.
Business Hours
/business-hour-settings
營業時間設定,控制何時可發訊/通話。Business hours settings — controls when messages/calls are allowed.
Accounts
/accounts
帳號管理與切換入口。

🔑API Key /apikeys

管理帳號的對外 API key。key rotation 目前無自動化,需手動更新。Manage the account's public API keys. Key rotation isn't automated yet — update manually.

📋Batch Jobs /batch-jobs

批次任務佇列。

📖Documentation 群組

對外 API 文件與使用者指南。

Contact
/doc/contacts-v2
Add Contact V2 的 API 參考(MDX 手維護)。Add Contact V2 API reference (hand-maintained MDX).
Contact Deletion 內部環境
/doc/contact-deletion
CCPA 聯絡人刪除 API 文件 + 互動測試台。CLO 對外 production 隱藏(QW 刪除專案進行中),GA 後移除隱藏。CCPA contact-deletion API reference + interactive test console. Hidden on CLO external production while the QW deletion program is in flight; remove the hide at GA.
User Guide
/doc/user-guide
使用者指南文件。

👤Profile /profile

個人設定。

🔗Partnership conduit 群組 限帳號 31

Partnership Conduit 整合。整個群組由目前帳號的 partnership_conduit_enabled 旗標 gate(目前僅帳號 31),其他帳號完全看不到。DB 驅動、無自服務 UI,換帳號後下次載入才反映。Partnership Conduit integration. The whole group is gated by the current account's partnership_conduit_enabled flag (account 31 only today); every other account sees nothing. DB-driven, no self-serve UI; reflects on next load after switching accounts.

Sub IDs
/partnership-conduit/sub-ids
Partnership Conduit 主 grid(改標為 Sub IDs)。The main Partnership Conduit grid (relabeled Sub IDs).
Schedule
/partnership-conduit/schedule
排程設定。Schedule settings.
Endpoint Attributes
/partnership-conduit/endpoint-attributes
依 endpoint 屬性拆分(與 Contacts 的同名子項是不同位置)。Split by endpoint attributes (a different place from the same-named Contacts child).
Technographics
/partnership-conduit/technographics
依裝置屬性拆分。Split by device attributes.
Lead filters
/partnership-conduit/lead-filters
Lead 篩選設定。Lead filter settings.
Change history
/partnership-conduit/change-history
變更歷史(與前面項目之間有分隔線)。Change history (preceded by a divider in the menu).
Revenue tracking (coming soon) 開發中
預留槽,不可點。Placeholder, not clickable.
Budget & caps (coming soon) 開發中
預留槽,不可點。
Reports & analytics (coming soon) 開發中
預留槽,不可點。

⏭️To be removed 群組

即將淘汰的舊功能暫留區。Holding area for features slated for removal.

Lite Campaigns NewLiteCampaignFeature admin / sales
/lite-campaign-requests
lite campaign 請求頁,只在 NewLiteCampaignFeature 旗標開啟時出現,且限 system-admin / Sales 角色。Lite campaign requests page; appears only with the NewLiteCampaignFeature flag, restricted to system-admin / Sales roles.
Triggers 即將移除
/triggers
自動化觸發條件,命中後透過 App Integration 呼叫 Ava。即將淘汰。Automation trigger conditions; on a match it calls Ava via App Integration. Slated for removal.
📌

想看每頁的「欄位 / 按鈕 / 後端 API / 陷阱」細節,到下一章 SW Manager 各頁面功能 的卡片清單;Auth 三頁(登入/註冊/忘記密碼)的逐鍵詳解在 Ava Messenger 頁面。Ava Messenger(app 那邊)的左側選單導覽若也需要,再跟我說,我用同樣方式補一篇。

頁面功能

SW Manager 各頁面功能

以下清單整理自 samurai-world-clientsrc/pages 路由與 auto_cl 的頁面 → API 對應表。新版 / 舊版 / 需 admin 標出權限或版本狀態。

Home / 總覽

/
Home 首頁儀表板
登入後的第一個畫面,顯示 Ava journey 報表與 contacts 概覽。HomeDashboard 元件。進頁會打 /ava_journey_reports/api/contacts

Contacts 系列(聯絡人)

/contacts-27
Contacts-27 新版
主要聯絡人列表,ag-grid 風格,打 /api/contacts/grid,回應 data.rows / data.lastRow。2026-08 起前端改版。
/contacts
Contacts (old) 舊版
舊版列表,size=20 分頁,回應 data.result.contacts / meta
/contacts-grid
Contacts Grid (old) 舊版
舊版 ag-grid,同樣打 /api/contacts/grid
/contacts-2026
Contacts-26 (old) 舊版
舊版,打 size=500,結構與 Contacts-27 相同。
/contacts-marketing-sources
Marketing Sources
依行銷來源拆分聯絡人,2026-08 起改打 /api/contacts/grid
/contacts-endpoint-attributes
Endpoint Attributes
依 endpoint 屬性拆分。cl1 尚未跟上新版(見環境落差)。
/contacts-technographics
Technographics
依裝置/技術屬性拆分。cl1 尚未跟上。
/doc/contacts-v2
Contacts API 文件
Add Contact V2 的對外 API 參考頁(MDX 手維護)。打 /account-api-keys。這是給客戶看的 API 契約,欄位必須與 backend 一致。
/contacts/import資料匯入
Import Contact
CSV 匯入聯絡人。欄位:phone, first_name, last_name, email, external_lead_id, traffic_source。stg 的新版 UI 已移到 Contacts 子選單,並以新分頁開啟。

Actions 系列(Ava 互動紀錄)

/actions
Actions
Ava journey 報表主頁,打 /ava_journey_reports,回應含 meta.totalsmeta.completeness。注意 Total: Filtered 大範圍會被 ES bucket 截斷(見 Q&A)。
/actions-marketing-sources
Marketing Sources
依行銷來源拆 actions。
/actions-endpoint-attributes
Endpoint Breakdowns
依 endpoint 屬性拆。
/actions-technographics
Technographics
依裝置屬性拆。
/actions-deep-dive
Action Deep Dive
單一 action 深入檢視。
/actions-org
By Organization
依組織拆分。點組織名會 shallow-push ?organization_id=,頁面須讀 live router.query 而非 SSR 的 stale query(已知 QA-fail 點)。

Reports(舊版報表)

/reports/action
Action Report
舊版,打 /ava_journey_reports
/reports/contact
Contact Report
舊版,打 /contact_reports。週視圖以週日起算(對齊 CLM)。
/reports/visitor
Visitor Report
舊版,打 /visitor_reports。週視圖同樣週日起算。

策略與設定模組

/segments
Segments 分群
聯絡人分群規則,API 取計數:/api/accounts/{aid}/segments/{sid}/get-segment-contact-count。匯入命中規則時 count +1。
/triggers
Triggers 觸發 即將移除
自動化觸發條件,命中後透過 App Integration 呼叫 Ava。
/assets
Assets 素材
訊息/內容素材(「發什麼」)。每個 Asset 隸屬一個 App Integration;選 Ava 整合時帶出 Interaction Type(Message/Call)、Campaign(backend 用 API Key 向 Ava 查)、Template 樣板(可插變數)。表單驗證用 Ant v4 語法,升級套件時要重驗。
/app-integrations
App Integrations 關鍵
接 Ava 的橋樑。以 API Key(非 OAuth)認證,存的就是 Ava account ID。欄位清單透過 backend 中轉查詢,避免 key 暴露前端。
/apikeys
API Keys
管理帳號的對外 API key。key rotation 目前無自動化,需手動更新。
/custom-fields
Custom Fields
自訂欄位,可透過 API Key 動態從 CLM 取得,非硬編碼。
/conversions
Conversions
轉換追蹤設定。
/google-offline-conversions
Google Offline Conversions
Google 離線轉換整合。
/ai-variables
AI Variables
AI 回覆變數設定,供 Ava Bot 使用。

合規 / 營運設定

/sms
SMS
簡訊設定。測試用的 SMS 走 Quo API(2026-08 由 Toky 換掉)。
/rcs-assets
RCS Assets
RCS 訊息素材。
/tcpa-restrictions
TCPA Restrictions
電話行銷合規限制。
/business-hour-settings
Business Hours
營業時間設定,控制何時可發訊/通話。
/holiday-settings
Holidays
假日設定。
/batch-jobs
Batch Jobs
批次任務佇列。

組織 / 帳號 / Admin

/accounts
Accounts
帳號管理與切換。三代 UI 相容(最新 crumb-account-button / 中版 BreadcrumbTrigger / 舊版 Ant Select)。
/organizations
Organizationssystem-admin
組織管理。
/user-circles
User Circlessystem-admin
使用者群組/權限圈。
/profile
Profile
個人設定。
/admin/*
Admin system-admin
admin/contacts、admin/actions 等。需 system-admin 權限,否則 403。一般帳號進不去是正常的。
/auth/signin
Sign in 登入
Email + 密碼登入,POST /api/auth/login 取 access_token。

Ava 登入後導覽

登入 Ava Messenger 後,畫面長這樣Inside Ava Messenger after you log in

Ava Messenger(ava-client)是營運人員看對話、通話、Bot 的地方。這一章先帶整體畫面,再把左側選單逐項介紹。Ava 跟 SW 最大的 UI 差別:帳號選單是階層式 Cascader(Account ▸ Campaign),且左側選單會依「有沒有選 Account / 有沒有進入 Campaign」切換成三種內容。標記:僅 system-admin限特定角色開發中/預留

① 整體畫面:頂部列 + 左側選單 + 主內容

🏠 左上 Logo回 Dashboardback to Dashboard ▸ Account/Campaign Cascader階層式選帳號與 Campaignpick Account then Campaign JK 右上頭像使用者選單 / 登出user menu / sign out

② 頂部列三個區塊細講

🏠 左上 Logo
點擊 → /
左上角 Ava logo(/static/images/logo.png)。點下去回首頁 Dashboard(/)。The Ava logo top-left (/static/images/logo.png). Clicking returns to the Dashboard (/).
▸ Account / Campaign Cascader CascaderComponent
頂部列中段
logo 右邊的階層式選單(Ant Cascader,changeOnSelect)。第一層選 Account,第二層選該帳號下的 Campaign;顯示成 AccountName (ID: n) / CampaignName (ID: m)。下拉頂端有「Search account」搜尋框(只搜帳號、不搜 campaign,避免破壞階層);底部有「Create New Account」(需 ACCOUNT_CREATE 權限,且要先連結 Google)。選了會 dispatch changeActiveAccount / changeActiveCampaignrouter.push('/')。帳號會依 name 前綴(「Group - Account」)分組排序。The hierarchical selector right of the logo (Ant Cascader, changeOnSelect). Pick an Account on the first level, then a Campaign under it; it displays as AccountName (ID: n) / CampaignName (ID: m). The dropdown has a "Search account" box at the top (accounts only, not campaigns, to preserve the hierarchy) and a "Create New Account" button at the bottom (needs ACCOUNT_CREATE permission and a linked Google account). Selecting dispatches changeActiveAccount / changeActiveCampaign and router.push('/'). Accounts are grouped/sorted by the name prefix ("Group - Account").
JK 右上頭像 Dropdown
頂部列最右
右上角大頭貼 + 你的名字 + ▾。點開選單:最上方顯示姓名與 email;若有 ACCOUNT_EXTERNAL_APP_INTEGRATE 權限,會出現 Profile 區塊讓你 Link Google / Facebook(已連結顯示 Linked);接著是 UI Settings(打開側欄設定抽屜)、Help?(連到 Ava Notion 文件)、Signout 登出。Top-right: avatar + your name + ▾. The dropdown shows your name and email at the top; if you have ACCOUNT_EXTERNAL_APP_INTEGRATE permission, a Profile section lets you Link Google / Facebook (shown as Linked once connected); then UI Settings (opens the sidebar settings drawer), Help? (links to the Ava Notion docs), and Signout.
💡

Ava 左側選單是「情境式」的,會依 cascader 的選擇切換:
選了 Account、沒進 Campaign → 帳號層級選單(Dashboard / Campaigns / Bots / Conversations … + Admin 群組)。
進入某 Campaign → Campaign 選單(Dashboard / Conversations / AI / Web Chat / Stats / Settings)。
沒選任何 Account → 只剩 Admin 群組。
另外 system-admin 看得到全部;一般帳號角色(Owner / Analyst / ExternalTrainer / InternalTrainer / AccountAdmin)只看到該角色被允許的項目——例如 Bots、Voice Messages 與整個 Admin 群組都只有 system-admin 看得到。

③ 左側選單逐項(三種情境)

情境 A · 帳號層級選單(選了 Account、沒進 Campaign)

來源:AccountsMenuItems(activeAccountId),尾端接 Admin 群組。路由前綴 /accounts/{aid}/…Source: AccountsMenuItems(activeAccountId), with the Admin group appended. Routes are prefixed /accounts/{aid}/….

🏠Dashboard /

登入後預設落地頁。所有帳號角色可見。若你沒有 CAMPAIGNS_DASHBOARD_LIST 權限又正在某 Campaign 內,會被自動導到該 Campaign 的 Call Performance Stats。The default landing page after login. Visible to all account roles. If you lack CAMPAIGNS_DASHBOARD_LIST permission while inside a Campaign, you're auto-redirected to that Campaign's Call Performance Stats.

📊Campaigns /accounts/{aid}/campaigns Owner/Analyst/Trainer/AccountAdmin

該帳號下的 Campaign 清單與管理入口。從這裡進入某個 Campaign 後,左側選單會切換成「情境 B」的 Campaign 選單。The list and management entry for this account's Campaigns. Entering a Campaign from here switches the left sidebar to the Context-B campaign menu.

🤖Bots /accounts/{aid}/bots 僅 system-admin

Bot 管理頁。roles: [] 代表只有系統管理員看得到(一般帳號角色看不到此項)。Bot management. roles: [] means system-admin only — normal account roles don't see this item.

💬Conversations /accounts/{aid}/conversations

帳號層級的對話總覽(所有 Campaign 的對話)。所有帳號角色可見。Campaign 內另有更窄的 Conversations 檢視(見情境 B)。Account-level conversation overview (across all campaigns). Visible to all account roles. A narrower in-campaign Conversations view exists in Context B.

📞Phone Numbers 群組 Owner/Analyst/Trainer/AccountAdmin

電話號碼管理與健康度。

Area Code Coverage
/accounts/{aid}/phone-numbers/area-code-coverage
依區碼查看號碼覆蓋情形。View number coverage by area code.
Number Health Stats
/accounts/{aid}/phone-numbers/stats
號碼健康度統計。Number health statistics.

📈Stats 群組 Owner/Analyst/Trainer/AccountAdmin

帳號層級的統計報表。Account-level statistics.

Conversion
/accounts/{aid}/stats/conversion
轉換統計。
Campaign Performance
/accounts/{aid}/stats/campaign-performance
Campaign 效能統計。
Voice Message
/accounts/{aid}/stats/voice-message
語音訊息統計。
Carrier
/accounts/{aid}/stats/carrier
依電信商統計。
Line Type
/accounts/{aid}/stats/line-type
依線路類型統計。

📋Leads /accounts/{aid}/leads Owner/Analyst/AccountAdmin

Lead 清單(不含 Trainer 角色)。Lead list (excludes Trainer roles).

📋Webhooks /accounts/{aid}/webhooks Owner/Analyst/AccountAdmin

帳號層級的 Webhook 設定(接收 Ava 事件回寫)。Account-level webhook settings (to receive Ava event callbacks).

🔊Voice Messages 群組 僅 system-admin

語音訊息管理。roles: [] → 僅 system-admin。

Speech Synthesis system-admin
/accounts/{aid}/voice-messages/speech-synthesis
語音合成設定。

⚙️Settings /accounts/{aid}/settings Owner/Analyst/Trainer/AccountAdmin

帳號設定(帳號層級)。5 個 tab:Main / Call / Transfer / API / A2P,各 tab 所需角色不同。注意 Campaign 內另有自己的 Campaign Settings(見情境 B)。Account settings (account level). 5 tabs: Main / Call / Transfer / API / A2P, each gated to different roles. Note there's a separate Campaign Settings inside a campaign (Context B).

Main / Call / Transfer tabs Owner/AccountAdmin
帳號層級的基本資料、通話與轉接預設值。Campaign 若沒單獨設,會繼承這裡的值。Account-level basic info and call/transfer defaults. A Campaign that doesn't override these inherits them.
API tab + Analyst/Trainer
建立 API Token,從 0 開始路線 A的 Phase 1「在帳號設定產生 API Key」用的就是這裡。Create the API Token — used in Track A's Phase 1 step "Generate the API Key in account settings".
A2P tab Owner/AccountAdmin P0(美加簡訊必備)
10DLC(A2P)簡訊合規登記。沒完成,美加號碼發簡訊會被電信商過濾或直接擋掉——這常是「Segment/Action 都設對了,Ava Stats 也顯示有觸發,但客戶收不到簡訊」的真正原因。詳解見下方 A2P 詳解10DLC (A2P) SMS compliance registration. Without it, SMS to US/Canada numbers gets filtered or blocked by carriers — often the real cause behind "Segment/Action are set up right, Ava Stats shows it fired, but the customer never got the text." See A2P detail below.

📵A2P(10DLC 簡訊合規)詳解 Account Settings → A2P P0

A2P(Application-to-Person)是美加電信商要求的簡訊發送方登記制度(業界稱 10DLC)。沒登記或登記未通過,長碼號碼發簡訊會被電信商標記為垃圾/詐騙並過濾,收件人根本收不到——即使 SW 的 Action 確實觸發、Ava 也確實呼叫了 Twilio 送出。這是「訊息明明有發、對方卻收不到」最常見卻最容易被忽略的原因,因為 SW/Ava 兩端的 log 和 Stats 都會顯示「已送出」,問題出在電信商那一層看不到。A2P (Application-to-Person) is a carrier-mandated sender registration scheme for US/Canada SMS (industry name: 10DLC). Without an approved registration, long-code SMS gets flagged as spam/fraud and filtered by carriers before it reaches the recipient — even though SW's Action fired and Ava did call Twilio to send. This is the most common yet most overlooked cause of "it sent but they never got it," because both SW and Ava logs/Stats will show "sent" — the block happens at the carrier layer, invisible to either system.

① Business Profile
A2P Settings → Business Profile 區塊 →「Create Business Profile」。一個 Account 只能有一個 Business Profile(建立鈕在已有一筆時會被禁用)。建立後狀態走 Draft → Pending → In Progress → Approved(或 Rejected);只有 Draft/Rejected 狀態能編輯重送。A2P Settings → Business Profile section → "Create Business Profile". An account can only have one Business Profile (the create button disables once one exists). Status flows Draft → Pending → In Progress → Approved (or Rejected); only Draft/Rejected can be edited and resubmitted.
② Trust Bundle(Company Entity)
Business Profile 建好後,同一張表格的「Trust Bundle Status」欄按「Create Trust Bundle」——公司實體驗證,必須先有 Business Profile(非 Draft)才能開始。Once the Business Profile exists, click "Create Trust Bundle" in that row's Trust Bundle Status column — company entity verification, only startable once the Business Profile is past Draft.
③ Brand
Trust Bundle 通過後,同一列「Brand Status」欄按「Create Brand」——把公司登記成一個發送品牌,必須先有 Trust Bundle(非 Draft)才能開始。Once the Trust Bundle passes, click "Create Brand" in that row's Brand Status column — registers the company as a sending Brand; requires the Trust Bundle to be past Draft.
④ A2P Campaign(10DLC Campaign)
A2P Settings → A2P Campaigns 區塊 →「Create A2P Campaign」,只有 Brand 已 Approved 才能按(按鈕上有 tooltip 說明)。欄位:Friendly Name;Campaign Usage(用途分類,如 2FA、Marketing、Customer Care、Account Notification 等,每個附說明 tooltip);Description(40–4096 字,說明誰發、發給誰、為何發);Message Flow(40–2048 字,說明收件人如何 opt-in 同意收訊息);Has Embedded Links / Has Embedded Phone(訊息是否含連結/電話);Message Sample ×2~5(20–1024 字,樣本訊息須與上面的 Description/Usage 一致)。⚠️ 刪除這個 Campaign 會連動刪除電信商那邊真正的 10DLC 申請,官方建議只在申請被拒或卡住時才刪。A2P Settings → A2P Campaigns section → "Create A2P Campaign", enabled only once the Brand is Approved (a tooltip explains this on the disabled button). Fields: Friendly Name; Campaign Usage (e.g. 2FA, Marketing, Customer Care, Account Notification — each with an explanatory tooltip); Description (40–4096 chars: who's sending, to whom, and why); Message Flow (40–2048 chars: how the recipient opted in); Has Embedded Links / Has Embedded Phone; 2–5 Message Samples (20–1024 chars, must align with the Description/Usage above). ⚠️ Deleting this Campaign also deletes the real 10DLC application at the carrier — only recommended when the application is rejected or stuck.
⚠️

四層依序卡關:Business Profile → Trust Bundle → Brand → A2P Campaign,每一層都要前一層通過(非 Draft)才能開始下一層,任何一層卡在 Pending/In Progress 都會讓後面全部卡住。狀態不是即時的,審核由電信商端進行,可能要數天。練習用 stg 帳號通常不需要真的走完 A2P(測試門號、低流量),但要對客戶或 prod 帳號送真實簡訊,務必提前確認 A2P 全部 Approved,不要等到「訊息送不出去」才回頭查。
另外要留意 Inherit Existed Twilio Account:若這個 Ava Account 是沿用別的帳號的 Twilio(從 0 開始 Phase 1「建立新的 Ava Account」步驟提過的選項),A2P 頁面上方會顯示「Inherit Twilio Account」,代表 A2P 資格跟著被沿用的帳號走,不用也不能在這個帳號重新申請。

各環境新建 Account 時,A2P 要 Inherit 哪個帳號

練習或新建 Account 時,不要自己重新跑一遍 A2P 申請——直接在 Create New Account 的 Inherit Existed Twilio Account 選下面對應環境的既有帳號,沿用它已經 Approved 的 A2P 資格。When creating a new Account for practice or real use, don't re-run the A2P application yourself — in Create New Account, set Inherit Existed Twilio Account to the existing account below for that environment, reusing its already-Approved A2P eligibility.

環境要 Inherit 的帳號
stgAfforHousing - test (ID: 1)
prody_Back Up Bots - Jimmy Test (ID: 75)
cl1x_Jimmy Test (ID: 155)

👤Admin 群組 僅 system-admin

系統管理群組,roles: [] 僅 system-admin。在帳號層級選單尾端自動接上;沒選任何 Account 時則單獨顯示(情境 C)。System administration group, roles: [] → system-admin only. Appended to the account-level menu; shown alone when no Account is selected (Context C).

Contexts system-admin
/contexts
Context 管理。Context management.
Organizations system-admin
/organizations
組織管理。
Accounts system-admin
/accounts
所有帳號管理(系統層級,與帳號層級選單的 Settings 不同)。All-accounts management (system level; different from the account-level Settings).
Users system-admin
/users
使用者管理。
Internal Performance Stats system-admin
/accounts/internal-performance-stats
內部效能統計。
Intent Knowledge Base system-admin
/intent-knowledge-base
Intent 知識庫管理。
Holiday Settings system-admin
/holiday-settings
假日設定(系統層級)。
API Keys system-admin
/api-keys
API Key 管理(系統層級)。
Short Codes system-admin
/short-codes
短碼管理。

情境 B · Campaign 內選單(從 Cascader 選了某 Campaign,或從 Campaigns 頁進入)

來源:CampaignsMenuItems(activeCampaignId)。路由前綴 /campaigns/{cid}/…。子項少於 2 個的群組會被「攤平」成頂層項目(shouldFlattenChildrenWhen)。Source: CampaignsMenuItems(activeCampaignId). Routes prefixed /campaigns/{cid}/…. Groups with fewer than 2 children are flattened into a top-level item (shouldFlattenChildrenWhen).

🏠Dashboard / Owner/Analyst/Trainer/AccountAdmin

Campaign 的 Dashboard 落地頁。The campaign's Dashboard landing page.

💬Conversations 群組

該 Campaign 的對話。所有角色可見。子項只有 1 個以上時保持群組;Tags 限 Owner/AccountAdmin。This campaign's conversations. All roles. Stays a group when it has more than one child; Tags is Owner/AccountAdmin only.

Conversations
/campaigns/{cid}/conversations
Campaign 內的對話列表(比帳號層級更窄)。所有角色可見。In-campaign conversation list (narrower than account level). All roles.
Tags Owner/AccountAdmin
/campaigns/{cid}/conversations/tags
對話標籤管理。

🤖AI 群組 Owner/AccountAdmin

Campaign 的 AI / Intent 設定。The campaign's AI / intent settings.

Intent Actions
/campaigns/{cid}/ai/intents-actions
Intent 觸發的動作設定。
Intent Tree
/campaigns/{cid}/ai/intents-tree
Intent 樹狀結構檢視。
Manage Intents
/campaigns/{cid}/ai/intents
Intent 的 CRUD 管理。

🌐Web Chat 群組 Owner/Analyst/Trainer/AccountAdmin

網頁聊天 widget 設定。Web chat widget settings.

Code Snippet
/campaigns/{cid}/web-chat/code-snippet
嵌入網站的 widget 程式碼片段。The embed snippet for the widget.
Settings
/campaigns/{cid}/web-chat/settings
Web Chat 外觀與行為設定。Web chat appearance and behavior settings.

🔗Custom Posts 群組 Owner/Analyst/Trainer/AccountAdmin

自訂 Webhook / 貼文整合。子項目前只有 List 一項。Custom webhook / post integrations. Currently only a List child.

List
/campaigns/{cid}/webhooks
Custom Posts / Webhook 清單。Custom posts / webhook list.

📈Stats 群組

Campaign 層級的統計報表。Campaign-level statistics.

Call Performance Stats
/campaigns/{cid}/conversations/call-performance-stats
通話效能統計。所有角色可見。沒有 Dashboard 權限的人會被導來這裡。Call performance stats. All roles. Users without Dashboard permission are redirected here.
Conversion Stats Owner/AccountAdmin
/campaigns/{cid}/conversations/conversion-stats
轉換統計。
Voice Message Stats Owner/AccountAdmin
/campaigns/{cid}/ivr/greeting-messages/stats
語音訊息統計。
Intent Response Stats Owner/AccountAdmin
/campaigns/{cid}/ai/intents-responses/stats
Intent 回覆統計。
Link tracking Stats
/campaigns/{cid}/conversations/link-tracking
連結點擊追蹤統計。所有角色可見。
Web Chat Stats Owner/Analyst/Trainer/AccountAdmin
/campaigns/{cid}/web-chat/stats
Web Chat 統計。

⚙️Settings /campaigns/{cid}/settings Owner/AccountAdmin

Campaign 專屬設定(有別於帳號層級的 Account Settings)。頁面是 5 個 tab:Conversation / Call / Transfer / SMS / Bot。下面依新人該設的優先度排列,不是 tab 上的順序。優先度標記:P0 不設動不起來 P1 Call/轉接才需要 P2 調優後補從 0 開始的路線 A第一次跑至少把 P0 設好,Phase 3 才看得到行為。Campaign-specific settings (distinct from account-level Account Settings). The page has 5 tabs: Conversation / Call / Transfer / SMS / Bot. Below they're ordered by priority for a newcomer, not by tab order. Priority markers: P0 must set P1 for calls/transfer P2 refine later. For a first run of Track A, set at least the P0 items so Phase 3 shows behavior.

Bot tab P0
Campaign Settings → Bot
把帳號下的某個 Bot 綁到這個 campaign(預設 Bot 會標註)。沒綁 Bot → Ava 不會自動回話,Conversations 只會看到 SW 發的首則訊息(單向),Phase 3 看不到「Ava 行為執行」的自動應答。沒有任何 Bot 時,頁面會連到 /accounts/{aid}/bots 让你先建。Attach one of the account's Bots to this campaign (the default Bot is marked). No Bot attached → Ava won't auto-reply; Conversations only shows the first message SW sent (one-way), and Phase 3 won't show Ava's auto-answer behavior. With no Bots at all, the page links to /accounts/{aid}/bots to create one first.
Conversation tab P0
Campaign Settings → Conversation
Main Settings:conversation_channel(對話頻道,須與 SW Asset 的 Interaction Type 對應)、redirect_domainfb_page_idPoke Rules(催促未回覆 lead):enable_conversation_poke_mechanismpoke_prefixpoke_response / custom_poke_responseenable_after_x_messages(幾則後 poke)、lead_did_not_reply_after_x_hours(X 小時未回就 poke)、pokes_adhere_to_holidaydo_not_poke_if_*(已排程來電/已通話/前次未回/opt-out 等排除)。Poke 屬後續跟進行為,首則訊息不依賴它。Notion:Conversation Settings
Transfer tab P1
Campaign Settings → Transfer
Call 類 Asset 或 lead 要求轉接時才必備。transfer_mode(Direct Transfer 直轉 / IVR Mode 語音選單 / SVR Mode 串流語音)、target_transfer_phone_number(轉接號碼)、transfer_hours_start/end(轉接時段)、transfer_message、Key Press Actions(None / Transfer / Transition to Campaign / Add to Opt Out List)、Greeting Messages(語音問候)。沒設轉接號碼/時段 → 轉接會失敗。Only needed for Call-type Assets or when a lead asks to be transferred. transfer_mode (Direct Transfer / IVR Mode / SVR Mode), target_transfer_phone_number, transfer_hours_start/end, transfer_message, Key Press Actions (None / Transfer / Transition to Campaign / Add to Opt Out List), Greeting Messages. No number/time window set and transfers fail.
SMS tab P2
Campaign Settings → SMS
Appointment Reminder:appointment_reminder_sms_content(預約提醒簡訊內容)、appointment_IVR_message_recording_file(提醒錄音檔)。Short Code:勾選該 campaign 要用組織裡的哪個短碼。只在預約提醒流程 / 短碼路由場景才用,第一次跑可先不管。Appointment Reminder: appointment_reminder_sms_content, appointment_IVR_message_recording_file. Short Code: toggle which of the organization's short codes this campaign uses. Only for appointment-reminder flows / short-code routing; can be ignored on a first run.
Call tab P2
Campaign Settings → Call
answer_machine_detection_status(答錄機偵測 On/Off)等通話行為設定。屬通話品質調優,第一次跑可後補。answer_machine_detection_status (Answering Machine Detection On/Off) and other call-behavior settings. Call-quality refinement; can be added later.
🔑

層級繼承 gotcha:campaign 級設定覆蓋 account 級;campaign 級留空就套 account 預設(Transfer 的 transfer_mode 原始碼 extra 明寫:「campaign 級沒設就預設套 account 級 call method」)。新人最常見的困惑:改了 account 級卻被 campaign 級覆蓋、或以為 campaign 會自訂結果其實套了 account 預設——設定時分清楚現在改的是哪一層。

情境 C · 未選 Account(只剩 Admin 群組)

來源:AdminMenuItems() 單獨渲染。內容同上面「Admin 群組」的 9 個子項(Contexts / Organizations / Accounts / Users / Internal Performance Stats / Intent Knowledge Base / Holiday Settings / API Keys / Short Codes),全部 僅 system-admin。一般使用者通常不會停在這個情境——登入後會自動帶入帳號層級選單。Source: AdminMenuItems() rendered alone. Same 9 children as the Admin group above (Contexts / Organizations / Accounts / Users / Internal Performance Stats / Intent Knowledge Base / Holiday Settings / API Keys / Short Codes), all system-admin only. Normal users rarely land here — login normally drops them into the account-level menu.

📌

Ava 的 Auth 三頁(登入 / 註冊 / 忘記密碼)的逐鍵詳解在下一章 Ava Messenger 頁面。SW Manager 那邊的登入後導覽在 登入後導覽Per-button detail for Ava's three Auth pages is in the next chapter Ava Messenger pages. The SW Manager post-login tour is at Post-login tour.

頁面功能

Ava Messenger 各頁面功能

Ava Messenger(ava-client)是營運人員看對話、通話、Bot 的地方。SW 負責「對誰做什麼」,Ava 負責「實際講話的過程」。

Auth(登入/註冊/忘記密碼)逐鍵詳解

登入
Login
Ava Messenger 各環境獨立帳密(stg/cl1/prod 各一組),登入後進帳號選擇。
帳號切換
Account Cascader
Ava 用階層式下拉(ant-cascader)選 account_id,可選多個帳號逐一驗證。
Conversations
Conversations 對話頁 核心
看每個帳號的對話。inbound(聯絡人發).lniLtN、outbound(Ava 發).gtrpLg。可篩 All / 含 https:// 的對話,驗證 Ava 發的連結是否有效。
Campaign / Call / IVR / Bot
互動營運
Campaign、通話、IVR 選單、Bot 回覆、電話號碼、Webhooks 設定。這些是 Ava 自己的營運面,SW 透過 App Integration 觸發。
📞

Transfer Call 雙層設定。轉接電話設定分 Account 層(account_transfer_settings)與 Campaign 層(campaign_transfer_settings),Campaign 可覆蓋 Account 預設。查詢端點 GET /api/accounts/{id}/transfer-call-method

從 0 開始 · 路線 A

從 Ava 建帳號到 SW Segment 設定完成

這條路線是一條跨系統的完整流程:先在 Ava Messenger 建立一個新的 Account 並開出 API Key,再到 SW Manager 用那組 Key 接上、匯入名單、把 Segment 設到好。全程以 stg 環境為例,不碰任何程式碼。

🔑

整條流程的「橋」是 Ava Account ID(填進 SW App Integration 的 Account ID 欄位;stg 環境還要記得勾 Sandbox)。Ava 端建帳號時產生,SW 端 App Integration 消費。所以必須先做 Ava、再做 SW,順序不能反。

Phase 1 · Ava 端 — 建立帳號、Bot、Campaign

  1. 取得 Ava 登入帳號(signup 目前是 stub)

    ⚠️ 注意:/auth/signup 頁面目前是 stub——填 Nickname/Email/Password 送出後只會跳「Account created. Please check your inbox!」提示,不會呼叫任何 API、不寄確認信、也不會真的建帳號。所以登入帳號請改由已存在的 system-admin 建立再提供給你。stg 環境大多數 user 拿到的都是 system-admin 權限,可直接用來跑後續流程。這一步建立的是「登入使用者」,還不是業務 Account(業務 Account 在下面「建立新的 Ava Account」步驟建)。

  2. 登入 Ava Messenger

    確認信完成後到 /auth/signin 用 Email + Password 登入,進入 Ava 主畫面。stg / cl1 / prod 是三套獨立的 Ava,帳號不互通。

  3. 建立新的 Ava Account

    從 admin 進入 Account 列表(/accounts)後,點右上角 Create 建立新 Account。必填:Name(帳號名)、Transfer Phone Number(轉接號碼,預設走 Dial Transfer,之後可在 Settings 改 Streaming Transfer)、Organization(所屬組織,下拉選)。

    Ava Create New Account 表單 img/AVA1.png
    Create New Account 表單

    ⚠️ Inherit Existed Twilio Account 欄位請務必依照A2P 詳解裡「各環境要 Inherit 哪個帳號」的對照表填(stg / prod / cl1 各不同)——若這裡沒設定,新 Account 會沒有 A2P 資格,之後無法發送任何 SMS 或撥打電話
    🔒 權限:/accounts 屬於 Admin 群組(roles: [] = 僅 system-admin),Cascader 的「Create New Account」也需要 ACCOUNT_CREATE 權限——所以這一步必須用 system-admin 帳號。stg 環境大多數 user 都是 system-admin,可直接做;若你不是,請找 system-admin 協助建 Account。
    建立完成後刷新頁面,再進入剛建立的 Account 做接下來的設定。💡 小提示:在 Account 列表找剛建立的那筆,可以點 ID 欄排序,最新建立的會排到最上面(或最下面,依排序方向)。

  4. 在帳號設定產生 API Key

    進入剛建的 Account → Settings(/accounts/{accountId}/settings),切到 API tab → 建立 API Token。把產生的 API Token 與這個 Account 的 Account ID 一起記下來——這兩個值待會要貼進 SW。Settings 共有 Main / Call / Transfer / API / A2P 五個 tab,只有 API tab 需要在這一步完成。

  5. 建立 Bot(Campaign 的必要前提)

    ⚠️ 要先建立 Bot,否則無法建立 Campaign。一樣點右上角 Create 建立新 Bot(/accounts/{accountId}/bots/create)。

    Ava Create Bot 表單 img/AVA2.png
    Create Bot 表單

    欄位:Name;TypeFusion KB(另一個選項 DialogFlow 需要 user 先跟 Google 連通帳號,暫時不用管);Welcome Message——這則訊息只有在 Ava → Bots → Chat Simulator 測試時會出現,平常用實體號碼測試不會看到它,屬正常現象,不是沒設定成功;Reply Mode 由上到下是 Fixed(死板)→ Guided → Flexible(靈活);Intent Group 一開始可以先選前面有 - 前綴的四個(用 Transfer 元件從 Available 移到 My Intent Groups),之後有需求再自行新增。

  6. 建立 Campaign

    Bot 建好後,一樣點右上角 Create 建立新 Campaign。精靈只需要填 Name,其他步驟(Default Language、Default Timezone、後續的 IVR/Conversation 設定)都有預設值,一路按 Continue 到底即可——這些之後都能回 Campaign Settings 再調整。

  7. 回 Campaign Settings 綁 Bot + 設定對話頻道(P0)

    要讓 Ava 真的能回話,回到這個 Campaign 的 Settings 至少把 P0 設好:
    Bot tab — 把剛建的 Bot 綁定到這個 Campaign(沒綁,Ava 不會自動回話,只會收到 SW 發的首則訊息)。
    Conversation tab → Conversation Channel — 設定 campaign 走的頻道,需與 SW 端 Asset 的 Interaction Type 對應。
    門號(Phone Numbers 綁號)、轉接(Transfer tab)、營業時段(Business Hours)屬 P1,第一次跑可後補。完整的 5-tab 詳解與優先度排序見 Ava Campaign Settings 詳解

  8. 確認 Account ID 與 Campaign ID 都已記錄

    以上是 Ava 建立新 Account 的完整步驟。收尾前務必確認沒有遺漏:Account ID(Account 列表 Name (ID: nn))和 Campaign ID(Campaign 列表同樣格式)都要存在、記錄下來——接下來 SW 那邊(Phase 2)的 Asset / Integration 都會用到。

Phase 2 · SW 端 — 建 Account、接上 Ava、完成 Segment

  1. 登入 SW Manager 並建立新 Account

    https://staging.sw.onramplab.com/auth/signin,輸入 SW 的 Email + 密碼登入(看到 "home" 字樣即成功)。從 settings/admin 進入 Accounts 列表,點右上角 Create 建立新 Account。

    SW Create Account 表單 img/SW1.png
    Create Account 表單

    表單裡兩個欄位要特別注意:
    ⚠️ Phone Verification 開啟的話,非美國的正式號碼會被阻擋並加入黑名單——如果客戶名單有海外門號,先確認這個開關的影響。
    ⚠️ Blacklist Check Enabled 開啟的話,匯入時會檢查號碼是否在一些已知黑名單裡。
    💡 Redirect Domain 先跟著外面其他 Account 填一樣的值就好,不用自己另外想。

  2. 把新 Account 加入 Organization,再把 Organization 指給你的 User

    ⚠️ 建立完 Account 後,即使刷新頁面,也沒辦法在帳號切換器上馬上看到剛建立的 Account——這不是壞掉,是因為新 Account 還沒被指派給任何人。要讓自己的 User 看得到它,需要兩步:
    ① 進 admin → Organization,把剛建的 Account 加入一個 Organization(attachAccounts,只能選還沒被任何 Organization 綁定的自由帳號)。
    ② 進 admin → Users,編輯你自己的 User,在 Organizations多選欄裡把該 Organization 加進去——User 會 inherit 這個 Organization 底下所有 Account(唯讀顯示在下方確認)。

    Organization 內加入 Account img/SW2.png
    admin → Organization:Add Account
    User 內指派 Organization img/SW3.png
    admin → Users:把 Organization 指給 User
  3. 切換到新 Account,建立 App Integration(接 Ava)

    點左上角 logo 離開 admin 頁面,用帳號切換器切到剛新增的 Account。點 settings/admin 進入 /app-integrations,一樣點右上角 Create 建立新的 App Integration。

    Create App Integration 表單 img/SW4.png
    Create App Integration 表單

    TypeAva。這個表單只有兩個欄位:Account ID——這裡填的其實是 Phase 1 拿到的 Ava Account ID(目前實作把它存進後端叫 api_key 的欄位,是暫時的技術債,不代表要另外填一組 API Key);Sandbox checkbox——在 stg 環境一定要勾選 Sandbox,才能連到 Ava。沒設這一步,後續 Action 呼叫 Ava 不會生效。

  4. 到 Configuration 建立 Asset

    建好 App Integration 後,到左側選單的 Configuration 群組建立 Asset——⚠️ 每個 App Integration 有自己的子項目,要在剛建立的那個 App Integration 名稱底下建 Asset,別選錯了。一樣點右上角 Create

    Create Asset 表單 img/SW5.png
    Create Asset 表單

    先確認 App Integration 名稱是不是選對了那個 Ava 整合,再選 Interaction Type(目前 Ava 只有兩種:Message / Call)、選 Campaign。如果 Interaction Type 選 Message,需要填 Template 作為 Ava 要傳送的訊息內容;選 Call 則不用填。

  5. 到 Configuration 建立 Segment

    一樣在 Configuration 裡,點右上角 Create 建立新 Segment。

    Create Segment 表單 img/SW6.png
    Create Segment 表單

    表單上半部的 Rules(資料篩選)是觸發條件設定——決定哪些聯絡人算命中這個 Segment。下半部從 Reschedule Rule 開始一路到底的欄位(TypeBusiness HoursTCPAHoliday 等)是觸發時間設定——決定命中的聯絡人「什麼時候」被真正觸發。存檔後頁面會直接接著要求你設定 Action

  6. 設定 Action(選 Channel,可行內建立 Asset)

    Action 頁面設定 Channel 與 Asset img/SW7.png
    Action:Channel + Asset 選擇

    Channel 要跟剛剛建立的 Asset 對應:
    · 若 Asset 是 Message → Channel 選 SMS
    · 若 Asset 是 Call → Channel 選 Active Dials
    · Other 是給非 Ava 在用的其他整合類型選的,這條路線用不到。
    💡 如果前面沒有先建好 Asset,也可以在這個畫面直接建立:先選好 Channel 和要建在哪個 App Integration 底下,再點下面的 Create Asset 按鈕,彈出的表單就是完整的 Asset 建立流程。
    ⚠️ 關鍵:在下拉選單裡選好要用的模板(Asset)後,一定要點旁邊的 Add 按鈕——不點 Add,選擇不會生效,Action 就等於沒接上任何 Asset。

  7. 匯入聯絡人(Contacts)

    Contacts 選單 → Import Contact(stg 新版會在新分頁開啟)。貼上 CSV,欄位:phone, first_name, last_name, email, external_lead_id, traffic_source。匯入後,命中 Segment 規則的聯絡人會觸發「已指派給該 Segment 的 Action」,Action 再透過 App Integration 呼叫 Ava 發送(首則訊息 / 外呼)。⚠️ 若 Action 沒建或沒指派給 Segment,匯入只會把聯絡人寫入 SW,不會觸發任何訊息——這是「匯入了卻沒動」最常見的原因。

  8. 查看 Contacts-27 聯絡人資料

    /contacts-27 開啟聯絡人總覽(新版 ag-grid,進頁會打 /api/contacts/grid,回應 data.rows / data.lastRow)。在這裡確認剛匯入的聯絡人是否出現、用欄位排序與篩選查看 phone / first_name / last_name / email 等欄位。2026-08 起前端已改打 grid API,舊的 size=500 列表行為已不適用;若要對照舊版,可看 /contacts(old,size=20)或 /contacts-2026(old,size=500),新人日常請以 Contacts-27 為準。

⚠️

先在 stg 跑完整條,確認對話真的接起來再碰 prod。prod 匯入真實名單會真的發 SMS / 打電話給客戶,且受 TCPA 限制與營業時間(Business Hours)管控,出錯無法回收。Ava Account 一旦建立會開出真實 Twilio 門號費用,練習請用 stg。

流程總覽(整條從頭到尾的一頁式總圖)

Ava 登入帳號(由 system-admin 建立;signup 是 stub)→ Ava signin
   │
   ▼
Ava /accounts → Create New Account(Name + Transfer Phone + Organization)〔需 system-admin〕
   │  產生 Ava Account ID
   ▼
Ava Account → Settings → API tab → 建 API Token
   │  拿到 Ava Account ID + API Key  ←── 整條流程的「橋」
   ▼
Ava Campaign Settings(P0:Bot + Conversation Channel;門號/轉接/營業時段 P1 後補)
   │
   ▼
SW signin → 選 SW Account
   │
   ▼
SW /app-integrations → Type=Ava,Account ID 填 Ava Account ID,stg 勾選 Sandbox
   │
   ▼
SW /assets → 建 Asset(樣板 + 變數 + Ava Campaign = 發什麼)
   │
   ▼
SW /segments → 建 Segment(規則 = 對誰 + Trigger 何時)→「Next - Create Action」
   │
   ▼
SW 建 Action(Channel + App Integration + 選 Asset)→ 指派回 Segment(action_id)
   │
   ▼
SW Import Contacts(命中規則者 count +1 → 觸發【已指派給 Segment 的 Action】→ Ava 發訊息)
   │
   ▼
SW /contacts-27 → 查看聯絡人資料
   │
   ▼  Phase 3 · 回 Ava 確認訊息與行為執行
Ava Cascader 選 Account/Campaign → Conversations 看對話 + 首則訊息 + Bot 回話
   │
   ▼
Ava Stats(Call Performance / Conversion)→ 確認行為有執行 ✓ 完成

Phase 3 · 回 Ava 確認訊息與行為有執行

前面 Phase 2 在 SW 做的事,最終都要回 Ava 這一端驗證真的發生了。這是整條流程的收尾,也是判斷「有沒有接起來」的依據。

  1. 切回 Ava,選剛建的 Account / Campaign

    回到 Ava Messenger,用頂部 Cascader 選 Phase 1 建的 Account,再進入該 Account 下的 Campaign(SW 端 Asset 的 Campaign 下拉選的就是這個)。選了會 router.push('/') 進 Campaign Dashboard,左側選單同時切換成「情境 B · Campaign 內選單」。Back in Ava Messenger, use the top Cascader to pick the Account from Phase 1, then enter a Campaign under it (the same one the SW Asset's Campaign dropdown selected). Selecting does a router.push('/') into the Campaign Dashboard, and the left sidebar switches to the "Context B · in-campaign" menu.

  2. 到 Conversations 看對話是否出現

    左側 Conversations → /campaigns/{cid}/conversations。確認剛匯入的聯絡人有出現一則對話,且SW 觸發的首則訊息(Asset 的 Template 內容)已送達。若前面「回 Campaign Settings 綁 Bot」步驟的 Bot tab 有綁 Bot,會看到 Ava 自動回話——這就是「Ava 行為有執行」最直接的證據。若 Bot 沒綁,只會看到單向的首則訊息(沒有自動應答),此時行為算「訊息送達但未應答」。Left sidebar Conversations → /campaigns/{cid}/conversations. Confirm each imported contact shows a conversation thread and that the first message triggered by SW (the Asset's Template content) was delivered. If you attached a Bot in the earlier "attach the Bot in Campaign Settings" step's Bot tab, you'll see Ava auto-reply — the most direct evidence that "Ava behavior executed." With no Bot attached you'll only see the one-way first message (no auto-reply); in that case the status is "message delivered, not answered."

  3. 到 Stats 確認行為有執行

    左側 Stats 群組:Call Performance Stats(所有角色可見)看發送/通話數;Conversion Stats(Owner/AccountAdmin)看轉換。計數 > 0 代表 Action 確實被觸發並送到 Ava 執行。也可回帳號層 Stats 看 Campaign Performance 當整體對照。Left sidebar Stats group: Call Performance Stats (all roles) for send/call counts; Conversion Stats (Owner/AccountAdmin) for conversions. A count > 0 means the Action was actually triggered and executed on the Ava side. You can also check account-level Stats → Campaign Performance for an overall comparison.

  4. 通過標準(什麼算「接起來了」)

    同時滿足以下即算成功:
    ① Contacts-27 看得到匯入的聯絡人(資料有進 SW);
    ② Ava Conversations 看得到對話 + 首則訊息已送達(訊息有到 Ava);
    ③ Ava Stats 計數 > 0(Action 確實被觸發執行);
    ④ (若有綁 Bot)Conversations 看得到 Ava 自動回話(Bot 行為有執行)。
    Success means all of the following hold:
    ① Contacts-27 shows the imported contacts (data made it into SW);
    ② Ava Conversations shows the thread + the first message delivered (the message reached Ava);
    ③ Ava Stats count > 0 (the Action was actually triggered and executed);
    ④ (if a Bot is attached) Conversations shows Ava auto-replying (Bot behavior executed).

🛠️

沒動?依這個順序排查:
1. Action 有沒有建、有沒有指派給 Segment——最常見原因(匯入了卻沒動多半是這)。
2. App Integration 的 Account ID 是否填對 Ava Account ID、Sandbox 是否有勾(stg 環境必勾)——填錯或沒勾 Sandbox,SW 查不到 Ava Campaign、Action 呼叫 Ava 也會失敗。
3. Asset 的 Campaign 下拉有沒有選到正確的 Ava Campaign
4. Campaign Settings 的 P0 有沒有設——Bot 沒綁就沒有自動回話;Conversation Channel 不對訊息走錯路徑。
5. 門號有沒有綁、營業時段(Business Hours)/ TCPA / Holiday 是否 Follow——Follow 模式下遇到非營業時段會 Queued 到下次可用時段,看起來像「沒發」。
6. Segment Trigger 的 Enabled 有沒有開、Type/Schedule 設對沒
7. 美加號碼:A2P(10DLC)有沒有 Approved——SW/Ava 兩端 log 都顯示「已送出」、Stats 計數也 > 0,但客戶就是收不到簡訊,十之八九是這個:電信商在看不見的那一層把訊息過濾掉了。

從 0 開始 · 路線 B

QA 工程師:從 0 跑出第一套測試

auto_cl 是 ContactLoop 的 E2E 自動化測試專案(Python + Playwright),跑通它就等於把 SW ↔ Ava 整條迴圈驗過一遍。目標:在本機跑出 stg 的綠燈報告。

測試覆蓋哪些事

測試檔驗什麼
test_ip.py最先跑,確認當前 IP 環境
test_sw_nucleus.pySW 登入 → 選帳號 → 匯入聯絡人 → 驗證首則 SMS 送達(Quo)→ 模擬 lead 發 5 句 → 登入 Ava 比對訊息一致
test_sw_page_api_checks.py逐頁導航 SW 各核心頁面,攔截真實 XHR,驗狀態碼與關鍵欄位
test_sw_segments.py匯入前後 segment count 增量驗證
test_ava_link.py最後跑,Ava 對話中 Ava 發的連結有效性驗證

安裝步驟

# 1. 建立虛擬環境並安裝套件
python -m venv venv
source venv/bin/activate          # Windows: venv\Scripts\activate
pip install -r requirements.txt

# 2. 安裝 Playwright 瀏覽器
playwright install chromium

# 3. 複製環境變數範本並填入
cp .env.example .env              # Windows: copy .env.example .env

.env 必填欄位(以 stg 為例)

變數說明必填?
STG_SW_EMAIL / PASSWORDstg 的 SW Manager 帳密
STG_AVA_EMAIL / PASSWORDstg 的 Ava Messenger 帳密
QUO_API_KEYQuo SMS API 金鑰(測 SMS 驗證用)跑 Nucleus 才需要
QUO_phoneNumberId測試 lead 號碼的 Quo 內部 ID跑 Nucleus 才需要
QUO_participants_stgstg 對應的 SW 端號碼(E.164)跑 Nucleus 才需要
SMTP_EMAIL / PASSWORD測試結果通知信(Gmail App Password)要收信才需要
TEAMS_WEBHOOK_URLTeams 通知 webhook要 Teams 通知才需要
R2_*Cloudflare R2(影片/報告上傳)要上傳才需要

跑測試

# Windows 先設編碼
$env:PYTHONUTF8=1

# 全部測試(自動排序:IP → Nucleus → 頁面 API → Segments → AvaLink)
pytest --env stg -v

# 只跑某一支
pytest tests/test_sw_segments.py --env stg -v

# 只跑 Ava 相關 / 排除 SMS
pytest -m Ava --env stg -v
pytest tests/test_sw_nucleus.py --env stg -v -m "not Sms"

# 跑單一方法
pytest tests/test_sw_segments.py::TestSW::test_sw_segments_count2 --env stg -v
📍

Account ID 不在 .env 裡。它是寫在 conftest.pyENV_CONFIG 裡(例如 stg sw_nucleus.account_id=93)。換帳號要改程式碼,不是改 .env。各環境帳號請找主管或既有 auto_cl 維護者確認。

產出物在哪

  • reports/report.html — HTML 測試報告
  • reports/test.log — 完整 log
  • videos/ — 每次執行的單一連續影片(.webm,檔名帶環境與時間戳)
  • reports/ava_link_issues.json — Ava 連結異常(有異常才產生)
  • reports/sw_page_api_issues.json — SW 頁面 API 檢查異常
  • reports/api_metrics.json — API 回應時間統計
  • 測試結束自動寄 Email / Teams 通知(若已設定)

互動

Q&A 助理

下面輸入框可以直接問問題——常見題會先給你題庫速答;同時問題會送進下方的即時 Q&A 板,管理員會在上面回答,其他人也能留言、點讚。再往下是整理好的分類 FAQ。

嗨!我是 ContactLoop 新人助手。可以問我「stg 跟 cl1 差在哪」「.env 要填什麼」「Total Filtered 為什麼不對」之類的問題 👋

即時 Q&A 板

載入中…

完整 FAQ(整理好的速查)

概念
SW Manager 跟 Ava Messenger 到底差在哪?

SW Manager(Samurai World)是「策略中樞」:管 Contact 主檔、匯入、Segment 分群、Trigger 觸發、Asset 素材、App Integration。決定 什麼時候、對誰、做什麼

Ava Messenger是「互動引擎」:實際執行對話、通話、Bot 回覆、IVR。決定 怎麼跟對方講話

SW 透過 App Integration 用 API Key(=Ava Account ID)呼叫 Ava 開對話;Ava 完成後透過 Webhook 把 Journey Log / Opt-out 回寫 SW。兩者合起來才是 ContactLoop。

三個環境(stg / cl1 / prod)有什麼不同?我該用哪個?

stg(staging.sw.onramplab.com):開發整合測試,新人練習、QA 跑測試都在這,低風險可亂搞。

cl1(manager-cl1.contactloop.com):Pre-prod / 客戶預覽,中風險,部分新版頁面可能還沒跟上 stg。

prod(manager.contactloop.com):正式流量、真實客戶,高風險,勿任意匯入或觸發。

新人一律先用 stg。prod 帳號要特別申請,且操作會真的影響客戶。

帳號 / 設定
從 Ava 建帳號到 SW Segment 設定完成的完整流程是什麼?

必須先 Ava 再 SW,因為 SW 需要 Ava 產生的 API Key 當對接鍵。

Phase 1 · Ava 端:/auth/signup 註冊使用者(Nickname/Email/Password → 收信)→ /auth/signin 登入 → /accounts 建 Account(Name + Transfer Phone Number + Organization,會開 Twilio 子帳號)→ 該 Account 的 Settings → API tab 建立 API Token,記下 Account ID + API Token

Phase 2 · SW 端:/auth/signin 登入 → 建/選 SW Account(需先加入 Organization 並指給 User 才看得到)→ /app-integrations 建 Ava 整合(Account ID 填 Ava Account ID,stg 勾 Sandbox)→ Configuration 下建 Asset 訊息樣板(Interaction Type / Template / Campaign,發什麼)→ Configuration 下建 Segment 並驗證計數(對誰 + 何時)→ 建立 Action(Channel + 選 Asset,記得點 Add)指派回 Segment(用哪個管道)→ /contacts/import 匯入名單(命中 Segment 規則且 Action 已指派者才會觸發 Ava)→ /contacts-27 查看聯絡人資料。Segment + Asset + Action(已指派)+ 匯入四者設好,整條流程才算接通。

第一次全程請在 stg 跑;Ava Account 一旦建立會產生真實 Twilio 門號費用,prod 勿任意練習。

怎麼切換 Account?

點左上角的帳號切換器。SW 有三代 UI 相容,測試程式會依序嘗試:最新版是 button.crumb-account-button 按鈕、中版是 button.BreadcrumbTrigger、舊版是 Ant Select 下拉。選好後帳號名後會顯示 (ID: nn)。Ava 則用階層式 cascader 選帳號。

Account ID 在哪設定?為什麼 .env 裡找不到?

Account ID 寫在 auto_cl/conftest.pyENV_CONFIG 裡,不在 .env。例如 stg 的 sw_nucleus.account_id"93"、cl1 是 "38"、prod 是 "361"。換帳號要改程式碼,且每個環境 ID 都不同,不能互通。

.env 必填欄位有哪些?

基本跑頁面測試只需要該環境的 SW / Ava 帳密,例如 stg:STG_SW_EMAILSTG_SW_PASSWORDSTG_AVA_EMAILSTG_AVA_PASSWORD

跑 Nucleus(SMS 整合流程)還需要 QUO_API_KEYQUO_phoneNumberIdQUO_participants_stg。要收信通知需 SMTP_EMAIL/PASSWORD;要 Teams 通知需 TEAMS_WEBHOOK_URL;要上傳 R2 需 R2_*。範本見 .env.example

Admin 頁面進不去、一直 403?

正常。/admin/*(如 admin/contacts、admin/actions)與 Configuration / Settings 類頁面需要 system-admin 權限,一般帳號會被擋 403。測試 test_sw_page_api_checks.py 因此只覆蓋非 Admin 頁面,避免把 403 誤判成 bug。要測 Admin 頁面得先用具備 system-admin 權限的帳號。

頁面 / 資料
Contacts-27 / Contacts (old) / Contacts Grid (old) 差在哪?

Contacts-27(新版):主要列表,打 /api/contacts/grid,ag-grid 風格,回應 data.rows / data.lastRow。2026-08 前端改版後的標準頁。

Contacts (old):舊版,size=20 分頁,回應 data.result.contacts / meta

Contacts Grid (old):舊版 ag-grid,同樣打 /api/contacts/gridContacts-26 (old) 則打 size=500,結構與 Contacts-27 相同。

新舊並存是為了遷移過渡,新人操作請用 Contacts-27。

Actions 頁面的 "Total: Filtered" 為什麼數字不對?

已知 bug(Trello f1cfO0nU)。時間範圍過大時,產生 grid 的 Elasticsearch terms aggregation 超過 bucket_limit(60000),回應的 meta.completeness.capped=true,導致 Total: Filtered 嚴重低估(3 個月範圍差約 2.4 倍)。

測試 TestActionsTotalCompletenessRegression 會斷言 capped=false,後端修復前預期失敗(xfail),不會讓 CI 變紅;修復後會自動轉 XPASS 提醒可以拿掉 xfail。

CL1 的某些頁面 API 檢查為什麼是 xfail?

這是「環境版本落差」,不是壞掉。stg 通常是最新版,cl1 / prod 的前端部署會晚一點跟上。例如 2026-08 實測:stg 的 Marketing Sources / Endpoint Attributes / Technographics 已改打 /api/contacts/grid,但 cl1 還在打舊版 /api/contacts?…size=500

這類情況登記在 KNOWN_ENV_LAG_XFAILS,標成 xfail 避免每次 CI 跑都被通知洗版;等 cl1 部署跟上會自動轉 XPASS,屆時就可拿掉該設定。

SMS / 測試
SMS 驗證為什麼改用 Quo?Toky 不能用了嗎?

2026-08 起 SMS 從 Toky 換成 Quo。Toky 已停止 SMS 發送服務、只剩接收,所以測試用的 lead 號碼與模擬發送都改用 Quo API。讀取驗證與模擬 lead 發訊都走 api.quo.com/v1/messages,Authorization header 直接帶 API Key(非 Bearer 格式)。號碼用 E.164 格式(+1…)。

怎麼只跑某一個測試?

單支檔:pytest tests/test_sw_segments.py --env stg -v

單一方法:pytest tests/test_sw_segments.py::TestSW::test_sw_segments_count2 --env stg -v

依 marker:pytest -m Ava --env stg -v(只跑 Ava)、pytest -m "not Sms" --env stg -v(排除 SMS)

Windows 記得先 $env:PYTHONUTF8=1 避免編碼問題。

測試影片與報告在哪裡?

報告:reports/report.html;log:reports/test.log;影片:videos/(檔名帶環境與時間戳,單一連續影片含連結頁面訪問);API 統計:reports/api_metrics.json。有異常時額外產生 reports/ava_link_issues.jsonreports/sw_page_api_issues.jsonruns/ 會自動保留最新 10 份歸檔。

Ava 連結驗證失敗代表什麼?

test_ava_link.py 會對每個 account 抽 3–5 則對話,點擊 Ava 發送的連結驗證 HTTP 狀態。chrome-error:// / about: 代表瀏覽器層連不上;HTTP ≥ 400 代表連結頁面異常。測試整體仍會 PASSED(連結異常不中止測試),但會把異常寫進 reports/ava_link_issues.json,Email / Teams 通知會附專屬異常表格,需人工確認。

通知信出現 Gmail 535 錯誤怎麼解?

535 是 SMTP 認證失敗。確認 SMTP_EMAILSMTP_PASSWORD 正確——Gmail 不能用主密碼,必須在 Google 帳號安全設定裡建立 App Password 並用那組密碼。