Training: Context & RAG
Give your bot real knowledge from your website, files, and external pages using Retrieval Augmented Generation.
What is RAG?
RAG stands for Retrieval Augmented Generation. Instead of relying on generic AI knowledge, the bot searches your indexed content for the most relevant information before generating each answer.
- Indexing — The plugin analyzes your content (pages, posts, products, PDFs) and converts it into "embeddings" — numerical representations the AI can search.
- Query — When a user asks a question, the system finds the most relevant content chunks.
- Response — The AI generates an answer using those specific chunks as context, staying grounded in your actual content.
How Context Works Now
In this page (wp-admin/admin.php?page=aichat-training-context), the bot is managed with an associated context (knowledge base). The base mode is embeddings from that associated context.
- Associated context — The bot points to one context via
context_id. - Include current page (checkbox) — Enables Auto behavior: embeddings + current page content.
- If checkbox is off — The bot uses embeddings context only.
Important: this screen is focused on context + indexing. Legacy modes like page-only/none can exist internally, but the primary workflow here is associated context with optional current-page inclusion.
Accessing the Context Page
- Go to AxiaChat AI → Training.
- In the Knowledge section, click "Manage Context".
- This opens the Context (Knowledge Base) sub-page.
If you have multiple bots, use the bot selector at the top to switch between them. Each bot can have its own context.
Stats Bar
At the top of the context page, a summary bar shows:
- Number of indexed documents
- Total chunks generated
- Processing status with percentage
Content Sources
The interface now shows 4 source cards where you choose what to index:
1. WordPress (Posts & Pages)
Includes posts and pages, with these options in each subsection:
- None — Don't index this type
- All Posts / All Pages — Index everything published
- Most Recent — Shows latest items with checkboxes
- Search — Type a partial title and select specific items
2. WooCommerce (Products)
Only visible if WooCommerce is active. Same selection options as posts/pages: None, All Products, Most Recent, or Search.
3. PDF / TXT (File Uploads)
Upload documents to include in the knowledge base:
- Drag and drop files into the upload zone, or click to browse
- Files upload automatically — no extra button needed
- Each file shows its own progress bar
- PDF and TXT formats accepted
- The plugin extracts text from PDFs and converts it into indexed chunks
4. Web Pages (External)
Import knowledge from external websites with two methods:
- Import URLs — Paste one URL per line and fetch directly.
- Discover from Website — Crawl from a root URL using depth and max-pages controls.
- Depth — 1 to 3 levels.
- Max pages — 10, 25, 50, 100, or 200.
- Include source URL option — Adds source URL to knowledge so the bot can reference it.
- Review discovered pages, then Select All / Deselect All / Import Selected Pages.
Imported web pages are converted into the same internal pipeline as file uploads (aichat_upload + chunks), then indexed with the rest.
Documents Table
Below the source cards, the "Documents in Context" table shows all currently indexed content:
- Title — Document or post name
- Type — Post, Page, Product, File PDF/TXT, or Web Page
- Chunks — Number of fragments generated
Features: search by title, filter by type, multi-select with checkboxes, "Remove Selected" to delete items, pagination for large sets.
Save & Index
The main "Save & Index" button:
- Saves your source selections and advanced settings
- Creates a new context if none exists
- Assigns the context to the active bot
- Starts batch indexing — a progress panel with real-time log shows each batch/item
If no source item is selected (and no "All" source is active), indexing will not run.
Advanced Settings
Click "Advanced Settings" below the documents table to expand the settings panel:
Context Name
Give your context a descriptive name (e.g., "Main Website" or "Product Catalog"). Useful when managing multiple contexts for different bots.
Storage Type
- Local (your server) — Embeddings stored in your WordPress database.
- Remote (Pinecone) — Requires Remote Type (Pinecone), API Key, and Endpoint URL.
Embeddings Provider
Select which embeddings provider to use for this context.
Include Page Content
Check "Also include the content of the page where the chat is displayed" so the bot receives both indexed knowledge and current-page content (auto behavior).
Context Max Length
Maximum characters of context sent to the AI model. Higher values can improve detail but use more tokens.
Knowledge Sources Limit
Slider (3–10) for how many chunks are used per answer. More chunks = richer context but more token usage.
AutoSync
Keep your knowledge base up-to-date automatically:
Enabling AutoSync
Check "Keep knowledge up to date automatically" in Advanced Settings.
Sync Modes
| Mode | What it does | Requirement |
|---|---|---|
| Only update modified content | Re-indexes documents already linked to context when changed | Always available |
| Update modified + add new content | Also discovers newly published matching content | At least one source set to "All" |
Manual Sync
Use "Run Sync Now" in Advanced Settings to run immediate sync/indexing instead of waiting for scheduled checks.
Advanced Indexing Options
By default, only the title and content are indexed. These options enrich your embeddings with additional fields:
General Fields
- Include excerpt — Adds the post excerpt
- Include post URL (on by default) — Lets the AI link directly to source content
- Featured image URL — Enables the AI to display images in chat (requires Markdown image instructions in the bot)
- Taxonomies — Comma-separated taxonomy names (e.g.,
category, post_tag, product_cat) - Custom meta keys — Comma-separated postmeta keys (ACF compatible)
WooCommerce Fields
- Short description
- Attributes — Size, color, material, etc.
Web Pages Import Notes
- The URL fetch pipeline processes imports in batches and reports per-page success/errors.
- Crawl mode discovers links from one domain/section, then you choose which pages to import.
- Imported web pages appear in the documents table as Web Page type.
When do changes take effect?
Changes to indexing options require a Save & Index to update existing embeddings. New content added via AutoSync automatically uses the current settings.
Page Builder Compatibility
The indexer fully supports Elementor, WPBakery, Divi, and other page builders:
- Expands shortcodes before extracting text (WPBakery, Divi)
- Strips all HTML tags, keeping only clean text
- Removes leftover shortcode markers
- Normalizes whitespace from nested wrapper divs
Elementor fallback: If standard extraction yields very little text (<10 words), the plugin reads Elementor's JSON data (_elementor_data) directly, recursively extracting text from all widgets: Text Editor, Headings, Icon Boxes, Tabs, Accordions, Toggles, and more.
Intelligent Chunking
Long content is automatically split into fragments:
- ~1,000 words per chunk
- ~180 words of overlap between chunks
- Preserves context across section boundaries
Pinecone (Optional)
For very large sites, use Pinecone as a remote vector store:
- Greater scalability for massive knowledge bases
- Faster searches at high volume
- Requires a Pinecone account
- Configure in Advanced Settings → Storage Type → Remote (Pinecone)
By default, all embeddings are stored locally in your WordPress database — no external service needed.
Advanced Context Management
For power users, a dedicated management page is available via "Advanced Context Management" at the bottom of the context page. It allows:
- Creating multiple contexts manually
- Browsing individual chunks
- Running similarity tests to verify relevance
- Deleting entire contexts
Best Practices
- Index only relevant content — Skip privacy policy/legal pages unless needed for support.
- Keep content updated — Use AutoSync or manually re-index after major changes.
- Review logs — Check which questions aren't answered well and adjust context.
- Use clear titles — Helps the system match relevant content.
- Enable "Include post URL" — Lets the bot link to your pages (on by default).
- For WooCommerce — No re-indexing needed for price/stock changes.
- Use "All" for AutoSync — Required for automatic new content detection.
- Start with 5 chunks — Increase the Knowledge Sources Limit only if answers lack detail.