Knowledge Base & RAG
RAG (Retrieval Augmented Generation) enables your AI agents to access and retrieve information from your organization’s knowledge base during conversations. This allows agents to provide accurate, up-to-date responses based on your company’s documentation, FAQs, policies, and other content.Overview
What is RAG?
RAG combines the power of large language models with your organization’s specific knowledge:- Document Storage: Upload your documents in MD format to knowledge bases
- Automatic Indexing: Documents are processed and indexed for semantic search
- Real-time Retrieval: During conversations, relevant content is retrieved based on user queries
- Context-aware Responses: The agent uses retrieved content to provide accurate answers
When to Use RAG
Ideal Use Cases:- Customer support with product documentation
- Internal helpdesk with company policies
- Sales agents with pricing and product information
- Healthcare with protocol and procedure guides
- Legal assistants with contract templates and regulations
- Reduce hallucinations by grounding responses in actual documents
- Keep information current without retraining models
- Provide source-backed answers for compliance
- Scale knowledge across multiple agents
Architecture
Configuration
Step 1: Create a Knowledge Base
First, create a knowledge base to store your documents:- Via Dashboard
- Via API
- Navigate to Knowledge Bases in the sidebar
- Click Create Knowledge Base
- Enter a name and optional description
-
Click Create
Step 2: Upload Documents
Add documents to your knowledge base:- Via Dashboard
- Via API
- Open your knowledge base
- Click Upload Documents
- Select files (only MD format supported)
- Wait for processing to complete (status: “Indexed”)
Step 3: Link Knowledge Base to Agent
Enable RAG on your agent and link the knowledge base:- Via Dashboard
- Via API
- Open your agent configuration
- Navigate to Features tab
- Enable RAG / Knowledge Base
- Select the knowledge base(s) to link
- Save your agent
Schema Reference
RAGFeature
Configuration for the RAG/Knowledge Base feature on an agent.| Property | Type | Default | Description |
|---|---|---|---|
version | "v1" | null | "v1" | Schema version |
isEnabled | boolean | null | false | Whether RAG is enabled for this agent |
kbLinks | Array<KBLink> | [] (required) | Links to knowledge bases the agent can query |
KBLink
A reference to a knowledge base.| Property | Type | Constraints | Description |
|---|---|---|---|
id | string | minLength: 1, maxLength: 255 | Knowledge base identifier |
KnowledgeBaseInfo
Full knowledge base information returned by API.| Property | Type | Description |
|---|---|---|
id | string (UUID) | Unique knowledge base identifier |
customerId | string (UUID) | Organization identifier |
name | string | Knowledge base name |
description | string | Optional description |
type | "Files" | Knowledge base type |
createdAt | string (ISO 8601) | Creation timestamp |
updatedAt | string (ISO 8601) | Last update timestamp |
status | KnowledgeBaseStatus | Current status |
statistics | KnowledgeBaseStatistics | Document processing statistics |
KnowledgeBaseStatus
DocumentStatus
API Endpoints
Knowledge Base Management
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/rag/kb | Create a knowledge base |
GET | /api/v1/rag/kb | List knowledge bases |
GET | /api/v1/rag/kb/{id} | Get knowledge base details |
PUT | /api/v1/rag/kb/{id} | Update knowledge base |
DELETE | /api/v1/rag/kb/{id} | Delete knowledge base |
Document Management
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/rag/kb/{id}/documents | Upload document |
GET | /api/v1/rag/kb/{id}/documents | List documents |
GET | /api/v1/rag/kb/{id}/documents/{docId} | Get document details |
DELETE | /api/v1/rag/kb/{id}/documents/{docId} | Delete document |
Search
| Method | Endpoint | Description |
|---|---|---|
POST | /api/v1/rag/search | Search across knowledge bases |
Examples
Complete Agent Configuration with RAG
Linking Multiple Knowledge Bases
Link different knowledge bases for different purposes:Searching Knowledge Base Programmatically
Test your knowledge base with direct search:Best Practices
Document Preparation
1. Structure Your Content- Use clear headings and sections
- Include relevant keywords
- Keep paragraphs focused on single topics
- Use consistent terminology
- Remove outdated information before uploading
- Ensure accuracy of all content
- Include common variations of terminology
- Add context for acronyms and technical terms
Knowledge Base Organization
1. Separate by Domain- Regularly review and update documents
- Remove outdated versions
- Track document status for processing failures
- Test searches with common customer queries
- Verify retrieval accuracy
- Adjust content based on results
System Prompt Integration
1. Reference the Knowledge BaseTroubleshooting
Documents Not Indexing
Symptoms:- Documents stuck in “Processing” status
- Documents showing “Failed” status
- Check document format is supported (MarkDown)
- Ensure file size is within limits
- Verify document content is extractable
- Check for special characters or encoding issues
- Re-upload the document if processing failed
Agent Not Using Knowledge Base
Symptoms:- Agent doesn’t reference KB content
- Responses seem generic or incorrect
- Verify RAG is enabled (
isEnabled: true) - Check knowledge base links are correct
- Ensure documents are in “Indexed” status
- Test search directly via API
- Improve system prompt to explicitly mention KB usage
Poor Search Results
Symptoms:- Irrelevant content retrieved
- Missing expected results
- Review document content structure
- Add more context and keywords to documents
- Adjust
minScorethreshold if too high - Increase
maxResultsfor broader coverage - Test different query phrasings
Slow Responses
Symptoms:- Long delays before agent responds
- Timeout errors
- Reduce
maxResultsin search configuration - Optimize document count per knowledge base
- Split large knowledge bases by topic
- Check network latency to API
Limitations
- File Size: Individual documents have size limits
- Processing Time: Large documents may take longer to index
- Format Support: Limited to MD format
- Query Length: Search queries have character limits
- Results Count: Maximum results per search is limited
Next Steps
Now that you understand RAG and Knowledge Base:- Create Your First KB: Start with a small set of core documents
- Test Retrieval: Use the search API to verify content is accessible
- Configure Agent: Link KB and update system prompt
- Monitor Performance: Track usage and accuracy
- Iterate: Add documents and refine based on real conversations
Related Documentation
- Agent Basics - Core agent configuration
- LLM Configuration - System prompt best practices
- Advanced Features - Other agent features
- Webhooks - Capture call results