System Prompt Configuration

The system prompt controls how the AI uses your documents. Configure it in the visual dashboard to customize AI behavior.

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.

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:

  1. Open the Config UI at http://localhost:3333
  2. Navigate to the System Prompt section
  3. Choose a template or write a custom prompt
  4. Ensure {{context}} is present
  5. Click Save
  6. Restart the dev server to guarantee the latest .env.local is loaded:
# In your dev terminal:
Ctrl+C
npm run dev

Troubleshooting

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:

  1. Select your desired target language from the dropdown
  2. Click "Translate with AI" button
  3. Review the translated prompt
  4. Make any necessary adjustments
  5. Save the translated version