The requests are carried out with the method POST on URL i.e. https://chatter.mavibot.ai/api/{api_key}/{action}
Where it’s located: api_key is the key to accessing API which is obtained in the project’s settings:
You can get the access key by using the variable #{api_key}. It holds the relevant generated key. Don’t forget to generate one before using it.
When copying the url of the query from this page a space is put in that needs to be deleted when calling
An example of copying the link the wrong way: https://chatter.mavibot.ai/api/callback
The space after .pro is easy to not notice but if it’s left in place the query won’t work
When sending the request with the GET method, don’t use prohibited words. Look into the right formation of GET requests
How to get messages on Webhook URL that is specified in the project’s settings
The project's settings
Every incoming or outcoming message comes with the following json POST requests:
If the request came back with an error it won’t be resent. If the server came back with an error then the notifications will come through despite this.
How to use a universal webhook
These methods now can be launched with both the POST and the GET request.
Previously, the parameters (with which the clients’ methods were launched, i.e. client_id) were very strictly written in our methods and it would implement some restrictions when using them with the third-party services.
Now you can point out in which parameter of the request Mavibot will look for the identifier of the user: for this, a parameter with the prefix value_ is used, like value_user_id and value_group_id.
Also the method for sending the callback callback can be launched by transmitting an email (client_email) and a client’s phone number (client_phone).
Methods callback and whatsapp_callback aren’t tied to the parameter’s names. You can specify which parameter will hold the client’s phone number, email and id.
It’s useful when you’re setting up the webhook’s reception through another site.
To specify which variable holds client_id you need to transfer value_client_id and mention the name of the parameter with this value in it
To specify which variable holds phone you need to transfer value_phone and mention the name of the parameter with this value in it
To specify which variable holds email you need to transfer value_email and mention the name of the parameter with this value in it
To specify which variable holds user_id you need to transfer value_user_id and mention the name of the parameter with this value in it
To specify which variable holds group_id you need to transfer value_group_id and mention the name of the parameter with this value in it
The method can be used for launching the workflow for the client or for approving the action on a third-party service. This message won’t be visible for the client.
Additionally transferred parameters are saved in the variables.
The method for sending the callback can now be turned on by sharing an email (client_email) or the client’s phone number (client_phone)
This method launches the bot in WhatsApp after the client registers through the site or after they leave a request with their phone number
Additionally transferred parameters are saved to the variables
The method can be used for launching the workflow or confirming actions on a third-party site. This message won't be visible to the client.
Additionally transferred parameters are saved to the variables
Path Parameters
Name
Type
Description
api_key
string
access token
Request Body
Name
Type
Description
message
string
the message text
user_id
string
the user's id in Telegram
group_id
string
the bot's name (must end in bot)
How to work with messages
Params for sending messages
attachment_type can take these values: image, video, link, file, audio
When sending attachments the parameter message isn’t mandatory
buttons identifies the buttons that will be attached to the message. The buttons’ format is comparable to the button’s advanced settings. Two variants of the buttons’ transmition are possible: one with the tooltip in messengers without buttons and one without it
This method can be used for sending messages with notifications. The parameter message is mandatory if you’re not sending a file. If you are, then the text isn’t needed
Allows sending a message from the name of the connected bot to the mentioned number whatsapp_bot_id has to be taken from the “Messengers and chats” section. Each connected WhatsApp page gets a unique identification
The method allows message distribution. If the param clients isn’t mentioned, the broadcast will be sent out to all users. It’s necessary to either send a file or a text
Path Parameters
Name
Type
Description
api_key
string
the access key
Request Body
Name
Type
Description
message_id
string
the sending block's number
list
string
the list of recipients' numbers
shift
string
the amount of seconds between messages. 0.2 by default
The method allows assigning a client to an employee. The email parameter is optional. If the email isn’t provided, it will be distributed through the system’s algorithm
The method allows loading clients into the system. When uploading WhatsApp clients you can transfer the number freely with the @s.whatsapp.net at the end or without it.
You can get the group id (group_id) here through /api/<api_key>/connected_channels
(if client_type=13 (telephony) then group_id=””)
You can see the type of messenger the client came from (client_type)
Allows saving variables in the application and in the client. The request of attributing variables by default adds to transaction variables.
If you need to change the variables in the profile you need to add the prefix client.
Ex. for mobile: client.phone
The param clients allows attributing variables in bulk
This method allows to integrate the site and chatbot, i.e. if a person went on the page with the special offer, you can send out instantly a message about the offer in the chat
Path Parameters
Name
Type
Description
api_key
string
access token
Query Parameters
Name
Type
Description
tag
string
customer tag
name
string
the client's name
recipient
string
the dialogue id on the site
Where do you get the recipient? On the site that carries online chat “Mavibot.ai” you need to get the feature SaleBotPro.recipient_id with the help of JS.
The method gives back the client id for executing requests to the API if you know the client’s phone number in WhatsApp.
If there is no such client with this number, you’ll get a 404.
Path Parameters
Name
Type
Description
api_key
string
access token
Query Parameters
Name
Type
Description
phone
string
the phone number
Getting client id with the phone number
GET https://chatter.mavibot.ai/api/<api_key>/find_client_id_by_phone?phone=
The method gives back the client id for executing requests to the API.
The search happens through WhatsApp clients, as well as through variables.
{
'id': the identifier of the message in the system,
'client': {
'id': the identifier of the client in the system,
'recepient': the identifier of the client in the messenger,
'client_type': the messenger’s type,
'name': the client’s name,
'avatar': the client’s avatar,
'created_at': the date when the client was created,
'tag': the subscription key,
'group': the bot to which the client is tied to,
},
'message': the message text,
'attachments': the array of links to files,
'message_id': the id of the block from which the message was sent from,
'project_id': the project’s id,
'is_input': 1 if the message is from a client, 0 if it’s from the bot,
'delivered': 1 if the message is sent successfully, 0 if there was an error,,
'error_message': the message explaining the 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)
# in case of success the function returns each element its id and addition status
# answer example
# {"status":"success","items":[{"platform_id":"[email protected]","group_id":"5kqchxwyvdvFZOsp80q2qw==","client_type":6,"status":"success","id":1469409}]}