AI FAQ Chat
WordPress AI FAQ chatbot — AlexHost case study (OpenAI + Node RAG)
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/gloutlaw/ai-faq-chat/archive/refs/heads/main.zipAI FAQ Chat — AlexHost case study
Not a drop-in WordPress plugin. This is the custom FAQ chatbot built for alexhost.com: it indexes the hosting catalog (FAQ, tariffs, coupons, SSL, blog posts, pages) and answers visitors from that knowledge — not from a generic “FAQ CPT only” template.
Live on the production site. Credentials never live in git (SECURITY.md).
What it does
A visitor asks about VPS, a coupon, or an SSL cert. The widget (POST /wp-json/ai-faq-chat/v1/message) answers from indexed site content:
- Primary — Node RAG (
knowledge_chunks): WPsave_postqueues a reindex; the chat backend embeds the page. - Fallback — PHP embeddings in
wp_aifaq_embeddings+ WordPress search, if Node is not configured.
The plugin is wired to this theme’s post types and ACF fields (prices, promo codes, CPU/RAM/storage). It will not make sense on an unrelated WP site.
Indexed content
| WP type | Role on the hosting site |
|---|---|
faq-post |
FAQ items registered by this plugin (includes/class-cpt.php) |
services |
AlexHost tariffs (theme CPT) |
service |
Ava tariffs (same hook, other brand) |
coupon |
Promos / coupon codes |
certificate / ssl-certificate |
SSL catalog |
news-post |
News |
post |
Blog / articles |
page |
Static pages |
Allowlists:
- Node reindex:
includes/class-node-reindex-hook.php - PHP index + config:
includes/class-embeddings.php,config/site-config.phpcontent_types
Tariffs / coupons / SSL are theme CPTs. The plugin only indexes them; it does not register those types.
Indexing logic
Editor publishes a post
│
▼
type in allowlist? ──no──► ignore
│ yes, status=publish
▼
WP-Cron (~5s) ──► Node POST /internal/reindex
{ url, content_hash, post_id, post_type }
Node fetches the URL and stores chunks
PHP fallback (admin bulk index / embeddings):
title + excerpt + first 5k of body
+ ACF: price, links, promo-coupon, CPU, RAM, storage, features
→ OpenAI embedding → wp_aifaq_embeddings
- Autosaves, revisions, and password-protected posts are skipped.
- Node gets a hash + permalink, not the full body; the chat server crawls the URL (idempotent via
content_hash/X-Event-Id). - Keyword fallback (
class-content-search.php) queriesfaq-post,services,coupon,certificate(not genericpost/page).
Visitor path: widget → /message → Node /internal/ai/chat when a reindex token is set; otherwise PHP semantic/keyword search over the indexed types.
Secrets
API keys, reindex Bearer, and live-chat secret are WordPress Settings / wp-config.php only. This repo has empty defaults and 127.0.0.1 placeholders in the admin UI. See SECURITY.md.
Layout
| Path | Purpose |
|---|---|
ai-faq-chat.php |
Bootstrap, widget inject, default prompt (AlexHost) |
config/site-config.php |
Catalog, countries, billing URLs, languages |
includes/class-node-reindex-hook.php |
save_post → Node |
includes/class-embeddings.php |
PHP index + cosine search |
includes/class-rest-controller.php |
/message and hosting-specific reply logic |
assets/ |
Widget UI |
admin/ |
Settings, history, bulk index (legacy PHP path) |
Tests
npm test
License
MIT — published as a portfolio case, not a product to install on third-party sites.
Changelog: CHANGELOG.md.