Chuyển đến nội dung

Chiến dịch

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

TrườngKiểuMô 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

TrườngKiểuMô 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

TrườngKiểuBắt buộcMô tả
namestring✓Tên chiến dịch
channel_typestringLoại kênh (vd: whatsapp, email)

CreateTouchpointInput

TrườngKiểuBắt buộcMô tả
namestringTên touchpoint
typestringLoại touchpoint
campaign_idstringID chiến dịch cha
messagestring | objectPayload tin nhắn

Phương thức

Campaign

Phương thứcTypeScriptPythonMô tả
Danh sách chiến dịchlistlistDanh sách tất cả chiến dịch
Lấy chiến dịchgetgetLấy chiến dịch theo ID
Tạo chiến dịchcreatecreateTạo chiến dịch mới
Xóa chiến dịchdeletedeleteXóa chiến dịch

Touchpoint

Phương thứcTypeScriptPythonMô tả
Danh sách touchpointlistTouchpointslist_touchpointsDanh sách tất cả touchpoints
Lấy touchpointgetTouchpointget_touchpointLấy touchpoint theo ID
Tạo touchpointcreateTouchpointcreate_touchpointThêm touchpoint vào chiến dịch
Cập nhật touchpointupdateTouchpointupdate_touchpointCập nhật touchpoint
Xóa touchpointdeleteTouchpointdelete_touchpointXóa touchpoint
Kiểm tra touchpointvalidateTouchpointvalidate_touchpointKiểm tra tính hợp lệ của 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);
}