Get Chatbot Messages Count
The API enables you to query the count of chatbot history messages by sending a
POST
request to the /chat/Chatbot/GetMessageCountByChatbot
endpoint.
Endpoint
Request URL: https://usapi.hottask.com/chat/Chatbot/GetMessageCountByChatbot
Method: POST
Request Headers
The API request must include the following headers:
Authorization: <Your-Secret-Key>
- string, required - The secret key for authenticating the API request
Example Request
JavaScript (Fetch API)
const res = await fetch('https://usapi.hottask.com/chat/Chatbot/GetMessageCountByChatbot', {
method: 'POST',
headers: {
"Authorization": "<Your-Session-Key>"
},
body: JSON.stringify({
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35"
})
});
const data = await res.json();
console.log(data);
Python (Requests Library)
import requests
import json
url = 'https://usapi.hottask.com/chat/Chatbot/GetMessageCountByChatbot'
headers = {
"Authorization": "<Your-Session-Key>"
}
data = {
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35"
}
response = requests.post(url, headers=headers, json=data)
data = response.json()
print(data)
cURL
curl 'https://usapi.hottask.com/chat/Chatbot/GetMessageCountByChatbot' \
-X POST \
-H 'Authorization: <Your-Session-Key>' \
-d '{"SerialNumber":"36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35"}'
HTTP Request
POST /chat/Chatbot/GetMessageCountByChatbot HTTP/1.1
Host: usapi.hottask.com
Authorization: <Your-Session-Key>
{
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35"
}
Response
The API response will be a JSON object with the following structure:
{
// int - Number of messages for chatbot
"Data": 13,
// string - API version
"Version": "1.0.0",
// boolean - Operation success status
"Success": true,
// integer - HTTP status code
"Code": 200,
// string - Error message if any
"Message": ""
}
Error Handling
If the request fails, you should:
1. Check the HTTP status code for network-level errors
2. Examine the `Code` and `Message` fields in the response for business-level errors
3. The `Message` field will contain detailed error information