Create a Chatbot
The API of app.neoagent.co provides functionality to create a new chatbot by sending a POST request to the endpoint /chat/Chatbot/Add.
Endpoint
Request URL: https://app.neoagent.co/chat/Chatbot/Add
Method: POST
Required Headers
The API request must include the following headers:
Authorization: <Your-Secret-Key>- string, required - The secret key to authenticate the API requestContent-Type: application/json- string, required - The content type of the request payload (must be application/json)
Request Body
The request body must contain the following parameters:
{
// string, required - The time zone of the chatbot (e.g., Asia/Shanghai, America/New_York)
"timeZone": "Asia/Shanghai",
// integer, required - Must be 0 for generic chatbot
"type": 0
}
Parameters
timeZone- string, required - The time zone of the chatbot (e.g., Asia/Shanghai, America/New_York)type- integer, required - Must be 0 for generic chatbot
Request Examples
- JavaScript (Fetch API)
- Python (Requests)
- cURL
- HTTP Raw
const res = await fetch('https://app.neoagent.co/chat/Chatbot/Add', {
method: 'POST',
headers: {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
},
body: JSON.stringify({
"timeZone": "Asia/Shanghai",
"type": 0
})
});
const data = await res.json();
console.log(data);
import requests
import json
url = 'https://app.neoagent.co/chat/Chatbot/Add'
headers = {
"Authorization": "<Your-Secret-Key>",
"Content-Type": "application/json"
}
data = {
"timeZone": "Asia/Shanghai",
"type": 0
}
response = requests.post(url, headers=headers, json=data)
data = response.json()
print(data)
curl 'https://app.neoagent.co/chat/Chatbot/Add' \
-X POST \
-H 'Authorization: <Your-Secret-Key>' \
-H 'Content-Type: application/json' \
-d '{"timeZone":"Asia/Shanghai","type":0}'
POST /chat/Chatbot/Add HTTP/1.1
Host: app.neoagent.co
Authorization: <Your-Secret-Key>
Content-Type: application/json
{
"timeZone": "Asia/Shanghai",
"type": 0
}
Response
The API response will be a JSON object with the following structure:
{
// string - The unique identifier (ID) of the created chatbot
"Data": "3254a9d0424c4806b9ea3d0763xxxxxx",
// string - API version
"Version": "1.0.0",
// boolean - Success status of the operation
"Success": true,
// integer - HTTP status code
"Code": 200,
// string - Error message if present
"Message": ""
}
Error Handling
If the request fails, you should:
- Check the HTTP status code for network-level errors
- Examine the
CodeandMessagefields in the response for business-level errors - The
Messagefield will contain detailed information about the error
Important
Make sure to replace <Your-Secret-Key> with your valid API key.
Next Steps
After creating the chatbot, you can: