Documentation:RAG Knowledge Base

RAG Knowledge Base & Semantic Grounding

The intelligence center powering NotifyIQ's AI auto-replies. Ingest company policies, FAQs, and product sheets into 768-dimensional Google Gemini vector embeddings, index them in MongoDB Vector Search, and guarantee strictly grounded WhatsApp customer responses.

1. Purpose of the Page

Retrieval-Augmented Generation (RAG) ensures that AI auto-replies in WhatsApp are 100% accurate, factual, and strictly bounded by your company's verified documentation. The Knowledge Base interface provides tools to upload text and documents (PDF, DOCX, CSV, TXT), automatically split them into 500-token chunks, compute semantic embeddings, and test retrieval in an interactive playground before deploying to production customer chats.

2. Who Uses It (Target Roles)

Customer Support Architects

Uploads operating procedures, troubleshooting checklists, and returns/warranty policies.

Product & Sales Operations

Maintains pricing schedules, feature matrices, and product catalogs for instant bot quoting.

AI Engineers & QA Leads

Evaluates cosine similarity confidence scores and inspects source citations in the Playground.

Interactive Visual Preview

KnowledgeBasePage.tsx • /knowledge-base
768-dim Vectors
Enterprise Knowledge Repository
Embedding Engine: gemini-embedding-001 • 8 Indexed Docs
Upload DocumentsRAG Query Playground
Ingest Document or Policy
📄
Drag & drop file or browse
Supports PDF, DOCX, TXT, CSV, JSON (Auto 500-token chunks)
Vectorize & Index
Playground Semantic Query TestConfidence: 94.2%
Query:“What is the refund timeline if a client cancels?”
Grounded AI Synthesis

Clients can receive a full refund if the cancellation request is submitted within 14 calendar days of plan activation. Refunds are processed back to the original payment method within 5-7 business days.

Source:Enterprise Cancellation Policy 2026.pdf (Chunk #2)

3. Step-by-Step: Adding and Testing Knowledge

  1. Upload Knowledge Documents: Go to the Upload Documents tab. Either drag in a file (.pdf, .docx, .txt, .csv) or paste raw text with a descriptive document title.
  2. Automatic Token Chunking: NotifyIQ automatically breaks documents into 500-token chunks with 50-token semantic overlap. This prevents context fragmentation across sentences.
  3. Vector Embedding Generation: The backend sends text chunks to Google Gemini API (models/embedding-001), creating 768-dimension dense vector arrays saved to MongoDB with vector index markers.
  4. Run Playground Verification Queries: Switch to the RAG Query Playground tab. Enter typical customer questions (e.g. “How do I configure my webhook?”) and verify that the AI cites the correct source document and displays high confidence (>85%).
  5. Manage & Prune Documents: View all active indexed documents in the repository table. When company policies update, delete outdated versions to prevent contradictory answers.

4. Controls, Endpoints & Vector Specifications

Feature / ParameterAPI RouteSpecificationDescription
Index DocumentPOST /api/ai/knowledgetitle, content, fileTypeSplits raw text into 500-token chunks and computes Gemini 768-dim embeddings.
Delete DocumentDELETE /api/ai/knowledge/:iddocIdPurges all chunk embeddings associated with the specified document from MongoDB.
RAG Playground QueryPOST /api/ai/queryquery: stringExecutes vector cosine search and generates grounded synthesized text with citations.
Embedding ModelGoogle Gemini APIgemini-embedding-001 (768d)Generates dense semantic vector representations for similarity ranking.

5. Behind the Scenes: Real-Time RAG Auto-Reply Pipeline

When a customer sends a WhatsApp message while the AI bot is enabled, the backend executes the following RAG sequence:

  • Query Vectorization: The inbound message text is vectorized in real time using gemini-embedding-001.
  • MongoDB Atlas Vector Search: An approximate nearest neighbor (ANN) search retrieves the top 3 most relevant document chunks based on cosine distance.
  • Grounded Generation: Retrieved chunks are injected into the Gemini system prompt: “You are a WhatsApp customer care agent for NotifyIQ. Only answer questions using the provided context chunks. If the answer is not in the context, politely state that you will connect them with a human agent.”
  • WhatsApp Delivery: The synthesized message is dispatched via Meta Graph API v20.0 with delivery receipts logged.

6. Common Errors & FAQs

Why does the AI say “I don't have enough information”?

NotifyIQ strictly prevents AI hallucination. If the customer's question cannot be matched with high cosine confidence against your indexed documents, the bot will decline to speculate and offer human agent handoff.

How many documents can I upload?

There is no arbitrary document count limit. Storage and token usage are calculated based on your workspace billing tier and wholesale token consumption.