> For the complete documentation index, see [llms.txt](https://docs.clickai.vn/clickai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clickai.vn/clickai-docs/nha-phat-trien/xay-dung-ung-dung-ai-agent-workflows.md).

# Xây dựng Ứng dụng AI, Agent, Workflows

## Mục lục

·       \[Giới thiệu]\(#giới-thiệu)

·       \[Các loại ứng dụng]\(#các-loại-ứng-dụng)

·       \[Chatbot]\(#1-chatbot)

·       \[Text Generator]\(#2-text-generator)

·       \[Agent]\(#3-agent)

·       \[Workflow]\(#4-workflow)

·       \[Chatflow]\(#5-chatflow)

·       \[Workflow & Chatflow Editor]\(#workflow--chatflow-editor)

·       \[Các Node cơ bản]\(#các-node-cơ-bản)

·       \[Biến & Dữ liệu]\(#biến--dữ-liệu)

·       \[App Toolkit — Tính năng mở rộng]\(#app-toolkit--tính-năng-mở-rộng)

·       \[Quy trình Build ứng dụng]\(#quy-trình-build-ứng-dụng)

·       \[Best Practices]\(#best-practices)

&#x20;

## Giới thiệu

ClickAI Studio cung cấp môi trường phát triển trực quan để bạn xây dựng các ứng dụng AI — từ chatbot đơn giản đến workflow tự động hóa phức tạp. Nền tảng hỗ trợ nhiều loại ứng dụng, mỗi loại được tối ưu cho các use-case khác nhau.

💡 TIP: Bạn không cần kinh nghiệm lập trình để bắt đầu xây dựng ứng dụng AI trên ClickAI. Giao diện kéo-thả giúp bất kỳ ai cũng có thể tạo ứng dụng AI chuyên nghiệp.

<figure><img src="/files/vZDzSO5w4dicgr0p4JXp" alt=""><figcaption></figcaption></figure>

## Các loại ứng dụng

### 1. Chatbot & Agent

AI Agent tại ClickAI xây dựng trên kiến trúc Agentic, có khả năng tự suy luận, lập kế hoạch và sử dụng các công cụ (tools) để hoàn thành nhiệm vụ phức tạp.

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Đặc điểm</td><td valign="top">Mô tả</td></tr><tr><td valign="top">Khả năng</td><td valign="top">Tự động chọn và sử dụng tools</td></tr><tr><td valign="top">Suy luận</td><td valign="top">Chain-of-thought reasoning</td></tr><tr><td valign="top">Tools</td><td valign="top">Web search, Code interpreter, API calls, ...</td></tr><tr><td valign="top">Use-case</td><td valign="top">Nghiên cứu thị trường, phân tích dữ liệu, tự động hóa</td></tr></tbody></table>

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Đặc điểm</td><td valign="top">Mô tả</td></tr><tr><td valign="top">Giao tiếp</td><td valign="top">Hội thoại nhiều lượt</td></tr><tr><td valign="top">Đầu vào</td><td valign="top">Nội dung từ người dùng</td></tr><tr><td valign="top">Đầu ra</td><td valign="top">AI tạo nội dung phản hồi</td></tr><tr><td valign="top">Tính ứng dụng</td><td valign="top">Customer support, virtual assistant, FAQ bot</td></tr><tr><td valign="top"></td><td valign="top"></td></tr></tbody></table>

<figure><img src="/files/6ZYtn8oz7QAIQqlsn4QV" alt=""><figcaption></figcaption></figure>

⚠️ IMPORTANT: Agent có thể gọi nhiều tool trong một lượt xử lý. Đảm bảo cấu hình đúng permissions cho các tool được kết nối.

### 2. Workflow

Luồng xử lý tự động hóa dạng pipeline — thực thi tuần tự từ đầu đến cuối, không có tương tác hội thoại.

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Đặc điểm</td><td valign="top">Mô tả</td></tr><tr><td valign="top">Kiểu thực thi</td><td valign="top">Tuần tự, batch processing</td></tr><tr><td valign="top">Đầu vào</td><td valign="top">Biến đầu vào (variables)</td></tr><tr><td valign="top">Đầu ra</td><td valign="top">Kết quả xử lý cuối cùng</td></tr><tr><td valign="top">Use-case</td><td valign="top">ETL data, tạo báo cáo, xử lý hàng loạt</td></tr></tbody></table>

<figure><img src="/files/Uns3QH872LQy3rMe4qt1" alt=""><figcaption></figcaption></figure>

### 3. Chatflow

Kết hợp sức mạnh của Workflow với giao diện hội thoại — cho phép xây dựng chatbot phức tạp với logic xử lý đa tầng.

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Đặc điểm</td><td valign="top">Mô tả</td></tr><tr><td valign="top">Kiểu giao tiếp</td><td valign="top">Hội thoại + logic phân nhánh</td></tr><tr><td valign="top">Sức mạnh</td><td valign="top">Toàn bộ node của Workflow + chat context</td></tr><tr><td valign="top">Use-case</td><td valign="top">Customer service phức tạp, hướng dẫn từng bước</td></tr></tbody></table>

## Workflow & Chatflow Editor

### Các Node cơ bản

ClickAI cung cấp hệ thống node phong phú để xây dựng logic xử lý:

#### 🔄 Flow Control

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Node</td><td valign="top">Chức năng</td></tr><tr><td valign="top">Start</td><td valign="top">Điểm bắt đầu, định nghĩa đầu vào</td></tr><tr><td valign="top">End</td><td valign="top">Điểm kết thúc, trả về kết quả</td></tr><tr><td valign="top">IF/ELSE</td><td valign="top">Phân nhánh logic có điều kiện</td></tr><tr><td valign="top">Iteration</td><td valign="top">Lặp qua danh sách items</td></tr><tr><td valign="top">Loop</td><td valign="top">Vòng lặp với điều kiện dừng</td></tr><tr><td valign="top">Parameter Extractor</td><td valign="top">Trích xuất tham số từ ngôn ngữ tự nhiên</td></tr></tbody></table>

<figure><img src="/files/18LtZOnFT48TGRr8Vvj3" alt=""><figcaption></figcaption></figure>

#### 🧠 Model

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Node</td><td valign="top">Chức năng</td></tr><tr><td valign="top">LLM</td><td valign="top">Gọi mô hình ngôn ngữ lớn (GPT, Claude, Gemini, ...)</td></tr><tr><td valign="top">Knowledge Retrieval</td><td valign="top">Truy vấn Knowledge Base</td></tr><tr><td valign="top">Question Classifier</td><td valign="top">Phân loại câu hỏi người dùng</td></tr></tbody></table>

#### 🔧 Tools

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Node</td><td valign="top">Chức năng</td></tr><tr><td valign="top">Code</td><td valign="top">Chạy code Python / JavaScript tùy chỉnh</td></tr><tr><td valign="top">HTTP Request</td><td valign="top">Gọi API bên ngoài</td></tr><tr><td valign="top">Template</td><td valign="top">Định dạng output với Jinja2 template</td></tr><tr><td valign="top">Variable Assigner</td><td valign="top">Gán giá trị cho biến</td></tr></tbody></table>

&#x20;📤 Output

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Node</td><td valign="top">Chức năng</td></tr><tr><td valign="top">Answer</td><td valign="top">Trả lời trực tiếp cho người dùng (Chatflow)</td></tr><tr><td valign="top">End</td><td valign="top">Trả về kết quả cuối (Workflow)</td></tr></tbody></table>

ClickAI hỗ trợ các loại biến:

·       Input Variables: Biến đầu vào do người dùng cung cấp

·       Environment Variables: Biến môi trường (API keys, secrets)

·       Conversation Variables: Biến phiên hội thoại (session-scoped)

·       System Variables: sys.query, sys.user\_id, sys.conversation\_id, ...

Ví dụ sử dụng biến trong LLM Prompt:\
──────────────────────────────────────\
Bạn là trợ lý AI cho công ty {{company\_name}}.\
Khách hàng hỏi: {{sys.query}}\
Hãy trả lời dựa trên {{#knowledge.context#}}

&#x20;

## App Toolkit — Tính năng mở rộng

Các tính năng tùy chọn giúp nâng cấp ứng dụng:

### 💬 Conversation Opener

Thiết lập tin nhắn chào mừng và gợi ý câu hỏi ban đầu cho người dùng.

Xin chào! 👋 Tôi là trợ lý AI của {{company\_name}}.\
Tôi có thể giúp bạn:\
\
• Tra cứu thông tin sản phẩm\
• Hỗ trợ kỹ thuật\
• Hướng dẫn sử dụng

### 🔄 Follow-up

Tự động gợi ý các câu hỏi tiếp theo dựa trên ngữ cảnh hội thoại.

### 🔊 Text to Speech (TTS)

Chuyển đổi phản hồi văn bản thành giọng nói tự nhiên.

### 🎤 Speech to Text (STT)

Cho phép người dùng nhập liệu bằng giọng nói.

### 📎 File Upload

Cho phép upload file làm đầu vào:

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Loại file</td><td valign="top">Giới hạn mặc định</td></tr><tr><td valign="top">Image</td><td valign="top">10 MB</td></tr><tr><td valign="top">Document</td><td valign="top">15 MB</td></tr><tr><td valign="top">Audio</td><td valign="top">50 MB</td></tr><tr><td valign="top">Video</td><td valign="top">100 MB</td></tr></tbody></table>

&#x20;

### 📝 Citations & Attributions

Hiển thị nguồn trích dẫn từ Knowledge Base, giúp người dùng xác minh thông tin.

### 🛡️ Content Moderation

Lọc nội dung không phù hợp với 3 phương pháp:

7\.     OpenAI Moderation: Dùng model moderation chuyên dụng

8\.     Keywords: Danh sách từ khóa bị chặn

9\.     API Extension: Kết nối API lọc nội dung tùy chỉnh

### ✏️ Annotation Reply

Tạo thư viện câu trả lời chuẩn, bypass AI khi gặp câu hỏi đã được ghi chú.

&#x20;

## Quy trình Build ứng dụng

graph LR\
&#x20;   A\[📋 Xác định\<br>Use-case] --> B\[🎯 Chọn loại\<br>ứng dụng]\
&#x20;   B --> C\[⚙️ Cấu hình\<br>Model & Prompt]\
&#x20;   C --> D\[📚 Kết nối\<br>Knowledge]\
&#x20;   D --> E\[🔧 Thêm\<br>Tools]\
&#x20;   E --> F\[🧪 Debug &\<br>Preview]\
&#x20;   F --> G\[🚀 Publish]

<table data-header-hidden><thead><tr><th valign="top"></th><th valign="top"></th><th valign="top"></th></tr></thead><tbody><tr><td valign="top">Bước</td><td valign="top">Hành động</td><td valign="top">Chi tiết</td></tr><tr><td valign="top">1</td><td valign="top">Xác định Use-case</td><td valign="top">Xác định rõ mục đích và đối tượng sử dụng</td></tr><tr><td valign="top">2</td><td valign="top">Chọn loại ứng dụng</td><td valign="top">Chatbot, Agent, Workflow, hoặc Chatflow</td></tr><tr><td valign="top">3</td><td valign="top">Cấu hình Model</td><td valign="top">Chọn LLM, viết System Prompt</td></tr><tr><td valign="top">4</td><td valign="top">Kết nối Knowledge</td><td valign="top">Upload tài liệu vào Knowledge Base</td></tr><tr><td valign="top">5</td><td valign="top">Thêm Tools</td><td valign="top">Kết nối API, plugins, custom code</td></tr><tr><td valign="top">6</td><td valign="top">Debug &#x26; Preview</td><td valign="top">Test trực tiếp trong Studio</td></tr><tr><td valign="top">7</td><td valign="top">Publish</td><td valign="top">Triển khai qua Web App, API, hoặc Embed</td></tr></tbody></table>

## Best Practices

💡 TIP: \*\*System Prompt hiệu quả:\*\* - Xác định rõ vai trò và phong cách trả lời - Đặt giới hạn rõ ràng về phạm vi trả lời - Sử dụng ví dụ mẫu (few-shot examples)

🚨 WARNING: \*\*Lưu ý quan trọng:\*\* - Luôn test kỹ trước khi publish lên production - Thiết lập Content Moderation cho ứng dụng public-facing - Monitor token usage để kiểm soát chi phí

&#x20;

*📖 Tiếp theo: \[Publish — Triển khai ứng dụng]*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.clickai.vn/clickai-docs/nha-phat-trien/xay-dung-ung-dung-ai-agent-workflows.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
