Self-host Flowise: visual builder cho LangChain trên VPS

Chia sẻ bài viết

Mục lục
TL;DR
  • Flowise là drag-drop visual builder open source cho LangChain, 30k+ star GitHub, build agent/RAG/chatbot mà không cần code Python.
  • Chạy 1 lệnh Docker Compose trên Cloud VPS 40 (399k/tháng) là xong, expose REST API cho app integration.
  • Hỗ trợ 100+ node: LLM (Claude, OpenAI, Ollama), vector DB (Chroma, Pinecone, Qdrant), tool (Tavily, SerpAPI), memory, document loader.
  • Use case: PoC AI nhanh cho client, internal bot, training material agent, demo workshop.
  • Trade-off: visual builder dễ học nhưng kém linh hoạt hơn code Python cho production phức tạp.

Build agent AI bằng code LangChain Python mất 1-2 ngày setup, debug, deploy. Cho PoC và demo client, lâu quá. Flowise giải bài này: kéo thả node trên web UI, connect input-output, click "Save", có ngay REST endpoint sẵn sàng. PoC chatbot RAG cho khách hàng làm trong 30 phút thay vì 2 ngày.

Mình đã dùng Flowise cho 8 client trong 2025: 3 chatbot website, 2 internal HR bot, 2 doc Q&A, 1 sales assistant. Sau khi PoC OK, một số tốt nghiệp sang LangChain Python code chuẩn production. Bài này chia sẻ setup full, build flow đầu tiên, deploy production, và khi nào nên migrate sang code.

1. Flowise vs n8n vs Langflow

Tiêu chíFlowiseLangflown8n
FocusLangChain agent/RAGLangChain agent/RAGGeneral workflow automation
BackendNode.js + TypeScriptPython (LangChain native)Node.js
LicenseApache 2.0MITFair-code
Node count100+80+500+ (general)
AI specializedTốtRất tốtTrung bình
RAM idle400MB800MB (Python)400MB
Cộng đồng VNĐang growTốtRất tốt

Flowise win về performance và DX cho AI use case. Langflow đầy đủ hơn về node Python native. n8n mạnh khi cần workflow business chung (CRM, email, Slack).

2. Cài Flowise Docker Compose

mkdir -p /opt/flowise && cd /opt/flowise
# docker-compose.yml
services:
  flowise:
    image: flowiseai/flowise:latest
    container_name: flowise
    restart: unless-stopped
    environment:
      PORT: 3000
      DATABASE_TYPE: postgres
      DATABASE_HOST: db
      DATABASE_PORT: 5432
      DATABASE_NAME: flowise
      DATABASE_USER: flowise
      DATABASE_PASSWORD: flowise_secure_pass
      FLOWISE_USERNAME: admin
      FLOWISE_PASSWORD: change_to_strong_password
      APIKEY_PATH: /root/.flowise
      SECRETKEY_PATH: /root/.flowise
      LOG_PATH: /root/.flowise/logs
      LOG_LEVEL: info
    volumes:
      - flowise-data:/root/.flowise
    ports:
      - "127.0.0.1:3001:3000"
    depends_on:
      - db

  db:
    image: postgres:16-alpine
    container_name: flowise-db
    environment:
      POSTGRES_USER: flowise
      POSTGRES_PASSWORD: flowise_secure_pass
      POSTGRES_DB: flowise
    volumes:
      - flowise-db:/var/lib/postgresql/data

volumes:
  flowise-data:
  flowise-db:
docker compose up -d
docker logs -f flowise

3. Reverse proxy Caddy

flow.your-domain.com {
    reverse_proxy 127.0.0.1:3001 {
        flush_interval -1
    }
    encode gzip
}

Reload Caddy, vào https://flow.your-domain.com, đăng nhập với admin/password đã set.

4. Build chatbot RAG đầu tiên trong 15 phút

  1. Click "Chatflows" -> "Add New" -> chọn template "Conversational Retrieval QA Chain"
  2. Drag node "Recursive Character Text Splitter" -> "PDF File" loader, upload tài liệu PDF
  3. Drag node "OpenAI Embeddings" hoặc "Hugging Face BGE" embed
  4. Drag node "In-Memory Vector Store" hoặc "Chroma"
  5. Drag node "Chat OpenAI" hoặc "Chat Anthropic"
  6. Drag node "Conversation Memory" cho multi-turn
  7. Connect các node theo flow input -> embed -> store -> retrieve -> LLM -> output
  8. Save flow, test ở panel "Chat" bên phải

Flowise tự gen API endpoint /api/v1/prediction/{chatflow-id}, bạn fetch từ frontend là xong.

5. Integrate vào frontend website

// React component
import { useState } from 'react'

export default function ChatBot({ flowId }) {
  const [messages, setMessages] = useState([])
  const [input, setInput] = useState('')

  async function send() {
    const userMsg = { role: 'user', content: input }
    setMessages([...messages, userMsg])

    const res = await fetch(`https://flow.your-domain.com/api/v1/prediction/${flowId}`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        question: input,
        overrideConfig: {
          sessionId: 'user-123'  // for memory persistence
        }
      })
    })
    const data = await res.json()
    setMessages([...messages, userMsg, { role: 'assistant', content: data.text }])
    setInput('')
  }

  return (
    
{messages.map((m, i) => (
{m.content}
))} setInput(e.target.value)} />
) }

Hoặc dùng widget embed có sẵn của Flowise:

6. Agent với tool use

Flowise hỗ trợ "Tool Agent" node. Drag node tool có sẵn: Calculator, SerpAPI, Tavily Search, Custom Function. Connect vào Agent node, LLM tự quyết định khi nào dùng tool.

Custom Function tool cho phép viết JavaScript ngắn:

// Function name: lookup_order
// Description: Lookup order status by order ID
// Arguments: orderId (string)

const orderId = $orderId
const res = await fetch(`https://api.your-domain.com/orders/${orderId}`, {
  headers: { 'Authorization': `Bearer ${$vars.API_TOKEN}` }
})
const order = await res.json()
return JSON.stringify({
  status: order.status,
  total: order.total,
  shipping_address: order.shipping_address
})

7. Document loader: 30+ source

  • File: PDF, Word, Excel, CSV, JSON, Markdown, HTML
  • URL: web scrape, sitemap crawler
  • API: Notion, Confluence, GitHub, GitLab, Jira
  • Cloud: S3, Google Drive, Dropbox
  • Database: SQL via custom loader, MongoDB

Drag loader, config credential, click "Process", document tự chunked và embed. Pattern phổ biến: load Confluence wiki -> embed -> build Q&A bot nội bộ.

8. Vector database options

Vector DBSetupBest for
In-MemoryBuilt-inPoC, demo nhỏ
Chroma local1 click1-10M vectors
Qdrant CloudAPI keyProduction scale
PineconeAPI key paidMulti-tenant SaaS
PgvectorPostgres extensionTích hợp với existing DB
MilvusDocker composeSelf-host scale lớn

Cho PoC, In-Memory đủ. Cho production self-host, Chroma hoặc Qdrant. Cho startup paying customer, Pinecone tiện nhất.

9. LLM provider hỗ trợ

  • OpenAI: GPT-4, GPT-4o, GPT-4o-mini, o1
  • Anthropic: Claude 4.5, 4.7 family
  • Google: Gemini 1.5, 2.5
  • Mistral, Cohere, Groq (fast inference)
  • Ollama (local), LocalAI, vLLM endpoint
  • HuggingFace Inference API
  • Custom OpenAI-compatible endpoint

Switch LLM dễ: đổi node trong flow, không cần rewrite. Test cùng prompt qua Claude vs GPT-4o, compare quality cho use case của bạn.

10. Authentication và security

# Trong docker-compose, thêm:
FLOWISE_USERNAME: admin
FLOWISE_PASSWORD: strong_password
JWT_AUTH_TOKEN_SECRET: random_32_char_secret
JWT_REFRESH_TOKEN_SECRET: another_random_secret
JWT_ISSUER: flowise

# API key per chatflow
# Trong UI: Chatflow Settings -> API Key -> Create

Mỗi flow có API key riêng, expose cho client cụ thể. Rotate key định kỳ. Caddy basicauth thêm 1 lớp bảo vệ admin UI.

11. Variable và secret management

Flowise Variables: lưu key API, config dùng cross-flow. Vào "Variables" -> "Add" -> tên ANTHROPIC_API_KEY, value sk-ant-..., type "Encrypted". Dùng trong flow bằng $vars.ANTHROPIC_API_KEY.

Backup secret bằng cách dump volume Postgres flowise-db, không hardcode trong code.

12. Marketplace template

Flowise có "Marketplace" với 50+ template community share: customer support bot, SQL Q&A, code reviewer, SEO content writer, email triage. Import 1 click, customize cho use case của bạn.

Template thường có sẵn prompt engineering tốt, học hỏi pattern từ community.

13. Monitor và analytics

Flowise có built-in analytics: số lượng request, latency, error rate, cost token. Export sang Langfuse, Langsmith, hoặc Phoenix nếu cần observability sâu hơn.

# Trong env Flowise:
ANALYTIC_PROVIDER: langfuse
LANGFUSE_PUBLIC_KEY: pk_lf_...
LANGFUSE_SECRET_KEY: sk_lf_...
LANGFUSE_HOST: https://lf.your-domain.com

14. Khi nào migrate từ Flowise sang code

  • Logic phức tạp branching/loop nhiều, visual hard to maintain
  • Cần custom tool sâu (RPA, file system, OS-level)
  • Performance critical (visual node có overhead serialization)
  • Team grow, cần version control git, code review chuẩn
  • Compliance audit yêu cầu code trace rõ ràng

Pattern phổ biến: PoC trên Flowise, validate market, sau đó dev team migrate sang Python LangChain hoặc LangGraph cho production.

15. Use case demo cho client

  1. HR Q&A bot: load policy PDF, embed, chat answer policy.
  2. Sales lookup: agent với tool query CRM API, trả lời deal status.
  3. Document summarizer: upload PDF, summarize ngắn gọn, key takeaway.
  4. Code review bot: agent đọc git diff, suggest improvement.
  5. SEO writer: input keyword, agent research + viết outline + draft bài.
  6. Customer support: chatbot trên website, escalate human khi không xử lý được.

16. Cost realistic cho indie và startup

ResourceSpecCost/tháng
VPS Flowise + PostgresCloud VPS 40 (2GB)399k
LLM API (1000 query/ngày)Claude Haiku 4~600k
Vector DB (Chroma local)Included VPS
Embedding (BGE local)Included VPS
Tổng10k query/ngày~1.000k

Rẻ hơn nhiều so với SaaS chatbot platform (Intercom, Drift) tốn 100-500 USD/tháng. Tự host Flowise tiết kiệm 80%+ cho startup VN.

17. Build SQL Q&A bot trong 20 phút

Use case rất phổ biến: cho non-tech user hỏi data bằng tiếng tự nhiên, bot tự dịch sang SQL, query DB read-only, trả lời. Setup Flowise:

  1. Drag node "SQL Database Chain" hoặc "SQL Database Agent"
  2. Config connection string Postgres read-only user
  3. Add "Sample SQL" và "Schema Description" cho LLM hiểu schema
  4. Connect Chat OpenAI/Anthropic làm LLM
  5. Test: "Top 5 sản phẩm bán chạy tuần này?"
  6. Bot tự gen SQL: SELECT product_name, SUM(qty) FROM orders WHERE created_at > NOW() - interval '7 days' GROUP BY product_name ORDER BY 2 DESC LIMIT 5
  7. Execute và trả về result formatted

Quan trọng: dùng read-only DB user, set statement_timeout 30s, không cho phép DROP/UPDATE. Combine với approval workflow nếu query critical.

18. Multi-flow chaining

Flowise hỗ trợ gọi flow khác từ trong flow hiện tại. Pattern: 1 flow router classify intent, route sang specialised flow.

// Router flow: classify intent
{
  "user_query": "Top 5 product bán chạy",
  "intent_options": ["sql_query", "doc_search", "general_chat"]
}

// Result: intent = "sql_query"
// Router gọi sub-flow "SQL Bot" với cùng user_query
// Sub-flow trả result, router format gửi user

Pattern này giúp scale flow tốt khi có nhiều use case. Tách concerns rõ ràng, dễ maintain.

19. Backup và version control flow

Flow JSON export/import dễ. Backup hằng tuần:

# Export all flow qua API
curl -X GET https://flow.your-domain.com/api/v1/chatflows 
  -H "Authorization: Bearer $API_KEY" 
  > /opt/backup/flowise-flows-$(date +%F).json

# Commit lên git private repo
cd /opt/gitops-flows
cp /opt/backup/flowise-flows-*.json .
git add . && git commit -m "Backup flows $(date +%F)" && git push

Restore khi cần: import JSON qua UI hoặc API. Combine với snapshot VPS Cloud TND cho disaster recovery toàn diện.

20. Performance optimization

  1. Cache LLM response: bật caching cho query lặp lại (FAQ phổ biến).
  2. Streaming response: enable streaming trong flow setting, frontend nhận token dần.
  3. Vector DB tốt: Qdrant nhanh hơn Chroma 3-5x cho dataset 1M+ vectors.
  4. Pre-process document: embed offline 1 lần, không re-embed mỗi request.
  5. Limit context size: chunk size 500-1000 tokens, top_k = 4-6 chunks là sweet spot.

21. Tổng kết và roadmap

Flowise là tool tuyệt vời cho indie và team nhỏ build AI feature nhanh không cần code Python. Trade-off rõ: dễ học, dễ ship, kém linh hoạt cho production phức tạp. Strategy của mình: dùng Flowise cho PoC và demo client (1-2 ngày là done), validate market, sau đó migrate quan trọng nhất sang code LangChain Python khi cần custom sâu. Workflow này tiết kiệm hàng tuần dev time cho mỗi dự án mới.

Cloud VPS cho vibe coder

VPS chạy Flowise visual builder cho dev no-code AI

Cloud VPS TND sẵn AlmaLinux 9, Ubuntu 22/24, Debian 12/13. SSD CEPH, snapshot 1-click, backup hằng ngày, network 200Mbps trong nước. Cloud VPS 40 (2GB RAM, 399k) đủ chạy Flowise + Postgres + Chroma cho 10k query/ngày.

Xem 8 cấu hình Cloud VPS →

FAQ

Flowise có miễn phí không?

Có, license Apache 2.0 hoàn toàn free self-host. Flowise Cloud (managed) thì tính phí 10-100 USD/tháng. Cho team có VPS sẵn, self-host miễn phí dùng tốt.

So với code LangChain Python thì kém ở đâu?

Flowise hạn chế custom logic phức tạp (loop, branching nhiều layer), debug khó hơn code, ít linh hoạt cho edge case. Cho PoC và demo, Flowise nhanh hơn. Cho production phức tạp, code Python kiểm soát tốt hơn.

VPS bao nhiêu RAM đủ cho Flowise?

Cloud VPS 40 (2GB RAM, 399k) đủ cho 10-50 user concurrent. Lên 100+ user và embedding nhiều thì Cloud VPS 80 (4GB). Vector DB lớn (10M+ vector) cần RAM 8GB+ hoặc dùng Qdrant Cloud.

Flowise có hỗ trợ tiếng Việt không?

UI hiện chỉ tiếng Anh, nhưng flow xử lý tiếng Việt tốt (LLM Claude/GPT hiểu Vietnamese). Embedding BGE-M3 multilingual hỗ trợ Vietnamese chính xác. Build bot tiếng Việt hoàn toàn OK.

Có chạy được cùng n8n trên 1 VPS không?

Được, dùng port khác nhau (Flowise 3001, n8n 5678) và Caddy route subdomain riêng. Cloud VPS 80 (4GB RAM) đủ chạy cả 2 cho team nhỏ. Combine mạnh mẽ: n8n cho workflow general, Flowise cho AI flow.

22. Bài học sau 1 năm dùng Flowise

Mình đã ship 8 dự án Flowise production trong năm qua, đây là những bài học quan trọng. Thứ nhất, Flowise giúp validate ý tưởng AI nhanh nhất hiện tại, từ ý tưởng đến demo client chỉ 1 buổi sáng. Thứ hai, prompt engineering trong Flowise vẫn quan trọng nhất, dù UI giúp setup nhanh nhưng prompt kém vẫn cho output kém. Thứ ba, đầu tư vào RAG quality (chunk size, embedding model, top_k) hơn là chọn LLM expensive nhất, BGE-M3 multilingual + Claude Haiku rẻ và hiệu quả cho 80% use case Việt Nam. Thứ tư, monitor cost LLM hằng ngày để tránh surprise bill, set rate limit per user. Cuối cùng, document flow rõ ràng bằng note trong UI, dev khác handover dễ dàng. Flowise là tool đáng đầu tư cho mọi indie hacker và team nhỏ build AI feature 2026.

2009
15+ năm vận hành liên tục
10+
tập đoàn lớn tin dùng
100+
doanh nghiệp SMB Việt
30 ngày
đổi key lỗi miễn phí
Phần mềm bản quyền chính hãng chúng tôi cung cấp
Bản quyền chính hãng Hóa đơn VAT đầy đủ Đổi key lỗi 30 ngày Vận hành từ 2009 MST 0200994870 Hotline 0225.999.6666