Create a support bot that learns from your documentation:
characters/support-bot.ts
import { type Character } from '@elizaos/core';export const supportBot: Character = { name: 'SupportBot', plugins: [ '@elizaos/plugin-openai', // Required for embeddings '@elizaos/plugin-knowledge', // Add knowledge capabilities ], system: 'You are a friendly customer support agent. Answer questions using the support documentation you have learned. Always search your knowledge base before responding.', bio: [ 'Expert in product features and troubleshooting', 'Answers based on official documentation', 'Always polite and helpful', ],};
Setup your support docs:
your-project/├── docs/ # Create this folder│ ├── product-manual.pdf # Your actual product docs│ ├── troubleshooting-guide.md # Support procedures│ ├── faq.txt # Common questions│ └── policies/ # Organize with subfolders│ ├── refund-policy.pdf│ └── terms-of-service.md├── .env│ OPENAI_API_KEY=sk-...│ LOAD_DOCS_ON_STARTUP=true # Auto-load all docs└── src/ └── character.ts
export const apiAssistant: Character = { name: 'APIHelper', plugins: [ '@elizaos/plugin-openai', '@elizaos/plugin-knowledge', ], system: 'You are a technical documentation assistant. Help developers by searching your knowledge base for API documentation, code examples, and best practices.', topics: [ 'API endpoints and methods', 'Authentication and security', 'Code examples and best practices', 'Error handling and debugging', ],};
{ "name": "InfoBot", "plugins": [ "@elizaos/plugin-openai", "@elizaos/plugin-knowledge" ], "knowledge": [ "Our office is located at 123 Main St", "Business hours: 9 AM to 5 PM EST", "Contact: support@example.com" ], "system": "You are a simple information bot. Answer questions using your basic knowledge."}
Note: The knowledge array is only for tiny snippets. For real documents, use the docs folder!
# Required: Your AI providerOPENAI_API_KEY=sk-...# Auto-load documents on startupLOAD_DOCS_ON_STARTUP=true# Optional: Custom docs path (default is ./docs)KNOWLEDGE_PATH=/path/to/your/documents
When users ask questions, the agent automatically:
// User asks: "What's your refund policy?"// Agent automatically:// 1. Searches knowledge base for "refund policy"// 2. Finds relevant chunks from refund-policy.pdf// 3. Uses this information to answer// User asks: "How do I install the software?"// Agent automatically:// 1. Searches for "install software"// 2. Finds installation-guide.pdf content// 3. Provides step-by-step instructions
The knowledge plugin includes a provider that automatically injects relevant knowledge into the agent’s context:
// This happens behind the scenes:// 1. User sends message// 2. Knowledge provider searches for relevant info// 3. Found knowledge is added to agent's context// 4. Agent generates response using this knowledge
# AI ConfigurationOPENAI_API_KEY=sk-...# Knowledge ConfigurationLOAD_DOCS_ON_STARTUP=trueKNOWLEDGE_PATH=/var/app/support-docs# Optional: For better processingCTX_KNOWLEDGE_ENABLED=trueOPENROUTER_API_KEY=sk-or-... # For enhanced context