Skip to main content

Get Messages History

The API enables you to query chatbot historical messages by sending a POST request to the /chat/Chatbot/ChatContentHistory endpoint.

Endpoint

Request URL: https://usapi.hottask.com/chat/Chatbot/ChatContentHistory

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

Request Body

The request body should contain the following parameters:

{
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35",
"StartTime": "2025-01-01",
"EndTime": "2025-03-07"
}
  • serialNumber - string, required - The unique identifier (ID) of the chatbot
  • startTime - string, optional - Start date for filtering (format: YYYY-MM-DD) - The time zone is UTC.
  • endTime - string, optional - End date for filtering (format: YYYY-MM-DD) - The time zone is UTC.

Example Request

JavaScript (Fetch API)

const res = await fetch('https://usapi.hottask.com/chat/Chatbot/ChatContentHistory', {
method: 'POST',
headers: {
"Authorization": "<Your-Session-Key>"
},
body: JSON.stringify({
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35",
"StartTime": "2025-01-01",
"EndTime": "2025-03-07"
})
});

const data = await res.json();
console.log(data);

Python (Requests Library)

import requests
import json

url = 'https://usapi.hottask.com/chat/Chatbot/ChatContentHistory'
headers = {
"Authorization": "<Your-Session-Key>"
}
data = {
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35",
"StartTime": "2025-01-01",
"EndTime": "2025-03-07"
}

response = requests.post(url, headers=headers, json=data)
data = response.json()
print(data)

cURL

curl 'https://usapi.hottask.com/chat/Chatbot/ChatContentHistory' \
-X POST \
-H 'Authorization: <Your-Session-Key>' \
-d '{"SerialNumber":"36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35","StartTime":"2025-01-01","EndTime":"2025-03-07"}'

HTTP Request

POST /chat/Chatbot/ChatContentHistory HTTP/1.1
Host: usapi.hottask.com
Authorization: <Your-Session-Key>

{
"SerialNumber": "36XXGxiYDigrQgg5xz4n45bcBW7qeYyW35",
"StartTime": "2025-01-01",
"EndTime": "2025-03-07"
}

Response

The API response will be a JSON object with the following structure:

{
// object - Messages within the chatbot time period
"Data": [
{
"SessionID": 31302,
"CreateTime": "2023-11-21T16:22:42.264484Z",
"URI": "xxx",
"Messages": [
{
"Type": "AI",
"Content": "Hi What can I help you with?"
},
{
"Type": "User",
"Content": "make an appointment"
},
{
"Type": "AI",
"Content": "Please select the date and time..."
}
]
}
],
// 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