AI Reply Engine and Knowledge Base
The AI stack in this build is grounded around OpenAI, workspace-specific knowledge sources, retrieval controls, trust signals, and customer memory. It is designed to stay buyer-friendly for CodeCanyon while still exposing enough depth for real support workflows.
1) OpenAI Provider Layer
OpenAI is the only built-in AI provider in the current release. All provider calls are routed through service classes and jobs instead of controllers so the chat flow stays testable and future providers can be added later.
- Widget replies
- Conversation summaries
- Suggested replies for agents
- Embedding generation
- FAQ drafting and memory summaries
Keep the queue worker running. AI replies and training jobs are dispatched asynchronously so the widget remains responsive.
2) Knowledge Sources and Training States
Knowledge content is managed from Chat > Knowledge Base. The product stores source-level records and chunk-level training data so each answer can be traced back to internal source identifiers.
| Source type | Examples | State model |
|---|---|---|
| Manual FAQ | Structured question/answer content written in the admin panel. | uploaded processing trained failed |
| Rich text article | Internal or public support articles. | Same source lifecycle as other knowledge items. |
| File upload | PDF, DOCX, TXT and similar parsed sources. | Queued extraction, chunking, embedding, and status tracking. |
| URL or sitemap | Website ingestion with crawl boundaries. | Queued crawl and retraining actions. |
3) Training Pipeline
When a source is uploaded or reprocessed, the application runs a queued pipeline rather than handling everything inside the request cycle.
- Store the source and mark it as uploaded.
- Extract and clean text from the source content.
- Split the text into chunks with source references.
- Create embeddings for those chunks.
- Store chunk metadata, vector data, and training logs.
- Mark the source as trained or failed.
4) Retrieval, Grounding, and Answer Modes
Retrieval is DB-first in this release. The application stores embeddings locally and computes relevance after workspace, source, and category filtering.
| Setting | Meaning |
|---|---|
| top_k | How many knowledge chunks are injected into the prompt. |
| similarity_threshold | Minimum relevance score required before grounding is trusted. |
| hybrid_guarded | Default mode. Prefer knowledge but allow limited model reasoning. |
| knowledge_only | Answer only when grounded content passes threshold, otherwise fall back to "I do not know". |
| general_assisted | Use knowledge when available but allow more free-form reasoning. |
Every AI answer can store source traces for debugging. Those traces are exposed in message metadata, retrieval logs, and admin detail panels so low-quality answers can be audited instead of guessed.
5) Confidence, Escalations, Gaps, and FAQ Drafting
The trust layer sits on top of retrieval. It combines grounding quality, low confidence signals, escalation rules, unresolved topics, FAQ suggestion generation, and sentiment/frustration patterns.
- Low-confidence answers can trigger escalation suggestions or open escalations.
- Repeated weak topics feed the knowledge-gap list.
- Resolved conversations can generate draft FAQs for review.
- Sentiment and frustration scoring help the dashboard identify sensitive chats.
Continuous improvement loop
A common workflow is: detect a weak topic from low-confidence answers, upload a better source or approve a FAQ draft, retrain, then confirm the topic drops out of the unresolved list in reports.
6) Help Center and Customer Memory
Approved FAQ content can be published to the hosted help-center routes. Customer memory is workspace-scoped and widget-aware, and is intended to store concise summaries rather than replaying full transcript history in every prompt.
- Workspace-branded public FAQ surface
- Category and FAQ detail routes
- Self-service deflection before a human chat starts
- Store preference or issue summaries
- Link repeat visitors through profile resolution
- Reset or delete memory from the admin panel when needed
7) Recommended AI Launch Pattern
- Start with one department and one widget before enabling AI everywhere.
- Upload clear FAQ or policy sources before testing reply quality.
- Use hybrid guarded mode first, then tighten to knowledge-only if needed.
- Review low-confidence threads and knowledge gaps weekly.
- Keep prompt and retrieval settings stable while you evaluate answer quality.