What Is Retrieval-Augmented Generation (RAG)?
Complete technical guide to vector embeddings, pgvector cosine distance, and tabular chunking.
Follow a customer inquiry through every stage of its lifecycle. From client keystroke to vector embedding, PostgreSQL semantic search, bounded LLM inference, and deterministic tool execution.
When a customer submits a query in an AI customer support chat window, the system executes an automated, coordinated pipeline. Within seconds, it sanitizes inputs, authenticates tenant boundaries, converts text into high-dimensional vector embeddings, queries a vector database for matching documentation, injects factual context into system prompt instructions, and streams clean, verified responses grounded strictly in your content.
Here is the technical execution chain triggered every time a website visitor submits an inquiry:
The standalone embed script (embed.js, under 20 KB) captures the visitor's raw text, adds the active session token and configured data-id, and issues an asynchronous HTTP POST request to the application API endpoint (/api/chat) without blocking the parent website DOM.
The backend API verifies the public bot_id, checks the tenant's monthly message quota (Free: 100 msgs, Basic: 1,000 msgs, Standard: 3,000 msgs), and enforces rate-limiting safeguards to protect against automated scraping or denial-of-service attempts.
The user question is transformed into a dense numerical vector using an embedding model. PostgreSQL executes a tenant-scoped cosine similarity query with pgvector. Any passage with cosine distance exceeding the relevance threshold is discarded, isolating only verified factual paragraphs and Markdown table rows.
The orchestrator constructs the full system prompt payload. Retrieved chunks are labeled with source metadata (such as [Source 1: ReturnPolicy.pdf]). Negative constraints strictly prohibit the language model from extrapolating beyond verified facts.
The model generates responses streamed via Server-Sent Events (SSE). When an e-commerce inquiry is detected, the agent triggers deterministic tool execution (such as querying the Shopify Storefront GraphQL API for live stock counts or order tracking status) to fetch authenticated real-time data.
The chat interface delivers a clean, verified answer grounded in your knowledge base. If the inquiry requires human consultation or specialized pricing, an in-chat scheduling form or contact capture modal appears, sending an instant email alert to the business inbox.
An AI customer support system should never leave high-intent prospective clients or complex inquiries unattended. Knogents provides integrated scheduling and lead handoff:
When an inquiry requires personal consultation, the agent understands natural language date and time requests (such as "Can we talk this Thursday at 2pm?"), performs automated conflict checks, and books the appointment directly in chat.
Whenever a lead submits their contact information or books a consultation, Knogents immediately dispatches an email notification to the business inbox with the visitor's verified details and complete chat transcript.
| Operational Factor | Human Support Teams | Rule-Based Chatbots | Knogents AI Support |
|---|---|---|---|
| Response Speed | Minutes to hours | Instant (rigid menu clicks) | Real-time streaming text |
| Unscripted Questions | Handled with human nuance | Fails ("Did not understand") | Understands semantic intent |
| 24/7 Availability | Requires costly shifts | Always on (limited utility) | 100% automated 24/7 coverage |
| Factual Transparency | Relies on agent memory | Pre-written static text | Strict grounding in source docs |
| Live E-Commerce Actions | Manual dashboard lookup | External redirect links | Native Shopify GraphQL tools |
When an inquiry has no semantically similar chunks in the vector database (cosine distance exceeds the relevance threshold), the system prompt instructs the model to acknowledge that it cannot verify the answer from company documentation. Rather than inventing policies, the agent offers an immediate escalation route, such as collecting the visitor contact details for personal follow-up or scheduling a consultation.
Knogents uses deterministic API tool execution rather than relying on LLM memory. For order status or inventory on supported platforms like Shopify, the model identifies the customer intent and triggers a native Shopify Storefront GraphQL query. It verifies fulfillment tracking with the customer Order Number and Email, returning verified live carrier status.
Instead of waiting for the full response to generate on the server before transmitting, Knogents streams tokens in real time using Server-Sent Events (SSE). The customer sees the first words appear on their screen within hundreds of milliseconds, creating a natural typing experience while the model completes complex reasoning in the background.
All document embeddings and chat sessions are isolated at the database layer. In PostgreSQL with pgvector, every retrieval query enforces tenant bounding using parameters like WHERE bot_id = $2. Data from one organization is never exposed to another, and customer interactions are not used to train public foundation models.
Yes. Knogents includes built-in in-chat consultation and meeting scheduling. The agent recognizes natural language date and time requests, checks for scheduling conflicts against configured business availability, and sends instant email lead notifications with complete chat context to the business inbox.
The client widget is a standalone vanilla JavaScript loader under 20 KB with zero external dependencies. It can be added to any HTML, WordPress, Shopify, Webflow, Wix, Squarespace, or React site. It supports floating corner widgets, embedded inline containers (using div id='rag-inline-bot'), and fullscreen portal views.
Related Architectural Research
Deepen your understanding of retrieval-augmented generation and vector databases.
What Is Retrieval-Augmented Generation (RAG)?
Complete technical guide to vector embeddings, pgvector cosine distance, and tabular chunking.
AI Chatbot vs. Live Chat: Cost, Accuracy & SLA Comparison
Objective comparison of response speed, cost per ticket ($0.03 vs $7.50), and the 80/20 hybrid model.
Understanding LLM APIs: Token Costs, RPM Limits & Latency
Token calculation math, RPM rate throttling, context window management, and latency optimization.
Production Industry Solutions
See how these architectural principles are implemented in production AI agents.
Answer customer inquiries instantly at any hour with verified factual accuracy and zero waiting.
Automated WISMO Order Tracking
Automate Where Is My Order inquiries with Order Number and Email verification on Shopify.
Turn storefront visitors into buyers with 24/7 product advice, stock checks, and checkout assistance.
24/7 STOREFRONT ASSISTANT
Build an AI Agent Grounded in Your Enterprise Knowledge
Index your sitemaps, PDFs, and spreadsheets with header preservation and strict cosine thresholding.