Each chatbot includes an integrated General QA AI agent to enhance its functionality.
Prerequisites
Before starting, make sure you have the following:
An API key for accessing the AI Chatbot Hub API.
A development environment or tool for making HTTP requests, such as Curl or a programming language like Python.
Create the Chatbot and General QA AI Agent
API Endpoint
To create a chatbot, use the following API endpoint:
https://app.aichatbothub.com/api/v1/chatbot/create
Request Body
To create your chatbot, send a POST request to the API endpoint with a JSON-formatted request body. Here’s an example:
Copy {
"name": "Your Chatbot's Name",
"rate_limit": [20, 240],
"rate_limit_message": "Too many messages",
"show_citations": false,
"visibility": "private"
}
name
(string, required): Assign a name to your chatbot.
rate_limit
(array, optional): Set message limits for the chatbot, specified as [messages, seconds]
(e.g., [20, 240]
).
First number: amount of messages. Min 1
- Max 100
Second number: amount of seconds. Min 1
- Max 360
rate_limit_message
(string, optional): Custom message to display when the rate limit is exceeded.
show_citations
(boolean, optional): Set to true
to show citations in chatbot responses.
visibility
(string, optional): Set the visibility to “private,” “public,” or “hybrid.”
Example Request
To create a chatbot with AI Chatbot Hub's API, replace <token>
with your actual API key.
Curl Python Javascript
Copy curl --location --request POST 'https://app.aichatbothub.com/api/v1/chatbot/create' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"name": "Your Chatbot Name",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"visibility": "private"
}'
Copy import requests
url = 'https://app.aichatbothub.com/api/v1/chatbot/create'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <token>'
}
data = {
"name": "Your Chatbot Name",
"rate_limit": [
20,
240
],
"rate_limit_message": "Too many messages",
"show_citations": false,
"visibility": "private"
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Request successful!")
print(response.json())
else:
print("Request failed with status code:", response.status_code)
print(response.text)
Copy const axios = require("axios");
const url = "https://app.aichatbothub.com/api/v1/chatbot/create";
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer <token>",
};
const data = {
name: "Your Chatbot Name",
rate_limit: [20, 240],
rate_limit_message: "Too many messages",
show_citations: false,
visibility: "private",
};
axios
.post(url, data, { headers })
.then((response) => {
console.log("Request successful!");
console.log(response.data);
})
.catch((error) => {
console.error("Request failed:", error);
});
Example Response
Copy {
"created_at": "string",
"meta": {
"rate_limit": [20, 240],
"rate_limit_message": "Too many messages",
"show_citations": false,
"visibility": "private"
},
"modified_at": "string",
"name": "string",
"uuid": "string"
}
Congratulations! You've now created your chatbot using the AI Chatbot Hub API. The chatbot’s uuid
will be used in other guides.
Note: After chatbot creation, a default General QA AI agent is automatically generated to manage user queries. You can customize this agent using the guides below.
Configure the General QA AI Agent
Get the List of Agents
To retrieve a list of agents for your chatbot, use the following endpoint:
https://app.aichatbothub.com/api/v1/chatbot/{chatbot_uuid}/agents
Example Response
Response:
Copy [
{
"created_at": "2024-07-26T03:04:13Z",
"data_source_uuids": [],
"description": "Assist users with [Company/Product]-related questions and greetings.",
"enabled": 1,
"meta": {
"model": "gpt-3.5-turbo",
"temperature": 0,
"use_all_sources": true
},
"modified_at": "2024-07-26T03:04:13Z",
"name": "General Q&A",
"prompt": "Roleplay as \"AI Assistant\" and assist users with expert knowledge in [Topic of Expertise].",
"tool_functions": [],
"type": "user-facing",
"uuid": "39d8243a3e854f16bb732b51143318d5"
}
]
After creating a chatbot, a default General QA AI agent will be available, as shown above. You can create additional agents as required.
Update the Agent
Once you have the list of agents, you can update an agent by sending a POST request to:
https://app.aichatbothub.com/api/v1/agent/{uuid}/update
Refer to the Update Agent API documentation and Agent Properties Reference for detailed information on agent configuration.
Example Request
Replace <token>
with your actual API key.
Curl Python Javascript
Copy curl --location --request POST 'https://app.aichatbothub.com/api/v1/agent/{uuid}/update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"name": "Test update agent name",
"description": "Test update agent description",
"prompt": "Test update agent prompt",
"model": "gpt-4o-mini-16k",
"enabled": true,
"variables": [{"description":"Email of the user.","example":"alice@company.com, ben@school.edu, carl@city.org","type":"string","default_value":{"content":"","static":0},"name":"user_email"},{"description":"Full name of the user, in the format of [First name] [Last name]","example":"","type":"string","default_value":{"content":"","static":0},"name":"user_name"}]
}'
Copy import requests
uuid = '<agent-uuid>'
url = f'https://app.aichatbothub.com/api/v1/agent/{uuid}/update'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <token>'
}
data = {
"name": "Test update agent name",
"description": "Test update agent description",
"prompt": "Test update agent prompt",
"model": "gpt-4o-mini-16k",
"enabled": true,
"variables": [{"description":"Email of the user.","example":"alice@company.com, ben@school.edu, carl@city.org","type":"string","default_value":{"content":"","static":0},"name":"user_email"},{"description":"Full name of the user, in the format of [First name] [Last name]","example":"","type":"string","default_value":{"content":"","static":0},"name":"user_name"}]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print("Request successful!")
print(response.json())
else:
print("Request failed with status code:", response.status_code)
print(response.text)
Copy const axios = require('axios');
const uuid = '<agent-uuid>'
const url = `https://app.aichatbothub.com/api/v1/agent/${uuid}/update`;
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <token>'
};
data = {
"name": "Test update agent name",
"description": "Test update agent description",
"prompt": "Test update agent prompt",
"model": "gpt-4o-mini-16k",
"enabled": true,
"variables": [{"description":"Email of the user.","example":"alice@company.com, ben@school.edu, carl@city.org","type":"string","default_value":{"content":"","static":0},"name":"user_email"},{"description":"Full name of the user, in the format of [First name] [Last name]","example":"","type":"string","default_value":{"content":"","static":0},"name":"user_name"}]
}
axios.post(url, data, { headers })
.then(response => {
console.log('Request successful!');
console.log(response.data);
})
.catch(error => {
console.error('Request failed:', error);
});
Example Response
Copy {
"created_at": "2024-07-25T21:19:01Z",
"data_source_uuids": [],
"description": "Test update agent description",
"enabled": true,
"meta": {
"model": "gpt-4o-mini-16k",
"tags": [],
"temperature": 0.0
},
"modified_at": "2024-07-25T21:19:01Z",
"name": "Test update agent name",
"prompt": "Test update agent prompt",
"tool_functions": [],
"type": "user-facing",
"uuid": "43474da7ae3b4b7191ee29c2de798257",
"variables": [
{
"default_value": {
"content": "",
"static": 0
},
"description": "Email of the user.",
"example": "alice@company.com",
"name": "user_email",
"type": "string"
},
{
"default_value": {
"content": "",
"static": 0
},
"description": "Full name of the user, in the format of [First name] [Last name]",
"name": "user_name",
"type": "string"
}
]
}
This completes the process for creating and managing chatbots and agents using the AI Chatbot Hub API.
Last updated 3 months ago