Chuyển đến nội dung

Campaign

client.campaign quản lý các chiến dịch marketing và các touchpoints liên quan — các điểm tương tác riêng lẻ (tin nhắn, hành động) tạo nên một chuỗi chiến dịch.


Schema

Campaign

FieldTypeMô tả
_idstringID duy nhất của chiến dịch
namestringTên hiển thị của chiến dịch
statusstring?Trạng thái chiến dịch (vd: draft, active, completed)
channel_typestring?Loại kênh chiến dịch chạy trên
created_atstring?ISO 8601 thời gian tạo
updated_atstring?ISO 8601 thời gian cập nhật

Touchpoint

FieldTypeMô tả
_idstringID duy nhất của touchpoint
namestring?Tên hiển thị của touchpoint
typestring?Loại touchpoint
campaign_idstring?ID chiến dịch cha
created_atstring?ISO 8601 thời gian tạo

CreateCampaignInput

FieldTypeRequiredMô tả
namestringTên chiến dịch
channel_typestringLoại kênh (vd: whatsapp, email)

CreateTouchpointInput

FieldTypeRequiredMô tả
namestringTên touchpoint
typestringLoại touchpoint
campaign_idstringID chiến dịch cha
messagestring | objectPayload tin nhắn

Methods

Campaign

MethodTypeScriptPythonMô tả
List campaignslistlistDanh sách tất cả chiến dịch
Get campaigngetgetLấy chiến dịch theo ID
Create campaigncreatecreateTạo chiến dịch mới
Delete campaigndeletedeleteXóa chiến dịch

Touchpoint

MethodTypeScriptPythonMô tả
List touchpointslistTouchpointslist_touchpointsDanh sách tất cả touchpoints
Get touchpointgetTouchpointget_touchpointLấy touchpoint theo ID
Create touchpointcreateTouchpointcreate_touchpointThêm touchpoint vào chiến dịch
Update touchpointupdateTouchpointupdate_touchpointCập nhật touchpoint
Delete touchpointdeleteTouchpointdelete_touchpointXóa touchpoint
Validate touchpointvalidateTouchpointvalidate_touchpointXác thực cấu hình 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

Kiểm tra xem touchpoint đã được cấu hình đúng chưa trước khi kích hoạt chiến dịch.

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