跳转到内容

Campaign

client.campaign 管理营销活动及其相关的接触点 — 构成活动序列的各个互动点(消息、操作)。


Schema

Campaign

FieldType说明
_idstring唯一活动 ID
namestring活动显示名称
statusstring?活动状态(例如 draftactivecompleted
channel_typestring?活动运行的渠道类型
created_atstring?ISO 8601 创建时间戳
updated_atstring?ISO 8601 更新时间戳

Touchpoint

FieldType说明
_idstring唯一接触点 ID
namestring?接触点显示名称
typestring?接触点类型
campaign_idstring?父活动 ID
created_atstring?ISO 8601 创建时间戳

CreateCampaignInput

FieldTypeRequired说明
namestring活动名称
channel_typestring渠道类型(例如 whatsappemail

CreateTouchpointInput

FieldTypeRequired说明
namestring接触点名称
typestring接触点类型
campaign_idstring父活动 ID
messagestring | object消息负载

Methods

Campaign

MethodTypeScriptPython说明
List campaignslistlist列出所有活动
Get campaigngetget按 ID 获取活动
Create campaigncreatecreate创建新活动
Delete campaigndeletedelete删除活动

Touchpoint

MethodTypeScriptPython说明
List touchpointslistTouchpointslist_touchpoints列出所有接触点
Get touchpointgetTouchpointget_touchpoint按 ID 获取接触点
Create touchpointcreateTouchpointcreate_touchpoint向活动添加接触点
Update touchpointupdateTouchpointupdate_touchpoint更新接触点
Delete touchpointdeleteTouchpointdelete_touchpoint移除接触点
Validate touchpointvalidateTouchpointvalidate_touchpoint验证接触点配置

list / list

const { data: campaigns } = await client.campaign.list();
for (const c of campaigns) {
console.log(c._id, c.name, c.status);
}

create / create

const campaign = await client.campaign.create({
name: "Q3 Re-engagement",
channel_type: "whatsapp",
});
console.log(campaign._id);

get / get

const campaign = await client.campaign.get("campaign_id");
console.log(campaign._id, campaign.name, campaign.status);

delete / delete

await 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." },
});

updateTouchpoint / update_touchpoint

const updated = await client.campaign.updateTouchpoint("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);

deleteTouchpoint / delete_touchpoint

await client.campaign.deleteTouchpoint("touchpoint_id");

validateTouchpoint / validate_touchpoint

在激活活动前检查接触点是否已正确配置。

const result = await client.campaign.validateTouchpoint({
touchpoint_id: "touchpoint_id",
});
if (!result.valid) {
console.error("Validation errors:", result.errors);
}