# Message AI Agent Q/A

### Add Q/A to AI agent via API

You can interact with this API by sending a `POST` request. This API allows you to train your AI agent with given a Question and Answer.

***

### **API Endpoint**

The following endpoint/URL should be used in order to access this API:

```
https://admin.gpt4business.ai/en/chatbot/api/v1/qa/
```

***

### **Request Headers**

The API must have the following request headers:

```
Content-Type: application/json
Authorization: Token <Your-API-Token>
```

***

### **Request Body**

The API requires the following parameters in the request body:

* **`chatbot_uuid`** (Type: UUID, Required)

  Unique identifier (UUID) of the chatbot. You can find this UUID on the chatbot's detail page.
*
* **`question`** (Type: String, Required)

  Question to train chatbot. Must be under 5000 characters.
*
* **`answer`** (Type: String, Required)

  Answer to the above question for the chatbot. Must be under 5000 characters.

***

### **Request Example**

Here's an example of the request:

PythonJavaScriptCurl/Shell

```
import requests

# Define the API endpoint
url = "https://admin.gpt4business.ai"

# Set the headers for the request
headers = {
    'Authorization': 'Token <YOUR-API-TOKEN>',
    'Content-Type': 'application/json'
}

# Construct the data payload
data = {
    "chatbot_uuid": "12345678-1234-5678-1234-567812345678",
    "question": "Your message/string here.",
    "answer": "Your message/string here.",
}

# Make the API request
response = requests.post(url, headers=headers, json=data)

# Check the response
if response.status_code == 200:
    print("response:", response.json().get('data'))
else:
    error_data = response.json()
    print("Error:", error_data.get('message', '') + error_data.get('error', ''))
```

***

### **Response Example**

Here's an example of the response:

JSON

```
{
    "id": 123,
    "question": "Hi",
    "answer": "Hello,
    How can I assist you?",
    "character_count": 26,
    "is_trained": true,
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gpt4business.ai/getting-started/apis/message-ai-agent-q-a.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
