Skip to main content

What Are Knowledge Bases?

Knowledge bases are collections of information that your AI agents can access during conversations. Instead of hardcoding information in instructions, you can upload documents, scrape websites, or provide structured data.

Automatic Context

Relevant information is automatically injected into conversations. No manual retrieval needed.

Multiple Sources

Upload PDFs, scrape websites, or provide structured data. Mix and match sources.

Always Up-to-Date

Update knowledge bases anytime. Changes are immediately available to your agents.

Scalable

Handle thousands of documents. TopCalls automatically manages indexing and retrieval.

How Knowledge Bases Work

1

1. Create Knowledge Base

Upload documents, scrape websites, or provide text. TopCalls indexes the content.
2

2. Attach to Calls

When making a call, include knowledge_base_ids in the request.
3

3. Automatic Retrieval

During the conversation, TopCalls automatically retrieves relevant information from the knowledge base.
4

4. Context Injection

Relevant context is injected into the AI’s prompt, allowing it to answer questions accurately.

Creating Knowledge Bases

From Text

curl -X POST https://api.topcalls.ai/v1/knowledge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "text",
    "name": "Product FAQs",
    "description": "Common questions about our products",
    "text": "Q: What is your return policy?\nA: We offer a 30-day money-back guarantee..."
  }'

From Files

Upload PDFs, TXT, DOCX, or MD files:
curl -X POST https://api.topcalls.ai/v1/knowledge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "type=file" \
  -F "name=Product Manual" \
  -F "file=@manual.pdf"

From Websites

Scrape content from URLs:
curl -X POST https://api.topcalls.ai/v1/knowledge \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "web",
    "name": "Company Website",
    "urls": [
      "https://topcalls.ai/about",
      "https://topcalls.ai/features"
    ]
  }'

Using Knowledge Bases in Calls

Attach knowledge bases when making calls:
{
  "phone_number": "+14155551234",
  "task": "Answer customer questions about our products and services.",
  "knowledge_base_ids": ["kb_xyz789", "kb_abc123"]
}

Example: Customer Support Agent

Step 1: Create Knowledge Base

{
  "type": "text",
  "name": "Support Knowledge Base",
  "text": `
    Product Features:
    - AI Voice Agents
    - Campaign Management
    - Custom Voices
    - Function Calling
    
    Pricing:
    - Starter: $0.10/minute
    - Pro: $0.08/minute
    - Enterprise: Custom
    
    Common Issues:
    - Call not connecting: Check phone number format
    - No audio: Verify microphone permissions
    - Poor quality: Check internet connection
  `
}

Step 2: Use in Calls

{
  "phone_number": "+14155551234",
  "instructions": "You are a customer support agent. Answer questions about our products, pricing, and help troubleshoot issues. Use the knowledge base to provide accurate information.",
  "knowledge_base_ids": ["kb_support_123"]
}

Best Practices

✅ Do This

  • Organize by topic: Create separate knowledge bases for different topics (products, pricing, support)
  • Keep it updated: Regularly update knowledge bases with new information
  • Use clear names: Name knowledge bases descriptively
  • Test thoroughly: Test knowledge base retrieval with sample questions
  • Combine sources: Use multiple knowledge bases for comprehensive coverage

❌ Don’t Do This

  • Too much information: Keep knowledge bases focused and relevant
  • Outdated content: Regularly review and update knowledge bases
  • Vague descriptions: Use clear, specific descriptions
  • Ignore context: Ensure knowledge base content is relevant to the conversation

Knowledge Base Limits

  • File size: Up to 10MB per file
  • Total size: Up to 100MB per knowledge base
  • URLs: Up to 50 URLs per web scrape
  • Text: Up to 1M characters per text knowledge base

Next Steps