We built DEV3 AI Shopping Assistant & Chatbot as a WooCommerce plugin in PHP, with a dependency-free storefront chat and a React admin. The model writes the reply; WooCommerce supplies every fact and the server validates every action.
Key design decisions
- Hybrid retrieval. Each question runs a keyword product search (titles, SKUs, categories, tags, attributes, price phrases) and, when an index exists, a semantic search over product and knowledge embeddings. The two ranked lists are merged with reciprocal rank fusion.
- The model only chooses. It sees up to 12 candidate products as facts and returns product ids in structured JSON. Ids outside the candidate set are dropped, and product cards (name, image, price, rating, stock, Add to cart) are rendered from WooCommerce, never from the model's text.
- Validated actions. "Add the blue mug to my cart" becomes an
add_to_cart action that must name a candidate product; the server rejects variable and out-of-stock products and offers Undo. Order status text always comes from WooCommerce.
- Private orders. Logged-in customers see their own recent orders; guests need the order number and the matching billing email. Addresses and payment details are never shown.
- Guided mode first. Without a key, or when the AI fails, hits its monthly cap or the per-conversation limit, rules answer: product finder, order tracking, knowledge base and handoff.
- Incremental index. Products and knowledge entries are embedded in background jobs; only items whose content hash changed are embedded again.
Architecture
The chat is a floating launcher, an inline block or a shortcode; on phones it opens as a full-screen sheet that stays above the keyboard. A same-origin, rate-limited REST API handles messages, cart actions, order lookups, ratings and handoff. Conversations are stored with transcripts, ratings and outcomes, and chat-added items are attributed to orders so the dashboard shows revenue from chat (HPOS-safe). The knowledge base imports refund, terms and privacy pages, shipping zones and payment methods; with the Google Gemini API connected, DEV3 AI drafts knowledge answers, groups unanswered questions into gaps, writes insights and the assistant's persona, all as drafts. A test console shows why each answer was given. The API client, encrypted key storage, embeddings store and usage logs come from a shared core used across DEV3's plugins.