Ask AI
English EN
Go to Watbot

Tags

Tags mark contacts: "vip", "ordered_bouquet", "awaiting_delivery". Tags make it easy to branch a scenario and to select mailing recipients. See Tags and variables for details.

Added and removed tags are saved once the code has finished without an error. Inside the code, checks already see the changes.

getContactTags

getContactTags()

Returns all of the contact's tags.

No parameters.

Returns an array of strings — the tag names. If there are no tags, the array is empty.

var tags = getContactTags();

if (tags.length === 0) {
    sendMessage('Tell us which flowers you like, and we will put together a bouquet.');
}

hasContactTag

hasContactTag(name)

Checks whether the contact has a tag.

Parameter Type What to pass
name String The tag name. Letter case matters: VIP and vip are different tags

Returns true if the tag is there, and false if not.

if (hasContactTag('vip')) {
    setContactVariable('discount', 15);
}

setContactTag

setContactTag(name)

Adds a tag to the contact. If the tag is already there, nothing changes.

Parameter Type What to pass
name String The tag name

Returns nothing.

setContactTag('ordered_bouquet');

deleteContactTag

deleteContactTag(name)

Removes a tag from the contact. If there is no such tag, nothing changes.

Parameter Type What to pass
name String The tag name

Returns nothing.

if (hasContactTag('awaiting_delivery')) {
    deleteContactTag('awaiting_delivery');
    setContactTag('order_received');
}