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ường Kiểu 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
Trường Kiểu 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
Trường Kiểu Bắt buộc Mô tả namestring ✓ Tên chiến dịch channel_typestring Loại kênh (vd: whatsapp, email)
Trường Kiểu Bắt buộc Mô tả namestring Tên touchpoint typestring Loại touchpoint campaign_idstring ID chiến dịch cha messagestring | object Payload tin nhắn
Phương thức
Campaign
Phương thức TypeScript Python Mô tả Danh sách chiến dịch listlistDanh sách tất cả chiến dịch Lấy chiến dịch getgetLấy chiến dịch theo ID Tạo chiến dịch createcreateTạo chiến dịch mới Xóa chiến dịch deletedeleteXóa chiến dịch
Touchpoint
Phương thức TypeScript Python Mô tả Danh sách touchpoint listTouchpointslist_touchpointsDanh sách tất cả touchpoints Lấy touchpoint getTouchpointget_touchpointLấy touchpoint theo ID Tạo touchpoint createTouchpointcreate_touchpointThêm touchpoint vào chiến dịch Cập nhật touchpoint updateTouchpointupdate_touchpointCập nhật touchpoint Xóa touchpoint deleteTouchpointdelete_touchpointXóa touchpoint Kiểm tra touchpoint validateTouchpointvalidate_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 );
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 " ))