Skip to main content

Edit Chatbot Knowledge Base

The AI Agent API enables you to edit the knowledge base data of a specified chatbot by sending a POST request to the /chat/Chatbot/EditKnowledge endpoint.

Endpoint

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

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
  • Content-Type: application/json - string, required - The content type of the request payload (must be application/json)

Request Body

The request body should contain the following parameters:

{
// string, required - The unique identifier (ID) of the chatbot
"serialNumber": "3254a9d0424c4806b9ea3d0763ccf1bf",
// string, optional - URL of the sitemap
"SiteMapUrl": "",
// boolean, optional - Whether to enable sitemap synchronization
"EnableSyncSiteMap": false,
// integer, required when EnableSyncSiteMap is true - Sync frequency (Monthly:30, Weekly:7, Daily:1)
"SyncSiteMapDays": 0,
// array of strings, optional - List of file IDs
"fileList": [
"34322",
"34321"
],
// string, optional - Text content to add
"text": "111111111",
// string, optional - URL of the Google Sheet
"googleSheetUrl": "",
// boolean, optional - Whether to retrain using Google Sheet data
"isRetrainGoogleSheet": true,
// array of objects, optional - List of websites to crawl
"websiteList": [
{
"url": "https://www.google.com",
"retrain": false
}
],
// array of objects, optional - List of Q&A pairs
"qaList": [
{
"key": "Question",
"value": "Answer"
}
]
}
  • serialNumber - string, required - The unique identifier (ID) of the chatbot
  • SiteMapUrl - string, optional - URL of the sitemap
  • EnableSyncSiteMap - boolean, optional - Whether to enable sitemap synchronization
  • SyncSiteMapDays - integer, required when EnableSyncSiteMap is true - Sync frequency (Monthly:30, Weekly:7, Daily:1)
  • fileList - array of strings, optional - List of file IDs
  • text - string, optional - Text content to add
  • googleSheetUrl - string, optional - URL of the Google Sheet
  • isRetrainGoogleSheet - boolean, optional - Whether to retrain using Google Sheet data
  • websiteList - array of objects, optional - List of websites to crawl
  • websiteList[].url - string - Website URL
  • websiteList[].retrain - boolean - Whether to retrain using this website
  • qaList - array of objects, optional - List of Q&A pairs
  • qaList[].key - string - Question
  • qaList[].value - string - Answer

Example Request

JavaScript (Fetch API)

const res = await fetch('https://usapi.hottask.com/chat/Chatbot/EditKnowledge', {
method: 'POST',
headers: {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"serialNumber": "3254a9d0424c4806b9ea3d0763ccf1bf",
"fileList": [
"34322",
"34321"
]
})
});

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

Python (Requests Library)

import requests
import json

url = 'https://usapi.hottask.com/chat/Chatbot/EditKnowledge'
headers = {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
}
data = {
"serialNumber": "3254a9d0424c4806b9ea3d0763ccf1bf",
"fileList": [
"34322",
"34321"
]
}

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

cURL

curl 'https://usapi.hottask.com/chat/Chatbot/EditKnowledge' \
-X POST \
-H 'Authorization: <Your-Secret-Key>' \
-H 'Content-Type: application/json' \
-d '{"serialNumber":"3254a9d0424c4806b9ea3d0763ccf1bf","fileList":["34322","34321"]}'

HTTP Request

POST /chat/Chatbot/EditKnowledge HTTP/1.1
Host: usapi.hottask.com
Authorization: <Your-Secret-Key>
Content-Type: application/json

{
"serialNumber": "3254a9d0424c4806b9ea3d0763ccf1bf",
"fileList": [
"34322",
"34321"
]
}

Response

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

{
// boolean - Operation success status
"Data": true,
// 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