Functions (API) in the calculator
API functions are available only on "Business" and "MaviBot AI"plans.
API MaviBot
LEGEND: ! -Required parameters
How to send callback
callback()
You can sent callback only to ANOTHER client.
YOU CAN'T send a callback to YOURSELF!
Description
callback(client_id, callback_message)
Parameters:
! client_id - client identifier
! callback_message - callback message text
Example
A callback is a special system message that the bot recognizes as a command to trigger a specific action. This message is invisible to the user and is only logged within the client's profile for internal processing.
Let's send callback to client with client_id=73704021

Next, we set the response to this callback in the block with the condition.
Code example to copy
callback('73704021', 'callback TEST123')
callback(client_id, 'callback TEST123')How to send callback in Telegram
tg_callback()
Description
tg_callback(platform_id , callback_message,group_id, business_connection_id)
Parameteres:
! platform_id - Telegram client identifier
! callback_message - callback message text
group_id - Telegram bot identifier
tg_business - for working with business clients, the value "1" is passed.
How to add a bot redirect with a tag in response to a callback button?
Description
tg_callback_url_open(callback_query_id, url)
Parameteres: ! callback_query_id - this id allows you to identify the person who pressed the button and show them Alert -notification, ! url - URL- specifying the bot and the parameter (looks like: t.me/your_bot?start=XXXX, instead of your_bot - bot name)
How to send message to the client
message() | platform_message() | whatsapp_message()
To store text with line breaks in a variable, set the value as follows:
text = "First line text" + "\n" + "Second line text" + "\n" +"Third line text"
Description
message(client_id, text, message_id, timeout)
Parameteres: ! client_id - client identifier ! text - message text message_id - the block ID. If you leave the text field empty (") and fill in this parameter, the text from the specified block will be sent to the client.
Note: If you pass the message_id parameter to the message function, the block will still be fully executed, and the client specified in the client_id parameter will be moved to the block you passed in message_id.
timeout - message delay or scheduled send time. You can use the timeout parameter to delay message sending: a) A delay in seconds (up to 3600 seconds). If the value exceeds 3600, the message will be sent in one hour. If the value is negative, the message will be sent immediately. Example: timeout = 50
b) A specific date and time in the format dd.mm.yyyy hh:mm, example: timeout = '03.04.2022 15:00' . If a past date is specified, the message will be sent immediately.
platform_message(platform_id, text, client_type, message_id, timeout,group_id)
Parameters: ! platform_id - client identifier in messenger ! text - message text client_type - messenger type, optional parameter. If it is not specified, the client will be searched in the same messenger from which the bot sends the message. If it is specified, the client will be found among the database of the specified messenger. You can find messenger types here. message_id - block ID. If it is specified, the client will receive the message from the specified block, not the value from the text parameter. timeout - sending time or delay. It is similar to the parameter of the message() function of the same name. group_id - bot identifier
whatsapp_message(phone, text, message_id)
Parameters: ! phone- the customer's phone number where Whatsapp is registered ! text - message text message_id -is the block ID. If the text field is left empty ('') and this parameter is set, the client will receive the message content from the specified block.
Whatsapp bot need to be connected to the project.
Example
A simple example of sending a message by client_id:

Different options for sending a message by client_id:

Example of sending a message via platform_message():

Getting client_id by platform_id value
get_client_id_by_platform_id()
Description
get_client_id_by_platform_id(client_type, platform_id , group)
After executing, the function will return the client_id if a client matching the specified conditions is found; otherwise, it will return None.
! client_type - messenger. For client_type value read this article.
! platform_id - client's ID in the specified messenger.
group - is a required parameter if more than one messenger bot is connected.
If several messengers of the same type are connected in the project, then the search will be based on all connected messengers of this type.
In this case, we recommend passing the group parameter.
Function for get-requests: requests_get(url, answer_type, headers, params, auth, proxy)
Description
! url - is a link where the request is made
answer_type – is optional parameter that defines what should be returned from the server response: ('status' – returns the response status code; 'json' – returns the json body of the response; 'text' – returns the raw text of the response any other value (including the default) returns a response in the format: '{"status": status_code, "data": data}')
headers - is optional parameter for passing request headers,
params - is get request parameters (can also be included directly in the URL),
auth - is optional parameter useful for API authentication. If you don’t want to use any optional parameter but need the next one, pass 0 here.
proxy - is optional parameter; accepts one value: "de", which routes the request through European IP address.
Functions for pos requests
Description
requests_post(url, answer_type, headers, data, json_data, auth, proxy)
! url - is a link where the request is made,
answer_type - is optional parameter that defines what should be returned from the server response: ('status' – returns the response status code; 'json' – returns the json body of the response; 'text' – returns the raw text of the response any other value (including the default) returns a response in the format: '{"status": status_code, "data": data}')
headers - is optional parameter for passing request headers
data - is optional parameter; represents the request body when the API does not work with json.
json_data - is optional parameter; also represents the request body. You should use only one of these parameters at a time.
Please note: certain header configurations may block the request from being sent with a specific type of body.
auth - is optional parameter useful for API authentication. If you don’t want to use any optional parameter but need the next one, pass 0 here
proxy - is optional parameter; accepts one value: "de", which routes the request through European IP address.
Functions for put-requests
Description
requests_put(url, answer_type, headers, data, auth, proxy)
! url - is a link where the request is made
answer_type - is optional parameter that defines what should be returned from the server response: ('status' – returns the response status code; 'json' – returns the json body of the response; 'text' – returns the raw text of the response any other value (including the default) returns a response in the format: '{"status": status_code, "data": data}')
headers - is optional parameter for passing request headers
data - is optional parameter; represents the request body when the API does not work with json.
auth - is optional parameter useful for API authentication. If you don’t want to use any optional parameter but need the next one, pass 0 here
proxy - is optional parameter; accepts one value: "de", which routes the request through European IP address.
Functions for patch-requests
requests_patch(url, answer_type, headers, data, auth, proxy)
Description
! url - is a link where the request is made
answer_type - is optional parameter that defines what should be returned from the server response: ('status' – returns the response status code; 'json' – returns the json body of the response; 'text' – returns the raw text of the response any other value (including the default) returns a response in the format: '{"status": status_code, "data": data}')
headers - is optional parameter for passing request headers
data - is optional parameter; represents the request body when the API does not work with json.
auth - is optional parameter useful for API authentication. If you don’t want to use any optional parameter but need the next one, pass 0 here
proxy - is optional parameter; accepts one value: "de", which routes the request through European IP address.
Functions for delete requests
requests_delete(url, answer_type, headers, data, json_data, auth, proxy)
Description
! url - is a link where the request is made
answer_type - is optional parameter that defines what should be returned from the server response: ('status' – returns the response status code; 'json' – returns the json body of the response; 'text' – returns the raw text of the response any other value (including the default) returns a response in the format: '{"status": status_code, "data": data}')
headers - is optional parameter for passing request headers
data - is optional parameter; represents the request body when the API does not work with json.
json_data - is optional and may also be used as the request body. However, only one option should be used at a time
auth - is optional parameter useful for API authentication. If you don’t want to use any optional parameter but need the next one, pass 0 here
proxy - is optional parameter; accepts one value: "de", which routes the request through European IP address.
Function for getting block name by its ID
Last updated

