> For the complete documentation index, see [llms.txt](https://docs.a4b.vn/xbot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.a4b.vn/xbot/features/ai-bots.md).

# AI bots

## Introduce

In the AI bot framework, there are three distinct types of AI bots designed to handle different aspects of interacting with messages. These AI bots are integrated into the system to manage, analyze, and respond to customer messages effectively. Here is an explanation of each type and their roles:

## Types of AI bots

### **1. AI Pre**

This AI bot is responsible for initially screening incoming messages from customers. It checks for inappropriate content or negative sentiments. If the AI PRE agent detects negative content, it returns `true`, marking the message as `NEGATIVE`. In such cases, the message is flagged and forwarded to a human agent with a warning, and the AI PRE does not respond to these messages. AI pre will immediately respond to the user's answers in the configuration messages. Here's a basic example class in Java to represent this functionality:

```java
public class AiPreAgent {
    public boolean checkMessageContent(String message) {
        // Implement logic to check for negative content
        boolean isNegative = false;
        // Example logic
        if (message.contains("negative keyword")) {
            isNegative = true;
        }
        return isNegative;
    }
}

```

User Interface (UI):

<figure><img src="https://2307922561-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRlPRvo4tFDdBfWtEOBE%2Fuploads%2F1Z6S075cc1RDJikBsH5Q%2Fai_pre_config.png?alt=media&amp;token=43ecaa11-5207-4a6b-80f9-d6d1dc6218fb" alt=""><figcaption></figcaption></figure>

### **2. AI agent**

This AI bot handles responses to customer queries based on the knowledge it has been trained on. It automatically provides answers to customer questions using its AI capabilities. Below is a simple example of how this might be implemented in a Java class:

```java
public class AiAgent {
    public String respondToCustomer(String query) {
        // Logic to generate response based on AI knowledge
        String response = "This is an automated response based on your query.";
        return response;
    }
}

```

User Interface (UI):

<figure><img src="https://2307922561-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRlPRvo4tFDdBfWtEOBE%2Fuploads%2FOO2ppP8wXzSyTbXGfkbE%2FAI_agent.png?alt=media&amp;token=1a8dd3b3-29dc-41d7-a832-96b6d804caff" alt=""><figcaption></figcaption></figure>

### **3. AI Post**

This AI bot is configured to post-process the responses given by the AI AGENT. It logs or monitors the answers to ensure quality or for further analysis. This agent does not interact directly with customers but acts as a backend process to gather data on AI performance. An example Java class might look like this:

```java
public class AiPostAgent {
    public void logResponse(String response) {
        // Logic to log or monitor responses
        System.out.println("Logging response: " + response);
    }
}

```

User Interface (UI):

<figure><img src="https://2307922561-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRlPRvo4tFDdBfWtEOBE%2Fuploads%2F6dwsvbzEePPeyogRNEtr%2FAi_post.png?alt=media&amp;token=8305ff6f-e52b-4f0f-81d5-0000e76de638" alt=""><figcaption></figcaption></figure>

Integration in Conversational Systems

These AI bots are assigned to specific groups within the conversational system. They perform checks, respond, and post-process messages as they arrive in a conversation. This structured approach allows for efficient handling of messages, ensuring that each is processed appropriately according to its content and the system's operational requirements. By leveraging these AI bots, the system can manage conversations dynamically, ensuring appropriate interactions and maintaining the quality of service.

<figure><img src="https://2307922561-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPRlPRvo4tFDdBfWtEOBE%2Fuploads%2Feaw0vc4iJHNqS05U985V%2Fconfig_group.png?alt=media&amp;token=a5d78b29-bfc8-4987-a462-5e29b3ee8f5b" alt=""><figcaption><p>Group configuration</p></figcaption></figure>
