=== ThimPress AI Chatbot with Chatboz ===
Contributors: thimpress
Donate link:
Tags: chat, education.
Tested up to: 6.9
Stable tag: 1.0.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Chatboz - AI chatbot for WordPress

== Description ==

Chatboz is an AI-powered chatbot plugin designed specifically for WordPress websites. It leverages advanced natural language processing to provide intelligent and context-aware responses to user queries, enhancing user engagement and support.

Integration with LearnPress LMS system allows Chatboz to assist students with course-related questions, enrollment processes, and general inquiries about the learning platform.

== Source and Build ==

This plugin ships compiled assets in `assets/dist`.

Source files are included in:
- `assets/src/js`
- `assets/src/scss`
- `assets/src/css`

Build steps:
1. `npm install`
2. `npm run build`
3. `npm run build:styles`
4. `npm run release`

Generated files are output into `assets/dist` and release artifacts are created in `release/`.

== External services ==
Plugin Chatboz AI Chatbot send data chat via API của chatboz to storage messages.

Document use API của chatboz: api.chatboz.com/docs

Term: https://api.chatboz.com/api/v1/terms-of-use

Privacy policy: https://api.chatboz.com/api/v1/privacy-policy

### Chatboz API Overview - Chatbot System

#### System Overview

The RAG Chatbot System (Retrieval-Augmented Generation) provides an intelligent chat solution with the ability to answer questions based on uploaded documents, combined with group chat features that allow multiple users to interact in the same chat room.

#### Technology Stack

1. **Backend Framework:** FastAPI
2. **Database:** MongoDB
3. **AI/ML:** LangChain, OpenAI/Google AI
4. **Real-time Communication:** WebSocket
5. **Authentication:** JWT Token

---

### Main Chat APIs

**Base URL:** `/api/v1`

---

#### 1. Bot Chat API (1-on-1)

**Endpoint:** `POST /chat`

**Description:** Send a message to the chatbot and receive an answer based on trained documents. The bot returns a streaming response (`text/event-stream`) to display the answer character by character.

**Authentication:** Bearer Token

**Request Body:**
```json
{
  "session_id": "session_123",
  "question": "What are the features of your product?",
  "chat_history": [
    {
      "role": "user",
      "content": "Hello"
    },
    {
      "role": "assistant",
      "content": "Hi! How can I help you?"
    }
  ]
}
```

**Response (Streaming):**
```
Content-Type: text/event-stream

Our product has the following features:
1. Automated 24/7 question answering
2. RAG (Retrieval-Augmented Generation) integration
3. Multi-language support
4. Document data analysis...
```

**Notes:**

1. Response is streamed as Server-Sent Events (SSE)
2. Answer is sent token by token (real-time typing effect)
3. After streaming completes, message is automatically saved to database with `session_id`
4. Token usage and cost are calculated and stored

**Use Cases:**

1. 1-on-1 chat with bot for product/service Q&A
2. Automated 24/7 customer question answering
3. Customer support with information from knowledge base

**Additional Notes:**

1. Bot answers based on uploaded and trained documents
2. Includes sources for users to verify information
3. Supports chat history for bot to understand conversation context

---

#### 2. WebSocket Group Chat (Real-time Multi-user)

**Endpoint:** `WebSocket /ws/group/{client_id}`

**Description:** Connect via WebSocket for real-time chat with multiple people in a room.

**Authentication:** `client_id` in URL (membership check when joining room)

---

#### Event: Send message in group

**Client sends:**
```json
{
  "event": "message",
  "room_id": "room_001",
  "content": "Hello everyone!",
  "sender": {
    "id": "user_123",
    "type": "user",
    "name": "John Smith"
  }
}
```

**Server broadcasts to all members:**
```json
{
  "event": "message",
  "room_id": "room_001",
  "message_id": "msg_001",
  "client_id": "user_123",
  "content": "Hello everyone!",
  "sender": {
    "id": "user_123",
    "type": "user",
    "name": "John Smith"
  },
  "timestamp": "2026-03-06T10:35:00Z"
}
```

---

#### Event: Join room

**Client sends:**
```json
{
  "event": "join",
  "room_id": "room_001",
  "limit": 50
}
```

**Server response:**
```json
{
  "event": "joined",
  "room_id": "room_001",
  "message": "Successfully joined room room_001"
}
```

**Server sends chat history:**
```json
{
  "event": "chat_history",
  "room_id": "room_001",
  "messages": [
    {
      "id": "msg_001",
      "sender": {...},
      "content": "Hello!",
      "timestamp": "2026-03-06T10:00:00Z"
    }
  ],
  "total": 150,
  "has_more": true
}
```

---

**Use Cases:**

1. Real-time group chat for team collaboration
2. Customer support with multiple agents
3. Live chat in e-learning
4. Community discussion rooms

**Key Features:**

1. Real-time messaging with WebSocket
2. Typing indicator display
3. Message reactions (👍, ❤️, ...)
4. Reply to message
5. Mention users (`@username`)
6. Edit/Delete messages
7. Pin important messages
8. Room management (lock, mute members, ban)

---

### Authentication

All APIs require authentication using one of the following methods:

**Bearer Token (JWT)** — For REST API
```
Authorization: Bearer <token>
```

**Client ID** — For WebSocket
```
wss://api.chatboz.com/api/v1/ws/group/user_123
```

**User ID** — For some simple APIs
```
?user_id=user_123
```

== Screenshots ==

1. Screen 1: Chatboz Chat Interface on a WordPress site.
2. Screen 2: Admin Settings Page for configuring Chatboz.

== Changelog ==

= 1.0.0 (2026-04-24) =
~ Initial release of Chatboz - AI Chatbot & Live Chat plugin.
