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
Field Type Mô tả _idstring ID duy nhất của chiến dịch namestring Tê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
Field Type Mô tả _idstring ID 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
Field Type Required Mô tả namestring ✓ Tên chiến dịch channel_typestring Loại kênh (vd: whatsapp, email)
Field Type Required Mô tả namestring Tên touchpoint typestring Loại touchpoint campaign_idstring ID chiến dịch cha messagestring | object Payload tin nhắn
Methods
Campaign
Method TypeScript Python Mô tả List campaigns listlistDanh sách tất cả chiến dịch Get campaign getgetLấy chiến dịch theo ID Create campaign createcreateTạo chiến dịch mới Delete campaign deletedeleteXóa chiến dịch
Touchpoint
Method TypeScript Python Mô tả List touchpoints listTouchpointslist_touchpointsDanh sách tất cả touchpoints Get touchpoint getTouchpointget_touchpointLấy touchpoint theo ID Create touchpoint createTouchpointcreate_touchpointThêm touchpoint vào chiến dịch Update touchpoint updateTouchpointupdate_touchpointCập nhật touchpoint Delete touchpoint deleteTouchpointdelete_touchpointXóa touchpoint Validate touchpoint validateTouchpointvalidate_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 );
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 " ,
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 ( {
campaign_id: " campaign_id " ,
message: { text: " Hi! Welcome to our service. " },
touchpoint = client.campaign. create_touchpoint ( {
" name " : " Welcome 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
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 " ,
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 " ))