Working with MaviBot tags

Create / remove label

create_label() | add_label() | remove_label() | remove_label_everywhere() | count_of_clients_with_label() | has_label()

Description

MaviBot tags are displayed in a customer profile as:

Tags in a customer profile

and in the "Lists" section:

create_label(label_name) creates MaviBot tag with specified name

Parameters: ! label_name- tag name, specified in single quotation marks ('').

add_label(label_name, client_id) add MaviBot tag to client

Parameters: ! label_name - tag name, specified in single quotes ('') client_id client ID. If omitted, current client ID is used

remove_label(label_name, client_id) remove tag fom client

Parameters: ! label_name - tag name, specified in single quotes ('') client_id -client ID. If omitted, current client ID is used

has_label(label_name, client_id) - check if client has tag

Parameters: ! label_name - tag name, specified in single quotes ('') client_id - client ID. If omitted, current client ID is used

remove_label_everywhere(label_name) remove tag from all clients

Parameters: ! label_name- tag name, specified in single quotes ('')

count_of_clients_with_label(label_name) get total number of clients with tag

Parameters: ! label_name- tag name, specified in single quotes ('')

Example

So, let’s see how a MaviBot tag is created.

You just need to execute the creation function once in the gray block (a non-state block), for example:

Creating a tag using the calculator function

At the same time, the variable a can be used to analyze the success of the tag creation function:

Next, you can assign a tag to any client by adding the add_label() function in the appropriate block of your funnel:

You can check if a client has a tag using the has_label() function:

The function returns a logical value: True or False.

Other tag-related actions are performed similarly—removing a tag from a specific client or removing a tag entirely from all clients.

You can also count the number of clients with a given tag by using the count_of_clients_with_label() function.

Counting the number of clients by a given tag
Code example for copying

/Create tag/ a=create_label('tag1')

/Assign tag to client/ a=add_label('stage 1')

/Check if client has tag/ a=has_label('этап 1','73704021')

/Count number of clients with given tag/ etap1=count_of_clients_with_label('stage 1') tovar1=count_of_clients_with_label('1')

Creating a tag

Description

create_label(label_name) - creates MaviBot tag with specified name

Parameters:

! label_name- tag name, specified in single quotes ('')

Creating a tag without duplicates

Description

create_label_if_not_exist(name, color) - creates a new tag if one with the same name doesn’t exist yet and returns its identifier; otherwise, returns the identifier of the existing tag

name — tag name

color — tag color (default: 0)

Color table for color parameter:

0 — light grey

1 — yellow

2 — blue

3 — red

4 — pink

5 — beige

6 — purple

7 — light blue

8 — grey

9 - green

Get all client tags

Description

get_all_client_labels(client_id)

Parameters:

client_id - optional; if not provided, tags of the current client will be retrieved.

The function returns a response in JSON format: {"161":"tag1","228":"tag2"}, where: key is the tag ID, and value is the tag name

Example

Get all tags of the current client

Delete client tags by array

Description

remove_multiple_client_labels(labels_array, names) - deletes tags specified in array

labels_array - tags array. OR ID array, OR names array.

If names array is passed, then❗it is mandatory to pass the second parameter (names) set to 1.

names - Set to 1, if array contains tag names instead of IDs. This indicates that array consists of names.

Example

/*Delete tags by ID*/

r = remove_multiple_client_labels('[138,169,166]')

/*Delete tags by tag name*/

r2 = remove_multiple_client_labels('["newTestTag","tag2"]', 1)

The variable stores the result of the function execution: either an error message or a number indicating how many tags were deleted.

Find clients by multiple tags

Description

find_clients_by_multiple_labels(labels_array, names) - finds clients by multiple tags

Parameters:

labels_array - tags array. OR ID array, OR names array.

If names array is passed, then❗it is mandatory to pass the second parameter (names) set to 1.

names - Set to 1, if array contains tag names instead of IDs. This indicates that array consists of names.

Returns an array of client IDs (client_id): [41121, 41192, 41522]

Example

/*Find clients who have all specified tags by ID*/

r = find_clients_by_multiple_labels('[138,169,166]')

/*Find clients who have all specified tags by tag names*/

r2 = find_clients_by_multiple_labels('["newTestTag","tag2"]', 1)

Check array of client tags

Description

has_client_multiple_labels(labels_array, names) - checks array of client tags

Parameters:

labels_array - tags array. OR ID array, OR names array.

If names array is passed, then❗it is mandatory to pass the second parameter (names) set to 1.

names - Set to 1, if array contains tag names instead of IDs. This indicates that array consists of names.

Returns either an error, or True if client has all tags from the array, or False if client doesn’t have all tags.

Example

/*Check if client has all specified tags by ID*/

r = has_client_multiple_labels('[138,169,166]')

/*Check if client has all specified tags by tag names*/

r2 = has_client_multiple_labels('["newTestTag","tag2"]', 1)

Last updated