RAG Embed
Embed Knowledge Base in Your App
End Static Docs. Initiate AI-Driven Intelligence.
GTWY’s RAG Knowledge Base lets you embed a complete AI-driven document system directly inside your application. Your users can upload files, browse documents, and retrieve information instantly — all without switching tabs or relying on external tools.
The embedded widget integrates seamlessly with your product UI while enabling powerful AI-driven document retrieval using GTWY’s Retrieval-Augmented Generation (RAG) system.
It is lightweight, secure, customizable, and designed to work naturally within your existing interface.
Why Embed a Knowledge Base?
Embedding a Knowledge Base transforms how users interact with information.
Instead of relying on static FAQs or lengthy documentation pages, users can interact with their documents dynamically.
With the GTWY RAG embed, users can:
Upload and manage files such as PDFs, reports, or internal documents
View and organize uploaded knowledge base files
Search and retrieve information instantly
Interact with documents directly inside your application
Whether you're building a SaaS platform, internal dashboard, or customer support portal, embedding the knowledge base provides faster and smarter access to critical information.
How to Configure RAG Embed
Step 1: Connect Your Knowledge Base
To begin, connect your application to your GTWY Knowledge Base using your organization details.
Example configuration:
org_id = 55592
folder_id = "6971b714f60dd5bf64ed42a6"
user_id = "unique_user_id"Field Explanation
org_id
Your GTWY organization’s unique identifier.
folder_id
The folder where the knowledge base documents will be stored.
user_id
A unique identifier for the user accessing the embedded knowledge base.
This can be an email, UUID, or internal user ID.
After defining these values, generate an Embed Token (JWT) using your GTWY access key.
NOTE:
Sign the JWT using the HS256 algorithm.
Use the access key exactly as provided (no encoding or modification required).

This token authenticates the embedded instance and securely connects it to your organization.
Step 2: Embed the Script
Once the embed token is generated, add the following script to your application where you want the Knowledge Base interface to appear.
<script
id="rag-main-script"
embedToken="ENTER_EMBED_TOKEN"
src="https://chatbot.gtwy.ai/rag-prod.js"
parentId="ID_OF_PARENT_CONTAINER"
theme="dark/light"
defaultOpen="true/false"
></script>
Script Parameters Explained
Parameter | Description |
|---|---|
id | Must always be |
embedToken | JWT token generated using your org credentials |
src | GTWY RAG embed script source |
parentId | The HTML container ID where the widget will render |
theme | Choose between |
defaultOpen | Set to |
This script loads the complete RAG interface and attaches it to your application container.
Step 3: Control the RAG Widget
GTWY also provides built-in JavaScript functions to control the embedded Knowledge Base programmatically.
Open Add Document Modal
window.openRag()
This opens the Add Document modal, allowing users to upload new knowledge base files.
Close Add Document Modal
window.closeRag()
Closes the document upload modal.
Show Uploaded Documents
window.showDocuments()
Displays the full list of documents stored in the connected knowledge base folder.
Example Integration Workflow
A typical integration flow looks like this:
Generate a JWT embed token using your org credentials.
Insert the RAG embed script into your application.
Define a container where the widget will render.
Use JavaScript functions to trigger document uploads or display document lists.
Allow users to interact with the knowledge base directly inside your product.
This setup enables a seamless knowledge experience without redirecting users to external platforms.
Example Use Cases
SaaS Platforms
Embed searchable AI documentation directly within your product interface.
Internal Teams
Provide employees instant access to SOPs, manuals, or internal documentation.
Customer Support Portals
Allow users to upload documents and retrieve information quickly through an AI-powered knowledge system.
Wherever information exists, GTWY makes it accessible and actionable.
Security and Access
Security is built directly into the RAG embed architecture.
The system uses JWT-based embed tokens to ensure secure access.
This guarantees that:
Only authenticated users can access the knowledge base
Each interaction is tied to a specific org_id, folder_id, and user_id
Tokens remain protected and should never be exposed in public client code
This architecture allows real-time AI-driven knowledge retrieval with enterprise-grade security.
Final Thoughts
Embedding GTWY’s RAG Knowledge Base turns your product into a smart document intelligence system.
With just a few lines of code, your users can:
Upload and manage knowledge base documents
View document lists directly inside your app
Access AI-powered information retrieval
Interact with knowledge without leaving your platform
Your application doesn’t just store documents anymore.
It understands them.