Retrieval-augmented generation (RAG) lets an AI agent answer questions by searching your documents first, then synthesizing a response from only the retrieved context. This eliminates hallucinations and keeps answers grounded in your actual content.Documentation Index
Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
Use this file to discover all available pages before exploring further.
When to use
Use this pattern when:- Users need accurate answers drawn from a specific document corpus (product sheets, FAQs, regulatory guides, policies)
- Responses must cite sources and avoid fabrication
- The knowledge changes over time and you want to update documents without retraining a model
- You need domain-specific answers that a general-purpose LLM cannot reliably provide
- The answer requires real-time data from an external API (use an MCP integration instead)
- The task is classification or extraction rather than open-ended Q&A (use TEXT_UNDERSTANDING or TEXT_EXTRACTION nodes)
- The corpus is very small (fewer than 5 documents) and could fit entirely in a system prompt
Architecture
- Analyzes the user query for key terms and intent
- Searches the connected Qdrant collection for relevant document chunks
- Receives the top matching chunks ranked by relevance score
- Synthesizes a response using only the retrieved context
- Returns a grounded answer with source references
Implementation
Prerequisites
Before configuring the workflow:- Create a Knowledge Base data source in Integration Designer
- Upload your documents (PDFs) to one or more stores in the Knowledge Base
- Wait for automatic chunking and vector indexing to complete
Knowledge Bases use vector embeddings stored in Qdrant for semantic search. Documents are automatically chunked and indexed when uploaded. For details, see the Knowledge Base integration documentation.
Configure the CUSTOM_AGENT node
Add a CUSTOM_AGENT node to your workflow
In the Agent Builder canvas, drag a Custom Agent node into your workflow.
Enable Knowledge Base
In the node configuration panel, scroll to the Knowledge Base section and enable it. Select the Knowledge Base you created.
Retrieval parameters
| Parameter | Description | Recommended value |
|---|---|---|
| Max. Number of Results | Number of document chunks retrieved per query (1-10) | 10 |
| Min. Relevance Score | Relevance threshold (0-100%). Chunks below this score are excluded | 10 |
| Metadata Filters | Restrict search using typed conditions. Use the system source key to scope to a specific store | No filters (search all stores) |
System prompt template
The prompt must instruct the agent to search the Knowledge Base and follow strict grounding rules.Input and output
| Direction | Key | Description |
|---|---|---|
| Input | User message (from chat or process data) | The question to answer |
| Output | Agent response text | The grounded answer synthesized from retrieved chunks |
Real-world example
The mortgage advisor chatbot tutorial uses this pattern in itsknowledgeBaseQA workflow. When the intent classifier detects a KNOWLEDGE_QA intent, the router calls a CUSTOM_AGENT node connected to a Knowledge Base containing mortgage product sheets, regulatory guides, and FAQ documents.
The agent answers questions such as:
- “What is DTI?” (retrieves debt-to-income ratio definition from the FAQ)
- “What are the requirements for a fixed-rate mortgage?” (retrieves eligibility criteria from product sheets)
- “What documents do I need to apply?” (retrieves checklist from the regulatory guide)
Mortgage advisor tutorial
Build the full chatbot including intent routing, knowledge base Q&A, and recommendation generation
Variations
Multi-KB search
Query multiple Knowledge Base collections in a single workflow. Use parallel CUSTOM_AGENT nodes, each connected to a different Knowledge Base, then merge the results in a downstream node. When to use: Your documents span distinct domains (for example, product documentation and regulatory compliance) that are better organized in separate collections.Hybrid search
Available starting with FlowX.AI 5.7.0Custom Agent and Context Retrieval nodes expose a Search Type option (Hybrid / Semantic / Keyword) directly on the node.
Hybrid (the default in 5.7+) on the CUSTOM_AGENT or CONTEXT_RETRIEVAL node. Choose Semantic for purely meaning-based retrieval, or Keyword when exact-token matches matter more than similarity.
When to use: Your documents contain precise terminology (part numbers, policy codes, legal references) where exact keyword matching outperforms semantic similarity alone.
Re-ranking
Available starting with FlowX.AI 5.7.0Custom Agent and Context Retrieval nodes expose a Re-rank toggle that applies a secondary relevance model to the retrieved chunks automatically — no downstream node required.
Best practices
Prepare your documents
Prepare your documents
Upload clean, well-structured documents. Remove headers, footers, and boilerplate that add noise. Organize documents into separate stores by topic for easier filtering.
Test retrieval before building the workflow
Test retrieval before building the workflow
Use the Knowledge Base test interface to run sample queries and verify that relevant chunks are returned with acceptable relevance scores before wiring the node into a workflow.
Tune retrieval parameters iteratively
Tune retrieval parameters iteratively
Start with a higher Max. Number of Results (8-10) and a lower Min. Relevance Score (10-20%). Monitor the chunks returned and adjust. Too few results leads to incomplete answers; too many leads to diluted context.
Keep prompts explicit about limitations
Keep prompts explicit about limitations
Always include instructions for what the agent should do when the Knowledge Base does not contain relevant information. This prevents the LLM from falling back to general knowledge.
Related resources
Patterns overview
All available AI patterns
Node types
AI node type reference including Custom Agent
Knowledge Base integration
Create and manage Knowledge Bases
Mortgage advisor tutorial
Full tutorial using this pattern

