flag92 flag92
Solutions

Dify + RAGFlow — two-layer stack for complex documents

Dify owns the app layer and workflow; RAGFlow handles retrieval over tables, scans and complex layouts that defeat simple chunking.

Scenario
KB is dominated by complex PDFs — product manuals, contracts, medical guidelines — where naive chunking fails
Monthly cost
$150 - $500
Difficulty
Hard
DifyRAGFlowChatwootPostgreSQLElasticsearch

What this combo solves#

Dify’s built-in KB is fine for Markdown / Notion exports, but it stumbles on:

Document typeDify default
Product manual with 12 tablesTables fragmented; 30-60% spec hit rate
Two-column legal / policy docsText streams out of order
Scanned / legacy manuals0 hits (no OCR)
Tech docs with formulas / figuresHeavy information loss

RAGFlow benchmarks show its DeepDoc engine lifts retrieval accuracy on these documents from ~60% to 90%+. RAGFlow is a retrieval engine, not an app platform — best paired as:

Dify for the app layer (prompts + workflow + multi-LLM) + RAGFlow as retrieval backend

Architecture#

Agent Bot

HTTP Tool

Cite + generate

Answer w/ chunk_id

Customer

Chatwoot

Dify Workflow

RAGFlow Retrieval API

RAGFlow Engine
+ DeepDoc parsing
+ Vector + BM25 + GraphRAG

Elasticsearch / Infinity

Source PDFs / Word

LLM

Components#

ComponentRoleSizing
RAGFlowDocument parsing + retrieval8C/16G + 100GB
Elasticsearch / InfinityBacking search4C/8G + 50GB
DifyWorkflow, prompts, LLM governance8C/16G
ChatwootChannels + agents4C/8G
PostgreSQLMetadata2C/4G

Deployment#

1. Bring up RAGFlow#

git clone https://github.com/infiniflow/ragflow
cd ragflow/docker
docker compose -f docker-compose.yml up -d

Open http://YOUR_IP:80, register, create the first KB:

  • Language: Chinese / mixed
  • Chunking: General to start, or Paper / Manual for table-heavy
  • Embedding: bge-m3
  • Upload docs, wait for DeepDoc to finish parsing (5-30s per page)

2. Test retrieval#

In RAGFlow’s Retrieval Testing pane, run real questions:

  • Tables: “max output power of model X-200”
  • Two-column: “temperature limit mentioned in chapter 2”
  • Scans: “safety rules in appendix B”

If top-1 lags:

  • Switch chunking strategy
  • Enable Auto-keyword and Auto-question preprocessing
  • Add reranker (default bge-reranker-v2-m3)

3. Use RAGFlow as Dify’s retriever#

Dify Workflow with an HTTP Request node:

Node: HTTP Request
URL: https://ragflow.example.com/api/v1/retrieval
Method: POST
Headers:
  Authorization: Bearer <RAGFlow API Key>
Body:
  {
    "question": "{{user_question}}",
    "dataset_ids": ["kb_uuid"],
    "top_k": 5,
    "similarity_threshold": 0.5,
    "rerank": true
  }

Pass the returned [{chunk_id, content, score}, ...] to your LLM node.

4. Strict prompt#

You are [Brand]'s support assistant. Answer only from "Reference"
and cite chunk_id after each fact.

Reference:
{% for chunk in retrieved_chunks %}
[{{chunk.chunk_id}}] {{chunk.content}}
{% endfor %}

Question: {{question}}

Answer (with chunk_id):

5. Chatwoot integration#

Same as Chatwoot + Dify — wire the Dify app as an Agent Bot.

Tuning#

RAGFlow chunking#

Document typeChunking
Generic Markdown / WordGeneral
Product manual (table-heavy)Paper / Manual
Legal / contractsLaws
Academic papersPaper
Resumes / card-styleResume
BooksBook

Enable GraphRAG#

For entity-rich documents (interconnected specs, medical terminology), enable RAGFlow’s Knowledge Graph:

  • Check “Knowledge Graph” in KB settings
  • Retrieval returns graph relations alongside chunks
  • Both accuracy and explainability rise noticeably

Multi-KB routing#

When docs span multiple domains, classify intent in Dify first, then route:

Question → LLM classify(domain: A|B|policy) →
  ├─ A → RAGFlow KB_A
  ├─ B → RAGFlow KB_B
  └─ policy → RAGFlow KB_policy

Cost#

ResourceMonthly (self-host)
8C/16G (RAGFlow + Dify)$60-80
4C/8G (Chatwoot + Postgres)$30
LLM tokens (5k conv/mo, Qwen 72B)$50-150
Embedding (local GPU = free)$0
Domain + email$15
Total$155-275 / mo

Effect (same product manual)#

30 real questions, with tables / two-column / scanned pages:

SetupTop-1 hitsFaithfulness
Dify default KB17/300.78
Dify tuned KB23/300.85
Dify + RAGFlow (default)28/300.87
Dify + RAGFlow (tuned + GraphRAG)30/300.94

When NOT to pick this#

SituationUse instead
Docs are mostly Markdown / NotionChatwoot + Dify
Tight budget, single 4C/8G hostChatwoot + Dify first
< 100 simple docsAnythingLLM copilot + Chatwoot

Pitfalls#

  1. Parse speed — scanned PDF ~30s/page; 100 pages = 50 minutes; batch overnight
  2. Elasticsearch memory — default 1G is not enough; bump to 4G+ in production
  3. Dify HTTP timeout — RAGFlow queries sometimes take 2s; set node timeout to 10s
  4. Chinese OCR weakness — RAGFlow’s built-in OCR struggles with handwriting / blurred scans; preprocess with PaddleOCR

Search

Press ⌘ K to open