行銷活動
client.campaign 管理行銷活動及其相關的接觸點 — 構成活動序列的個別互動點(訊息、動作)。
結構定義
Campaign
| 欄位 | 類型 | 說明 |
|---|---|---|
_id | string | 唯一活動 ID |
name | string | 活動顯示名稱 |
status | string? | 活動狀態(例如 draft、active、completed) |
channel_type | string? | 活動執行所在的頻道類型 |
created_at | string? | ISO 8601 建立時間戳 |
updated_at | string? | ISO 8601 更新時間戳 |
Touchpoint
| 欄位 | 類型 | 說明 |
|---|---|---|
_id | string | 唯一接觸點 ID |
name | string? | 接觸點顯示名稱 |
type | string? | 接觸點類型 |
campaign_id | string? | 父活動 ID |
created_at | string? | ISO 8601 建立時間戳 |
CreateCampaignInput
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
name | string | ✓ | 活動名稱 |
channel_type | string | 頻道類型(例如 whatsapp、email) |
CreateTouchpointInput
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
name | string | 接觸點名稱 | |
type | string | 接觸點類型 | |
campaign_id | string | 父活動 ID | |
message | string | object | 訊息承載 |
方法
行銷活動
| 方法 | TypeScript | Python | 說明 |
|---|---|---|---|
| 列出行銷活動 | list | list | 列出所有活動 |
| 取得行銷活動 | get | get | 依 ID 取得活動 |
| 建立行銷活動 | create | create | 建立新活動 |
| 刪除行銷活動 | delete | delete | 刪除活動 |
接觸點
| 方法 | TypeScript | Python | 說明 |
|---|---|---|---|
| 列出接觸點 | listTouchpoints | list_touchpoints | 列出所有接觸點 |
| 取得接觸點 | getTouchpoint | get_touchpoint | 依 ID 取得接觸點 |
| 建立接觸點 | createTouchpoint | create_touchpoint | 向活動新增接觸點 |
| 更新接觸點 | updateTouchpoint | update_touchpoint | 更新接觸點 |
| 刪除接觸點 | deleteTouchpoint | delete_touchpoint | 移除接觸點 |
| 驗證接觸點 | validateTouchpoint | validate_touchpoint | 驗證接觸點設定 |
list / list
const { data: campaigns } = await client.campaign.list();for (const c of campaigns) { console.log(c._id, c.name, c.status);}result = client.campaign.list()for c in result.get("data", []): print(c["_id"], c["name"], c.get("status"))create / create
const campaign = await client.campaign.create({ name: "Q3 Re-engagement", channel_type: "whatsapp",});console.log(campaign._id);campaign = client.campaign.create({ "name": "Q3 Re-engagement", "channel_type": "whatsapp",})print(campaign["_id"])get / get
const campaign = await client.campaign.get("campaign_id");console.log(campaign._id, campaign.name, campaign.status);campaign = client.campaign.get("campaign_id")print(campaign["_id"], campaign.get("name"), campaign.get("status"))delete / delete
await client.campaign.delete("campaign_id");client.campaign.delete("campaign_id")createTouchpoint / create_touchpoint
const touchpoint = await client.campaign.createTouchpoint({ name: "Welcome Message", type: "message", campaign_id: "campaign_id", message: { text: "Hi! Welcome to our service." },});touchpoint = client.campaign.create_touchpoint({ "name": "Welcome Message", "type": "message", "campaign_id": "campaign_id", "message": {"text": "Hi! Welcome to our service."},})updateTouchpoint / update_touchpoint
const updated = await client.campaign.updateTouchpoint("touchpoint_id", { name: "Updated Welcome Message", message: { text: "Hi! Great to have you here." },});updated = client.campaign.update_touchpoint("touchpoint_id", { "name": "Updated Welcome Message", "message": {"text": "Hi! Great to have you here."},})getTouchpoint / get_touchpoint
const touchpoint = await client.campaign.getTouchpoint("touchpoint_id");console.log(touchpoint._id, touchpoint.name);touchpoint = client.campaign.get_touchpoint("touchpoint_id")print(touchpoint["_id"], touchpoint.get("name"))deleteTouchpoint / delete_touchpoint
await client.campaign.deleteTouchpoint("touchpoint_id");client.campaign.delete_touchpoint("touchpoint_id")validateTouchpoint / validate_touchpoint
在啟動活動前檢查接觸點是否已正確設定。
const result = await client.campaign.validateTouchpoint({ touchpoint_id: "touchpoint_id",});if (!result.valid) { console.error("Validation errors:", result.errors);}result = client.campaign.validate_touchpoint({"touchpoint_id": "touchpoint_id"})if not result.get("valid"): print("Validation errors:", result.get("errors"))