Skip to main content
Skip to main contentSkip to navigation
Back to Guides

Upload Your Knowledge Base

Learn how to upload PDFs and documents to train your chatbot with your specific knowledge.

Step-by-Step Guide

Step 1: Access Knowledge Base Settings

Navigate to your chatbot editor and find the Knowledge Base section.

Step 2: Prepare Your Documents

Ensure your files are in supported formats (PDF, DOCX, TXT, CSV) and under 10MB each.

Step 3: Upload Files

Drag and drop your files or click to browse and select multiple files.

Practical Example:

// Upload file via JavaScript
const formData = new FormData();
formData.append('file', selectedFile);
formData.append('chatbotId', 'your-chatbot-id');

fetch('/api/knowledge-base/upload', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`
  },
  body: formData
})
.then(response => response.json())
.then(result => console.log('Upload successful:', result))
.catch(error => console.error('Upload failed:', error));

See our code examples for complete upload implementations.

Step 4: Process and Train

Wait for the AI to process your documents and create searchable knowledge.

Processing Time:

  • • Small files (TXT): ~30 seconds
  • • Medium files (DOCX): ~2-3 minutes
  • • Large files (PDF): ~5-10 minutes
  • • Multiple files: Process sequentially

→ Pro tip: Upload files during off-peak hours for faster processing.

Supported File Formats

.PDF

Portable Document Format

.DOCX

Microsoft Word Documents

.TXT

Plain Text Files

.CSV

Comma-Separated Values

File Size Limit

Each file must be under 10MB. For larger documents, consider splitting them into smaller sections.

Best Practices

Content Preparation

  • Use clear, descriptive file names for better organization
  • Include comprehensive content rather than just keywords

📄 Content Optimization Tips:

  • • Use descriptive headings (H1, H2, H3)
  • • Include keywords naturally in content
  • • Add table of contents for long documents
  • • Use bullet points and numbered lists

Maintenance

  • Regularly update your knowledge base with new information
  • Test your chatbot responses after uploading new content

Update Strategy:

// Check processing status periodically
async function checkProcessingStatus(chatbotId) {
  const response = await fetch(`/api/knowledge-base/status/${chatbotId}`);
  const status = await response.json();
  return status.processingComplete;
}

// Monitor and update as needed
setInterval(async () => {
  const isReady = await checkProcessingStatus('your-chatbot-id');
  if (isReady) {
    console.log('Knowledge base updated successfully!');
  }
}, 30000); // Check every 30 seconds

Troubleshooting

Common issues and their solutions with code examples

✗ Upload Failed

Check file size and format. Ensure you're within plan limits.

Solution:
// Validate file before upload function validateFile(file) { const maxSize = 10 * 1024 * 1024; // 10MB const allowedTypes = [ 'application/pdf', 'text/plain', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ]; if (file.size > maxSize) { throw new Error('File too large. Maximum size is 10MB.'); } if (!allowedTypes.includes(file.type)) { throw new Error('Unsupported file type. Use PDF, TXT, or DOCX.'); } return true; }

→ Processing Taking Too Long

Large files may take several minutes. Check processing status.

Status Check:
// Monitor processing progress async function checkProcessing(chatbotId, apiKey) { const response = await fetch(`/api/knowledge-base/status/${chatbotId}`, { headers: { 'Authorization': `Bearer ${apiKey}` } }); const status = await response.json(); console.log(`Processing: ${status.processingStatus}`); console.log(`Complete: ${status.processingComplete}`); return status.processingComplete; }

🤖 Chatbot Not Using New Knowledge

Wait for processing to complete, then test with relevant questions.

Test with API:
// Test if knowledge is available async function testKnowledge(chatbotId, apiKey, question) { const response = await fetch('/api/chat', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ chatbotId, message: question, conversationId: 'test-conversation' }) }); const result = await response.json(); console.log('Chatbot response:', result.message); return result; } // Test with a question from your uploaded content testKnowledge('your-chatbot-id', 'api-key', 'What information is in my uploaded document?');

Rate Limiting Issues

Too many requests. Implement retry with backoff.

Retry Logic:
// Implement exponential backoff async function uploadWithRetry(file, chatbotId, apiKey, maxRetries = 3) { for (let attempt = 1; attempt <= maxRetries; attempt++) { try { // ... upload logic ... return result; } catch (error) { if (error.status === 429 && attempt < maxRetries) { const delay = Math.pow(2, attempt) * 1000; // 2s, 4s, 8s await new Promise(resolve => setTimeout(resolve, delay)); continue; } throw error; } } }

Need More Help?

Check our comprehensive code examples for complete implementations and advanced troubleshooting.

Next Steps

Customize Your Chatbot

Learn how to customize your chatbot's personality and responses.

API Reference

Explore the complete API documentation for advanced integrations.