Messages sending delay#
Beta version
The functionality is in beta. Features may change and may also work unstably.
When sending messages, files, posts and comments, all data are put in the send queue.
All messages are sent from the queue sequentially in the order they come in the FIFO queue.
This sets the message sending delay from the queue.
To change the messages sending delay, use the SetSettings method and the delaySendMessagesMilliseconds parameter.
The interval is counted from the moment the previous message is sent from the queue.
Accordingly, if more time has passed than the interval value, the message will be sent without delay.
- The minimum message sending interval is 500 ms.
- The maximum sending interval is 1 minute (60000 ms).
A value outside these limits is brought to the nearest one: less than 500 - to 500, greater than 60000 - to 60000.
To check the current sending delay, use the GetSettings method, the delaySendMessagesMilliseconds parameter.
Messages sending delay change#
To change the messages sending delay, you have to execute a request at:
{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}
For apiUrl, idInstance and apiTokenInstance request parameters, refer to the Before you start section.
You have to specify the only parameter delaySendMessagesMilliseconds in the request body.
Request body example to set a 5-second messages sending delay#
{
"delaySendMessagesMilliseconds": 5000
}
Request examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}"
payload = {
"delaySendMessagesMilliseconds": 5000
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/setSettings/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data '{
"delaySendMessagesMilliseconds": 5000
}'
var restTemplate = new RestTemplate();
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/setSettings/")
.append({{apiTokenInstance}});
var headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
var jsonBody = "{\"delaySendMessagesMilliseconds\": 5000}";
var requestEntity = new HttpEntity<>(jsonBody, headers);
var response = restTemplate.exchange(requestUrl.toString(), HttpMethod.POST, requestEntity, String.class);
System.out.println(response);
var requestUrl = new StringBuilder();
requestUrl
.append({{apiUrl}})
.append("/waInstance").append({{idInstance}})
.append("/setSettings/")
.append({{apiTokenInstance}});
var response = Unirest.post(requestUrl.toString())
.header("Content-Type", "application/json")
.body("{\"delaySendMessagesMilliseconds\": 5000}")
.asString();
System.out.println(response);