System Prompt Configuration
The system prompt controls how the AI uses your documents. Configure it in the visual dashboard to customize AI behavior.
Critical Requirement
{{context}} exactly. Without it, RAG will not work.Prompt Structure
The system prompt is divided into three parts:
1. Pre-Context
Global instructions, tone, guardrails, and format guidelines that appear before the document context.
You are a helpful AI assistant.
Be professional and concise.
Use bullet points when appropriate.2. Context (Required)
The {{context}} placeholder where retrieved document chunks are automatically injected at runtime.
Context:
{{context}}
Use the context above to answer questions.{{context}} must appear in your prompt. Do not modify, encode, or remove it.3. Post-Context
Follow-up rules that tell the AI how to cite documents, refuse out-of-scope queries, and format answers.
If you can't find the answer in the context, say so.
Always cite document sources when possible.
Format code blocks with proper syntax highlighting.Pre-configured Templates
ChatRAG includes ready-to-use templates optimized for different use cases. All templates include the required {{context}} placeholder.
Helpful
General-purpose, friendly assistant tone
Professional
Formal business communication style
Educational
Explanatory teaching approach
Technical
Detailed technical documentation style
ChatRAG Sales
Product-focused sales assistance
Customer Support
Empathetic support agent tone
Research Assistant
Academic research and analysis
Code Assistant
Programming help and code examples
Legal Analyst
Legal document analysis
Medical Information
Healthcare information provider
WhatsApp Conversational
Concise, mobile-optimized responses
Best Practices
Keep Pre-Context Concise
Be explicit about how to use the Context. Avoid overly long instructions.
Instruct Citation Behavior
In Post-Context, tell the AI to cite or reference documents and how to respond when answers aren't found.
Optimize for WhatsApp
If using WhatsApp, start with the whatsappConversational template and keep responses brief.
Test Before Deploying
Use the preview feature in the Config UI to test your prompt with sample queries.
Include Guardrails
Add instructions about what the AI should NOT do or answer.
Saving & Applying
To apply your system prompt configuration:
- Open the Config UI at
http://localhost:3333 - Navigate to the System Prompt section
- Choose a template or write a custom prompt
- Ensure
{{context}}is present - Click Save
- Restart the dev server to guarantee the latest .env.local is loaded:
# In your dev terminal:
Ctrl+C
npm run devTroubleshooting
Documents found but not used
Solution: Verify {{context}} is present and unencoded in your prompt.
Use scripts/rag/decode-rag-prompt.js to check what's stored in .env.local.
AI ignoring instructions
Solution: Make instructions more explicit and direct. Place critical instructions in both Pre-Context and Post-Context for emphasis.
Responses too long or too short
Solution: Add length guidelines like "Keep responses under 3 sentences" or "Provide detailed explanations with examples."
AI Translation Support
The Config UI includes translation tools to help you create multilingual prompts:
- Select your desired target language from the dropdown
- Click "Translate with AI" button
- Review the translated prompt
- Make any necessary adjustments
- Save the translated version
{{context}} placeholder is automatically preserved during translation.Example Complete Prompt
You are a helpful AI assistant. Be concise and professional.
Context:
{{context}}
Based on the context provided above, answer the user's question.
If you cannot find the answer in the context, say so clearly.
Always cite sources when referencing specific information.