Training AI Chatbot with Q&A using MyBotChat API
Q&A is a great way to improve your Chatbot when customers ask questions that the bot cannot answer. By adding those frequently asked questions and answers, your chatbot can learn to answer customer questions accurately over time. You can find out what questions the customer ask and the bot cannot answer by looking at the chat log.
Prerequisite
- You need to have an account with MyBot and created a chatbot. If you have not done this step yet, visit this get-started turorial page to start.
- Genrated an API Key
1. Add a new pair of Question and Answer
We are using this endpoint to add a new pair of Q&A: /api/Training/QA/{ChatbotId}
with POST method
curl --location --request POST 'https://mybot.chat/api/Training/QA/--your-chatbotId--' \
--header 'Authorization: Bearer --your-api-key--' \
--header 'Content-Type: application/json' \
--data-raw '{
"question": "what product do you sell?",
"answer": "we are setting Chatbot service as a service (SaaS)"
}'
The response from server should looks like this:
{
"id": 22,
"chatbotId": "772af073-234f-465a-b44c-5a72fddce458",
"question": "what product do you sell?",
"answer": "we are setting Chatbot service as a service (SaaS)",
"contentLenght": 75,
"docId": "",
"isTrained": false,
"createdDate": "2024-11-25T04:58:22.226597Z",
"modifiedDate": "2024-11-25T04:58:22.226615Z"
}
2. List all the Q&A
Getting the list of all your Q&A by using this endpoint: /api/Training/QA/{chatbotId}
with GET method
curl --location --request GET 'https://mybot.chat/api/Training/QA/--your-chatbotId--' \
--header 'Authorization: Bearer --your-api-key--' \
--data-raw ''
Example response:
[
{
"id": 23,
"chatbotId": "772af073-234f-465a-b44c-5a72fddce458",
"question": "what service do you offer?",
"answer": "we are offering cloud service for Chatbot",
"contentLenght": 67,
"docId": "",
"isTrained": false,
"createdDate": "2024-11-25T05:49:31.880164Z",
"modifiedDate": "2024-11-25T05:49:31.880164Z"
},
{
"id": 22,
"chatbotId": "772af073-234f-465a-b44c-5a72fddce458",
"question": "what product do you sell?",
"answer": "we are setting Chatbot service as a service (SaaS)",
"contentLenght": 75,
"docId": "",
"isTrained": false,
"createdDate": "2024-11-25T04:58:22.226597Z",
"modifiedDate": "2024-11-25T04:58:22.226615Z"
}
]
3. Delete a Q&A
To delete a pair of Q&A, you need to have the Id of the Q&A, which should come from the list above.
curl --location --request DELETE 'https://mybot.chat/api/Training/QA/--Your-ChatbotId--/--QA-Id--' \
--header 'Authorization: Bearer --your-api-key--' \
--data-raw ''
4. Update an existing Q&A
To update an existing Q&A, you need to have the Id and use this endpoint: /api/Training/QA/{ChatbotId}/{Id}
where Id is the Q&A Id what you can find from the list.
curl --location --request PUT 'https://mybot.chat/api/Training/QA/--your-chatbotId--/--QA-Id--' \
--header 'Authorization: Bearer --api-key--' \
--header 'Content-Type: application/json' \
--data-raw '{
"question": "what is your product?",
"answer": "Our product is Chatbot as a service"
}'