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.

  1. Indexing — The plugin analyzes your content (pages, posts, products, PDFs) and converts it into "embeddings" — numerical representations the AI can search.
  2. Query — When a user asks a question, the system finds the most relevant content chunks.
  3. 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.

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

  1. Go to AxiaChat AI → Training.
  2. In the Knowledge section, click "Manage Context".
  3. 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:

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:

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:

4. Web Pages (External)

Import knowledge from external websites with two methods:

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:

Features: search by title, filter by type, multi-select with checkboxes, "Remove Selected" to delete items, pagination for large sets.

📘 Uploaded files PDF/TXT files are grouped by their parent file. Removing a parent file automatically removes all its associated chunks.

Save & Index

The main "Save & Index" button:

  1. Saves your source selections and advanced settings
  2. Creates a new context if none exists
  3. Assigns the context to the active bot
  4. 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

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

ModeWhat it doesRequirement
Only update modified contentRe-indexes documents already linked to context when changedAlways available
Update modified + add new contentAlso discovers newly published matching contentAt least one source set to "All"
⚠️ "Update + add new" mode This mode requires at least one source (Posts, Pages, or Products) set to "All." If none is set to "All," the selector shows a warning.

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

WooCommerce Fields

💡 WooCommerce dynamic data Price, stock, and SKU are not indexed in embeddings — they are injected fresh with every query. You never need to re-index when prices change!

Web Pages Import Notes

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:

  1. Expands shortcodes before extracting text (WPBakery, Divi)
  2. Strips all HTML tags, keeping only clean text
  3. Removes leftover shortcode markers
  4. 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:

Pinecone (Optional)

For very large sites, use Pinecone as a remote vector store:

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:

Best Practices

  1. Index only relevant content — Skip privacy policy/legal pages unless needed for support.
  2. Keep content updated — Use AutoSync or manually re-index after major changes.
  3. Review logs — Check which questions aren't answered well and adjust context.
  4. Use clear titles — Helps the system match relevant content.
  5. Enable "Include post URL" — Lets the bot link to your pages (on by default).
  6. For WooCommerce — No re-indexing needed for price/stock changes.
  7. Use "All" for AutoSync — Required for automatic new content detection.
  8. Start with 5 chunks — Increase the Knowledge Sources Limit only if answers lack detail.