client.campaign manages marketing campaigns and their associated touchpoints — the individual interaction points (messages, actions) that make up a campaign sequence.
Schema
Campaign
Field Type Description _idstring Unique campaign ID namestring Campaign display name statusstring? Campaign status (e.g. draft, active, completed) channel_typestring? Channel type this campaign runs on created_atstring? ISO 8601 creation timestamp updated_atstring? ISO 8601 last-updated timestamp
Touchpoint
Field Type Description _idstring Unique touchpoint ID namestring? Touchpoint display name typestring? Touchpoint type campaign_idstring? Parent campaign ID created_atstring? ISO 8601 creation timestamp
Field Type Required Description namestring ✓ Campaign name channel_typestring Channel type (e.g. whatsapp, email)
Field Type Required Description namestring Touchpoint name typestring Touchpoint type campaign_idstring Parent campaign ID messagestring | object Message payload
Methods
Campaign
Method TypeScript Python Description List campaigns listlistList all campaigns Get campaign getgetGet a campaign by ID Create campaign createcreateCreate a new campaign Delete campaign deletedeleteDelete a campaign
Touchpoint
Method TypeScript Python Description List touchpoints listTouchpointslist_touchpointsList all touchpoints Get touchpoint getTouchpointget_touchpointGet a touchpoint by ID Create touchpoint createTouchpointcreate_touchpointAdd a touchpoint to a campaign Update touchpoint updateTouchpointupdate_touchpointUpdate a touchpoint Delete touchpoint deleteTouchpointdelete_touchpointRemove a touchpoint Validate touchpoint validateTouchpointvalidate_touchpointValidate touchpoint configuration
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
Check whether a touchpoint is correctly configured before activating the campaign.
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 " ))