Knowledge Base (RAG)

Teach your AI agent about your product, documentation, or domain-specific knowledge using Retrieval Augmented Generation (RAG).

What is RAG?

RAG (Retrieval Augmented Generation) allows the AI to search your custom documentation and include relevant information in its responses.

Without RAG:

  • User: “How do I reset my password?”
  • AI: “I don’t have specific information about your password reset process.”

With RAG (after adding your docs):

  • User: “How do I reset my password?”
  • AI: “To reset your password, go to Settings → Account → Reset Password. You’ll receive a reset link via email within 5 minutes.”

How It Works

  1. Add URLs - You provide documentation URLs in the dashboard
  2. Content Extraction - InAppAI fetches and processes the content
  3. Vector Embeddings - Content is converted to searchable vectors
  4. Semantic Search - When users ask questions, relevant sections are found
  5. Context Injection - Relevant docs are added to the AI’s context
  6. Enhanced Response - AI answers using your documentation

Adding Documentation

Dashboard Interface

  1. Go to app.inappai.com
  2. Navigate to Knowledge Base
  3. Click Add URL
  4. Enter the documentation URL
  5. (Optional) Add a title and category
  6. Click Save

Supported Content

InAppAI can extract content from:

  • Documentation sites - GitBook, ReadTheDocs, Hugo, Docusaurus
  • Blog posts - Medium, WordPress, Ghost
  • HTML pages - Any public webpage
  • Markdown files - GitHub READMEs, wiki pages

Note: The URL must be publicly accessible (not behind authentication).

URL Examples

Good URLs:

https://docs.yourapp.com/getting-started
https://yourblog.com/how-to-use-our-api
https://github.com/yourorg/project/blob/main/README.md
https://help.yourapp.com/billing

Not Supported:

https://app.yoursite.com/admin/docs  (requires login)
file:///local/docs.html  (not public)
https://yoursite.com/video-tutorial  (video, not text)

Content Indexing

How Pages Are Split

Long documentation pages are automatically split into sections for better search accuracy:

  • Each section is ~1,000 characters
  • Sections maintain context (titles, headings)
  • Overlapping content ensures continuity

Example: A 10,000-character page becomes ~10 searchable sections.

Indexing Process

When you add a URL:

  1. Fetch - Content is downloaded from the URL
  2. Parse - HTML is converted to plain text
  3. Split - Text is divided into sections
  4. Embed - Each section is converted to a vector embedding
  5. Store - Vectors are saved with metadata
  6. Cache - Results are cached for fast retrieval

This process typically takes 5-30 seconds per URL.

Search and Retrieval

InAppAI uses semantic search, not keyword matching:

  • Understands meaning, not just exact words
  • Finds relevant content even with different phrasing
  • Ranks results by similarity

Example:

  • User asks: “How much does it cost?”
  • Matches documentation about: “Pricing”, “Plans”, “Billing”

Search Threshold

The threshold determines how similar content must be to be included:

  • 0.7 (default) - Moderately similar content
  • 0.8 - More selective, higher similarity required
  • 0.6 - More permissive, includes loosely related content

Configure in dashboard: Knowledge BaseSettingsSearch Threshold

Maximum Results

Control how many documentation sections are included in each response:

  • Default: 5 sections
  • Range: 1-10 sections

More sections = more context but higher latency and cost.

Configure in dashboard: Knowledge BaseSettingsMax Results

Managing Your Knowledge Base

Viewing Indexed URLs

See all added documentation:

  1. Go to Knowledge BaseURLs
  2. View list with:
    • URL
    • Document title
    • Section count (number of chunks)
    • Last updated timestamp

Refreshing Content

Update existing documentation when it changes:

  1. Find the URL in Knowledge BaseURLs
  2. Click Refresh icon
  3. Content is re-fetched and re-indexed

When to refresh:

  • Documentation has been updated
  • Page content has changed
  • Fixing outdated information

Deleting URLs

Remove documentation from the knowledge base:

  1. Find the URL in Knowledge BaseURLs
  2. Click Delete icon
  3. Confirm deletion

All sections from that URL are immediately removed.

Testing Your Knowledge Base

Test Search Feature

Verify your documentation is working:

  1. Go to Knowledge BaseTest Search
  2. Enter a test query (e.g., “How do I authenticate?”)
  3. Adjust threshold and limit
  4. Click Search

Results show:

  • Similarity score - How well content matches (0.0-1.0)
  • Content preview - Text snippet
  • Metadata - Document title, URL, section
  • Included? - Whether it exceeds threshold

Example:

Query: "password reset"
Threshold: 0.7

Results:
✅ 0.89 - "To reset your password..." (Account Settings)
✅ 0.82 - "Forgotten passwords can be..." (FAQ)
❌ 0.65 - "Change your username..." (Profile) - below threshold

Testing in Chat

Test knowledge base in actual conversation:

  1. Open your React app with InAppAI component
  2. Ask a question related to your documentation
  3. Check if AI includes information from your docs

Example:

  • User: “What payment methods do you accept?”
  • AI: “We accept Visa, MasterCard, American Express, and PayPal. You can manage payment methods in Billing → Payment Methods.” (sourced from your docs)

Statistics

Usage Limits

Knowledge base limits vary by plan:

PlanURL Limit
Developer10 KB URLs
Startup100 KB URLs
ScaleUp200 KB URLs

What counts as 1 KB URL?

  • Each unique URL you add
  • Example: Adding 5 documentation pages = 5 KB URLs

Current Usage

View in dashboard: Knowledge BaseStats

  • Total URLs indexed
  • Total sections (chunks)
  • Storage used
  • Cache size

Best Practices

1. Start Small

Add your most important documentation first:

✅ Priority 1: Getting Started, FAQ, Common Issues
✅ Priority 2: API Reference, Feature Guides
✅ Priority 3: Advanced Topics, Edge Cases

2. Use Clear Titles

Help the AI understand context:

❌ "Page 1", "Doc2"
✅ "Getting Started Guide", "API Authentication", "Billing FAQ"

3. Keep Content Updated

Refresh documentation when it changes:

  • Set reminders to refresh monthly
  • Update after major product changes
  • Remove outdated content

4. Test Your Queries

Use Test Search to verify:

  • Documentation is indexed correctly
  • Relevant content is found
  • Threshold is appropriate

5. Monitor Performance

If AI isn’t using your docs:

  • Lower the threshold (try 0.6)
  • Add more URLs covering the topic
  • Improve documentation clarity
  • Use Test Search to debug

Advanced Features

Categories and Tags

Organize documentation (coming soon):

Category: API Documentation
Tags: authentication, REST, OAuth

Category: User Guides
Tags: getting-started, tutorial

Custom Embeddings

Currently uses OpenAI’s text-embedding-3-small model. Custom embedding models coming soon.

Batch Import

Add multiple URLs at once:

  1. Go to Knowledge BaseBatch Import
  2. Upload CSV file with URLs
  3. Map columns (URL, Title, Category)
  4. Click Import

CSV format:

url,title,category
https://docs.example.com/api,API Docs,documentation
https://docs.example.com/faq,FAQ,support

Troubleshooting

“Failed to fetch URL”

Problem: URL cannot be accessed

Solutions:

  1. Verify URL is publicly accessible
  2. Check for typos in URL
  3. Ensure page doesn’t require authentication
  4. Try accessing URL in incognito browser

“No content found”

Problem: Page exists but no text extracted

Solutions:

  1. Page might be JavaScript-rendered (not supported yet)
  2. Content might be in images (not extracted)
  3. Page might be PDF (add PDF URL directly if text-based)

“AI not using my docs”

Problem: Knowledge base exists but AI doesn’t reference it

Solutions:

  1. Use Test Search to verify content is indexed
  2. Lower search threshold (try 0.6)
  3. Ask questions more similar to documentation language
  4. Add more comprehensive documentation
  5. Check that documentation is relevant to the question

“Too many sections”

Problem: Hit URL limit for your plan

Solutions:

  1. Remove outdated or low-value URLs
  2. Combine related pages into single comprehensive pages
  3. Upgrade to higher plan for more URLs

API Reference

Add URL

POST /api/:agentId/kb/urls
Authorization: Bearer <firebase-auth-token>
Content-Type: application/json

{
  "url": "https://docs.example.com/guide",
  "documentTitle": "User Guide",
  "category": "documentation",
  "tags": ["getting-started", "tutorial"]
}

List URLs

GET /api/:agentId/kb/urls
Authorization: Bearer <firebase-auth-token>

Refresh URL

POST /api/:agentId/kb/urls/refresh
Authorization: Bearer <firebase-auth-token>
Content-Type: application/json

{
  "url": "https://docs.example.com/guide"
}

Delete URL

DELETE /api/:agentId/kb/urls
Authorization: Bearer <firebase-auth-token>
Content-Type: application/json

{
  "url": "https://docs.example.com/guide"
}
POST /api/:agentId/kb/test-search
Authorization: Bearer <firebase-auth-token>
Content-Type: application/json

{
  "query": "How to authenticate?",
  "limit": 5,
  "threshold": 0.7
}

Note: All KB management endpoints require Firebase authentication token (admin access).

Next Steps

Need Help?