Knowledge Base Overview
The knowledge base stores company policies, shipping information, and FAQs that the AI chatbot uses to answer customer questions beyond product catalog queries.Knowledge base entries support RAG (Retrieval Augmented Generation) for semantic search.
Database Schema
Knowledge entries are stored in theknowledge_base table:
Schema
API Endpoints
GET /api/admin/knowledge
Fetch all knowledge base entries. Request:The embedding vector is excluded from the response to save bandwidth (query uses
SELECT without embedding field).POST /api/admin/knowledge
Add a new knowledge base entry. Request:Create Entry (knowledge.js:26-40)
DELETE /api/admin/knowledge
Remove a knowledge base entry. Request:Adding Knowledge via Admin Panel
While there’s no dedicated UI yet, you can add entries programmatically:Prepare Content
Write clear, concise answers to common questions:
- Shipping times by city
- Payment methods accepted
- Return/exchange policies
- Product usage instructions
- Contact information
Content Guidelines
Writing Effective Knowledge Entries
Use Clear, Direct Language
Use Clear, Direct Language
Good: “Manejamos contra entrega (COD) en Bogotá, Medellín y Cali.”Bad: “Bueno, pues, como que aceptamos COD en algunas ciudades grandes, depende…”
Include Specific Details
Include Specific Details
Good: “Envíos a Bogotá: 1-2 días. Medellín: 2-3 días. Otras ciudades: 3-5 días.”Bad: “Los envíos tardan un tiempo razonable dependiendo de la ciudad.”
Avoid Ambiguity
Avoid Ambiguity
Good: “Costo de envío: 12.000 en otras ciudades.”Bad: “El envío cuesta algo así como 8 mil o más o menos dependiendo.”
Update Regularly
Update Regularly
Review and update knowledge entries monthly to reflect:
- New shipping zones
- Updated pricing
- New payment methods
- Changed policies
Metadata Types
Use consistent metadata for organization:| Type | Use Case | Example Title |
|---|---|---|
| FAQ | Common questions | ”¿Cuánto tarda el envío?” |
| Política | Company policies | ”Política de Devoluciones” |
| Producto | Product care instructions | ”Cómo usar aceites esenciales” |
| Contacto | Support info | ”Horarios de Atención” |
| Promoción | Current offers | ”Descuento Black Friday” |
AI Integration
The chatbot uses thesearchKnowledgeBase tool to query knowledge:
Current Status (Disabled)
Placeholder Response (Retriever.js:107-113)
Implementing Vector Search
To enable semantic search:Best Practices
Chunk Long Content
Split long policies into multiple entries (max 500 words each) for better retrieval.
Use Keywords
Include common customer phrases in content: “envío gratis”, “contra entrega”, “devolución”.
Test AI Responses
After adding knowledge, test chatbot with related questions to verify retrieval.
Version Control
Keep a backup/changelog of policy updates to track what changed and when.
Example Knowledge Entries
Shipping Policy
Payment Methods
Returns Policy
Product Care
Troubleshooting
Entry Not Created
Symptom: POST returns error or no ID. Solutions:- Check
contentfield is not empty - Verify auth token is valid
- Check database connection
- Review backend logs for Prisma errors
AI Not Using Knowledge
Symptom: Bot doesn’t reference policies in answers. Solutions:- Confirm
searchKnowledgeBasetool is enabled (currently disabled) - Check knowledge content matches customer question keywords
- Verify embeddings are generated and stored
- Test similarity search query directly
Duplicate Content
Symptom: Multiple similar entries returned. Solutions:- Delete redundant entries using DELETE endpoint
- Consolidate similar topics into single comprehensive entry
- Use metadata types to organize content
Next Steps
Chatbot Management
Configure AI assistant behavior
Admin Portal
Access knowledge management endpoints