Some API request functions can be run in the Calculator.
Requests are sent via the POST or GET method to a URL in the following format:
https://chatter.mavibot.ai/api/{api_key}/{action}
Where:
api_key — the API access key generated in the project settings.
To use the token in a URL request, you first need to generate an API key.
Instructions for doing this are provided in the "Generating an API Key" section. ссылка
When copying a URL from this page, a space may appear and must be removed.
Example of an incorrect link:
https://chatter.mavibot.pro /api/callback
If the space after .pro remains, the request won’t work.
Do not use prohibited characters when sending a GET request.
Make sure you understand the correct format for GET requests.
How to generate an API key
The old API key generation feature still works as before but is not available for new projects.
If your project already has API keys generated without the access settings described in this section, those existing API keys will continue to function normally.
If you need to generate new keys, use the updated settings.
To generate an API key, go to the project settings:
Next, go to the "Integrations" section:
You’ll find the “Add API key” button in the "Integrations" section:
After clicking the button, a modal window will open with access settings and API key generation options:
Next, you need to select the access permissions for the API key:
The API function will work according to the access permissions you select.
Please note!
The API function depends on the access permissions you set: if you generate an API key with read-only access to client information and then use it to send a message to a client or modify their variables, the API request will fail.
The required permission for each API request is specified in the API request card:
Next, enter a name for the API key:
Generate the API key by clicking the "Generate" button:
После чего нажмите "Готово" и ключ api добавится в раздел:
You can add as many API keys as needed, assigning different access permissions to each.
Next, you need to set a primary project key. This allows you to use the key in a request URL with the #{api_key} placeholder.
To do this, click the "{+}" button to the right of the desired API key:
A label will then appear next to the key, indicating that it is the primary project key.
You can access the primary project key via api_key: simply generate the required key, set its permissions, and designate it as the primary project key. Then, in the Calculator, use the request URL with the #{api_key} placeholder, which will contain the value of the primary project key.
URL запроса
Any other generated keys with access settings will be considered secondary keys. In the request URL, you can use their value instead of #{api_key}. To do this, copy the value of the secondary key:
and paste it into the request URL in place of #{api_key}:
An API key generated using the old method is set as the primary project key by default and has full permissions.
Note!
If you delete the key set as the primary project key, you will need to manually designate a new key as the primary.
Please note!
If you have API keys generated using the old method, they will continue to work normally. It is not possible to generate new API keys of the old type.
How to receive messages at the Webhook URL specified in the project settings
Project settings
Each incoming or outgoing message will be sent as the following JSON POST request:
If a request returns an error, it will not be retried. Even if the server returns errors, notifications will continue to be sent.
How to create a JSON request
Go to the settings of the block where the data will be recorded in the table.
Add an API Request section.
Select POST-JSON as the request type.
Then proceed to fill in the request fields:
Request URL — the path to the function to be called. In the documentation, this is always shown on the first line next to the request type:
Saved values — a list of response parameters with the variable names where the results should be stored, in the following format:
request_parameter -> your_variable
If the response contains parameters with a complex structure, parse them as follows:
Previously, our methods had fixed parameters (such as client_id and fb_id) for triggering subscriber actions, which imposed certain limitations when integrating with third-party services.
Now you can specify which request parameter SaleBot should use to find the user ID. Use a parameter with the value_ prefix, for example, value_user_id or value_group_id.
Additionally, the callback sending method can now be triggered using the client’s email (client_email) or phone number (client_phone).
The callback, fb_callback, and whatsapp_callback methods are not tied to specific parameter names. You can specify which parameter contains the client’s phone number, email, or ID.
This is useful when setting up webhook reception from a website.
To specify which variable contains the client_id, use the value_client_id parameter and provide the name of the parameter holding this value.
To specify which variable contains the phone number, use value_phone.
To specify which variable contains the email, use value_email.
To specify which variable contains the user_id, use value_user_id.
To specify which variable contains the group_id, use value_group_id.
To specify the variable containing the message itself in the webhook, use value_message (passed in the same way as the other parameters).
Example:
In the address, specify value_client_id = my_client.
This method can be used to trigger a funnel for a client or confirm an action on an external resource. The client will not see this message.
Please note: any parameters you additionally pass will be saved in variable
The callback method can now also be triggered using the client’s email (client_email) or phone number (client_phone).
Access permission when generating a key: "Permission to modify/delete client information".
Path
api key* - access token
Body
client_phone - phone number used to look up the client
client_email - email used to look up the client
client_id - client ID in the builder
message - message text
resume_bot - True (optional parameter). If the bot is paused, this is used to unpause it.
Example: resume_bot = True
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Starting the bot using a WhatsApp number
POST https://chatter.mavibot.ai/api/<api_key>/whatsapp_callback
This method can trigger the WhatsApp bot after a client registers on the website or submits a request with their phone number.
Please note: any parameters you additionally pass will be saved in variable
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
name - client name
message - message text
phone - client phone number
bot_id - bot ID
resume_bot - True (optional parameter). If the bot is paused, use this to resume it. Example: resume_bot = True
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Starting the bot using a Telegram ID
POST https://chatter.mavibot.pro/api/#{api_key}/tg_callback
This method can be used to trigger a funnel for a client or confirm an action on an external website. The client will not see this message.
Please note: any parameters you additionally pass will be saved in variables.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
message - message text
user_id - Telegram user ID
group_id - bot name (ended as bot)
resume_bot - True (optional parameter). If the bot is paused, use this to resume it. Example: resume_bot = True
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Sending callback messages to a list of clients by platform_id
POST https://chatter.mavibot.ai/api/#{api_key}/send_callback_by_platform_id
When clients with a platform_id from the list are found in the project, a callback will be sent with the text from the callback_text field.
Limit: 1 request = maximum 300 sends
Example of request parameters:
{"platform_ids":[407184121, "79609879898", "2rwewefw"], "callback_text": "test_callback"}
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
platform_ids - List of client IDs in the messenger
callback_text - callback text
group_id - bot ID
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Sending a callback message to a client by email
POST https://chatter.mavibot.ai/api/#{api_key}/email_callback
This method can trigger the email bot after a client registers on the website or submits a request with their email. The method will locate the client’s email or create it if not found.
Access permission when generating a key: "Permission to modify or delete client information".
Please note: any parameters you additionally pass will be saved in variable
Path
api key* - access token
Body
name - client name
message - message text
email - email address
email_id_bot - bot email address
resume_bot - True (optional parameter).
If the bot is paused, use this to resume it. Example: resume_bot = True
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
How to work with messages
Message sending parameters
attachment_type — can be: image, video, link, file, or audio.
When sending an attachment, the message parameter is optional.
buttons — defines the buttons to be attached to the message. The button format matches the advanced button settings.
Buttons can be passed in two ways: with a hint for messengers that don’t support buttons, or without it.
Example of the buttons parameter:
Sending a message to a client
POST https://chatter.mavibot.ai/api/#{api_key}/message
This method can be used to send notification messages. The message parameter is required unless you are sending a file. If you are sending a file, the text is optional.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
message_id - block number for sending
message - message text
client_id - client ID in the builder
attachment_type - file display type. Required if attachment_url is provided.
attachment_url - file URL
buttons - buttons
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Sending a message in WhatsApp
POST https://chatter.salebot.pro/api/<api_key>/whatsapp_message
Allows you to send a message on behalf of the connected bot to the specified number. The whatsapp_bot_id must be taken from the "Messengers and chats" section. Each connected WhatsApp account is assigned a unique identifier by the builder.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
message_id - block number for sending
whatsapp_bot_id - WhatsApp bot ID from which the message should be sent
attachment_url - file URL
attachment_type - file display type. Required if attachment_url is provided.
message - message text
phone - recipient phone number
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Bulk message sending
POST https://chatter.mavibot.ai/api/#{api_key}/broadcast
You can use one of the following mutually exclusive options:
list parameter — the broadcast will be sent to the specified list of clients.
clients parameter — the broadcast will be sent to an array of client IDs.
platform_ids and group_id parameters — the broadcast will be sent to an array of platform_ids (messenger IDs) for the specified bot (group_id).
If none of the above parameters are provided, the broadcast will not be sent.
Required parameters: message (and/or attachment_type and attachment_url) or message_id.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
list - list number to which the broadcast should be sent
clients - client IDs in the builder
message - message text
platform_ids - recipient IDs in the messenger. Must be used together with the required group_id parameter
group_id - required only when using platform_ids. Ignored with other options. Specifies the bot for sending to the given platform_ids
attachment_url - file URL
attachment_type - file display type. Required if attachment_url is provided.
buttons - buttons
message_id - block number for sending
shift — number of seconds between messages. The default is 0.2.
time_shift - number. If specified, the message will be sent after the given number of seconds from the current time.
send_time - date and time in the format "%Y-%m-%d %H:%M:%S" (e.g., "2024-10-16 13:15:59"). This sets the date and time for sending the message. If both time_shift and send_time are specified, time_shift will take precedence.
Retrieving message history
GET https://chatter.mavibot.ai/api/#{api_key}/get_history?client_id=
This method allows you to assign a client to an employee. The email parameter is optional. If no email is provided, the system will assign the client according to its algorithm.
Access permission when generating a key: "Permission to modify/delete client information".
Path
api key* - access token
Body
client_id - client ID
email - employee email (optional)
Importing clients into the system
POST https://chatter.mavibot.ai/api/#{api_key}/load_clients
This method allows you to import clients into the system. When uploading WhatsApp clients, you can provide the number in any format, either with the ending @s.whatsapp.net or without it.
The group ID (group_id) can be obtained HERE via /api/<api_key>/connected_channels. (If client_type = 13 (telephony), then group_id is an empty string: ""). ссылка
The messenger type from which the client came (client_type) can be found HERE. ссылка
Retrieves client information from a selected messenger.
Note! This method does not return variables.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
page
tag – Tag specified on the subscription page
group – VK group ID the subscriber is linked to
date_from – Subscribed after this date (timestamp)
date_to – Subscribed before this date (timestamp)
client_type – Messenger ID for which to retrieve the subscriber list. If not specified, all clients will be returned
How to work with variables
Assigning variables
POST https://chatter.mavibot.ai/api/#{api_key}/save_variables
Allows you to save variables in both the lead and the client.
By default, the variable assignment request adds them to deal variables.
To update variables in the client profile, use the client. prefix. For example, for a phone: client.phone.
Access permission when generating a key: "Permission to modify or delete client information".
This method allows you to integrate a website with a chat bot. For example, if a user visits a promotion page, you can immediately send a message in the chat with a personalized offer.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access tiken
Body
tag - tag (client tag)
name - client name
recipient - dialog ID on a website
Where to get the recipient?
You can get it on the website with the Mavibot.ai online chat, use JS to get the property MavibotAi.recipient_id.
Retrieve client_id by WhatsApp number
GET https://chatter.mavibot.ai/api/#{api_key}/whatsapp_client_id?phone=
This method returns the client ID for making API requests if you know the client’s WhatsApp phone number.
If no client exists with that number, the method will return a 404 error.
Access permission when generating a key: "Permission to modify or delete client information".
Path
api key* - access token
Body
phone - phone number
group_id - bot ID
Retrieve client_id by phone number
GET https://chatter.mavibot.ai/api/<api_key>/find_client_id_by_phone?phone=
This method returns the client ID for making API requests.
Access permission when generating the key: "Permission to read client information"
Path
api key* - access token
Body
var - variable name to search by
val - variable value
group_id - group ID
search_in - pass the value 'order' to search in deal variables; searches up to three variables for project clients and returns a list of clients that have all the specified variables.
Retrieve the ID of the most recently created client by variable value
GET https://chatter.mavibot.ai/api/#{api_key}/find_latest_client_id_by_var?var=&val=
This method searches by variables and returns a list of client IDs that meet the query conditions.
By default, the search is performed on client variables (recommended): {"q": {"result": "ok", "var": "home", "var": "60"}} – the client must have all specified variables
Search in deal variables, at least one of the specified variables must be present: {"q": {"result": "ok", "var": "home", "var": "60"}, "search_in": "order", "include_all": False}
Client variable name equals one of the list values: {"q": {"name": {"_in": ["Joe", "Jane", "Donald"]}}}
Client variable name does NOT equal any of the list values: {"q": {"name": {"_not_in": ["Joe", "Jane", "Donald"]}}}
Client variable name does not equal "Joe": {"q": {"name": {"_not": "Joe"}}}
Note: Number comparison works only if all clients have numeric values in the searched variable. If even one client has a string, the request will fail.
Access permission when generating the key: "Permission to read client information"
Parameters
Path
api key* - access token
Body
q – required parameter, contains the query conditions for searching variables
search_in – specifies which entity’s variables to search; if not provided, the search is done on client variables. Can take the value order.
include_all – whether all conditions in q must be met;
False – if at least one condition matches, the entity is selected
How to work with deals
Retrieve the current deal ID
GET https://chatter.mavibot.ai/api/#{api_key}/get_current_order_id
Access permission when generating the key: "Permission to modify/delete CRM information"
Path
api key* - access token
Body
client_id - client ID
order_id - deal ID
variables -A dictionary of variables (the key is the variable name, and the value is what should be saved in that variable)
(format:{"var_name": "var_velue"})
Create a deal
POST https://chatter.mavibot.ai/api/#{api_key}/create_order
Access permission when generating the key: "Permission to modify/delete CRM information"
Path
api key* - access token
Body
client_id - client ID
name - deal name
description - deal description
budget - deal amount
You must specify one of the following parameters in the request: client_id, email, or phone.
If multiple parameters are provided, only one will be used. The priority order is: client_id > phone > email.
If phone or email is provided and no client exists with that phone number or email, a new client will be created.
Move a deal to a stage in MavibotCRM
POST https://chatter.mavibot.ai/api/#{api_key}/set_order_state
?delimiter=1 – the delimiter value that separates keys {key1}1{key2}1{key3}
delimiter_value_client_id={key1}1{key2} – to retrieve the client ID
delimiter_value_phone={key1}1{key2} – to retrieve the client phone number
{key1}, {key2}, … – keys containing the values (can include any characters except the delimiter). You can have an unlimited number of keys:
?delimiter=1&delimiter_value_client_id={key1}1{key2}1{key3}1{key4}1{key5}1{key6}.
Keys are passed without curly braces.
Use the delimiter between keys. For example, if delimiter=2, then {key1}2{key2}2{key3}; if delimiter=5, then {key1}5{key2}5{key3}. Ensure the key does not contain the delimiter character.
{
"id": "message ID in the system",
"client": {
"id": "client ID in the system",
"recepient": "client ID in the messenger",
"client_type": "type of messenger",
"name": "client's name",
"avatar": "client's avatar",
"created_at": "client creation date",
"tag": "subscription key",
"group": "bot the client is linked to"
},
"message": "message text",
"attachments": "array containing file links or dictionaries of file links",
"message_id": "ID of the block from which the message was sent",
"project_id": "project ID",
"is_input": "1 if the message is from the client, 0 if from the bot",
"delivered": "1 if the message was sent successfully, 0 if there was an error",
"error_message": "text of the message delivery error"
}
import requests
import json
token = 'b551e18c8b8e86bea6f14f38de3f5cc3c31ba1edb4d8'
url = f'https://chatter.mavibot.ai/api/{token}/load_clients'
params = [{ "platform_id": 274827917, "group_id": 169166236, "client_type":0},
{"platform_id":"[email protected]", "group_id": "1hwF7lwEjv4SKYIGFhQnBw==", "client_type": 6}]
requests.post(url, json=params)
# if successful, the function will return an ID and an addition status for each item
# response example
# {"status":"success","items":[{"platform_id":"[email protected]","group_id":"5kqchxwyvdvFZOsp80q2qw==","client_type":6,"status":"success","id":1469409}]}
Successful response: {"status":"success"}
Error response: {"status":"order 12345 not found"}
Successful response: {"status":"success","order_id":40654},
where order_id is the ID of the new active deal.
Error response: {"status":"client_not_found"}
Example of a successful response:
{'status': 'success', 'state_id': 123456}
Example of an unsuccessful response:
{'status': 'order not found'}