Custom Script Training
Overview
Custom Script Training allows the AI agent to fetch and process data dynamically using custom scripts instead of uploading static documents or URLs.
This method is useful when knowledge needs to be retrieved from external APIs, databases, or dynamic data sources.
The script processes the data and returns it in JSON format, which is then indexed by the AI system for retrieval.
Custom Script Data Sources
Inside Custom Script training, you can configure different data sources: Custom scripts can be used for two main purposes:
- RAG (Custom Data Indexing)RAG Script Setup – Retrieve responses using trained documents.
- MongoDB Search Custom ScriptMongo DB Script Setup – Fetch data dynamically from MongoDB.
When to Use RAG vs MongoDB
Custom scripts can be used for two different purposes depending on how the data needs to be used by the AI system.
- RAG Indexing is used when the AI needs to perform semantic search and retrieve contextual answers from large text data.
- MongoDB Storage is used when the system needs to store structured data and retrieve it using APIs or exact field queries.
The table below explains the key differences.
RAG Indexing | MongoDB Storage |
|---|---|
Uses page_content | Uses data_to_save |
Used for semantic AI search | Used for structured database retrieval |
Data is converted into embeddings | Data is stored as JSON documents |
Best for FAQs, documents, websites, knowledge bases | Best for product data, tours, doctors, catalog data |
AI retrieves answers based on context similarity | Data retrieved using API queries or filters |
Optimized for natural language queries | Optimized for exact field lookup |
Supports vector search | Supports database queries and integrations |
Quick Guideline
Use RAG Indexing when:
- The AI must answer questions from documents, websites, FAQs, or large text content.
- The user asks questions in natural language.
- Context-based retrieval is required.
Use MongoDB Storage when:
- The data is structured records (tours, doctors, products, bookings).
- The system needs to retrieve specific fields or filtered data.
- The data will be accessed through backend APIs or system queries.