Campaign
client.campaign 管理营销活动及其相关的接触点 — 构成活动序列的各个互动点(消息、操作)。
Schema
Campaign
| Field | Type | 说明 |
|---|---|---|
_id | string | 唯一活动 ID |
name | string | 活动显示名称 |
status | string? | 活动状态(例如 draft、active、completed) |
channel_type | string? | 活动运行的渠道类型 |
created_at | string? | ISO 8601 创建时间戳 |
updated_at | string? | ISO 8601 更新时间戳 |
Touchpoint
| Field | Type | 说明 |
|---|---|---|
_id | string | 唯一接触点 ID |
name | string? | 接触点显示名称 |
type | string? | 接触点类型 |
campaign_id | string? | 父活动 ID |
created_at | string? | ISO 8601 创建时间戳 |
CreateCampaignInput
| Field | Type | Required | 说明 |
|---|---|---|---|
name | string | ✓ | 活动名称 |
channel_type | string | 渠道类型(例如 whatsapp、email) |
CreateTouchpointInput
| Field | Type | Required | 说明 |
|---|---|---|---|
name | string | 接触点名称 | |
type | string | 接触点类型 | |
campaign_id | string | 父活动 ID | |
message | string | object | 消息负载 |
Methods
Campaign
| Method | TypeScript | Python | 说明 |
|---|---|---|---|
| List campaigns | list | list | 列出所有活动 |
| Get campaign | get | get | 按 ID 获取活动 |
| Create campaign | create | create | 创建新活动 |
| Delete campaign | delete | delete | 删除活动 |
Touchpoint
| Method | TypeScript | Python | 说明 |
|---|---|---|---|
| List touchpoints | listTouchpoints | list_touchpoints | 列出所有接触点 |
| Get touchpoint | getTouchpoint | get_touchpoint | 按 ID 获取接触点 |
| Create touchpoint | createTouchpoint | create_touchpoint | 向活动添加接触点 |
| Update touchpoint | updateTouchpoint | update_touchpoint | 更新接触点 |
| Delete touchpoint | deleteTouchpoint | delete_touchpoint | 移除接触点 |
| Validate 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"))