Athenian AI Chat & Recommendations
Overview
Product overview
This document consolidates technical implementation notes and marketing-ready positioning for the Athenian WordPress & WooCommerce AI Chat and Product Recommendations plugin. It is intended to support product-page content, internal documentation, sales enablement, implementation planning, and future roadmap refinement.
The summary below is based on inspection of the uploaded plugin package, including the primary plugin bootstrap, PHP classes, frontend/admin assets, REST routes, bundled Markdown documentation, and response-contract fixtures.
---
Use cases
- Product discovery
- Storefront assistance
- Recommendation workflows
- Catalog Q&A
Developer
Developer starting point
This baseline documents the reviewed chat/recommendation architecture. It does not claim that an external AI provider request or end-user conversation has been exercised.
Technical Architecture
Bootstrap and Load Order
The main plugin file defines constants, helper functions, includes the module files in an intentional order, registers activation hooks, and boots the plugin on plugins_loaded.
Key constants include:
define( 'AWCAI_PLUGIN_FILE', __FILE__ );
define( 'AWCAI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AWCAI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'AWCAI_PLUGIN_VERSION', '1.0.1' );Load order is important because REST handlers and live chat modules depend on the core, credentials, tools, conversations, and live chat classes being available first.
Primary PHP Classes
| Class | Responsibility | |---|---| | AWC_AI_Config | Default theme values and system prompt template. | | AWC_AI_Creds | OpenAI/Twilio credential lookup, preferring SecureStore when available. | | AWC_AI_Core | Central OpenAI and tool-calling facade. | | AWC_AI_Tools | Tool schema registry and dispatcher. | | AWC_AI_Router | Search-plan construction and keyword extraction. | | AWC_AI_REST | Main REST endpoints for chat and index status. | | AWC_AI_Shortcode | [awc_ai_chat] shortcode and frontend asset registration. | | AWC_AI_Indexer | WooCommerce product index build/status/integrity logic. | | AWC_AI_Index_Search | JSON index loading, prompt normalization, scoring, and fallback search. | | AWC_AI_Customer_Context | Customer, order, address, phone, and tracking context helpers. | | AWC_AI_Conversations | Conversation and message table management. | | AWC_AI_LiveChat | Popup widget, state table, capabilities, auto-injection helpers. | | AWC_AI_LiveChat_REST | Live chat REST endpoints for users and agents. | | AWC_AI_LiveChat_Admin | WooCommerce admin live chat console. | | AWC_AI_SMS_Router | Twilio SMS webhook and debug routes. | | AWC_AI_Voice_Router | Twilio voice webhook and TwiML response handling. | | AWC_AI_Twilio | Twilio SMS/MMS send helper. | | AWC_AI_TTS | Extension point for speech synthesis URL generation. |
Frontend and Admin Assets
| Asset | Purpose | |---|---| | assets/js/chat.js | Embedded shortcode chat behavior, REST submission, message rendering, recommendation cards. | | assets/css/chat.css | Embedded chat UI styling. | | assets/js/chat-popup.js | Popup/live chat widget, conversation open, polling, streaming, send fallback. | | assets/css/chat-popup.css | Popup widget styling. | | assets/js/admin-livechat.js | Admin agent console behavior. | | assets/css/admin-livechat.css | Admin live chat console styling. |
Assets use a cache-busting helper that appends filemtime() to the plugin version where possible.
---
REST API Surface
Main Chat Routes
| Method | Route | Purpose | Permission | |---|---|---|---| | POST | /wp-json/awcai/v1/chat | Handles embedded chat messages and product recommendations. | Public | | GET | /wp-json/awcai/v1/index-status | Returns product index status. | manage_options |
Live Chat Routes
| Method | Route | Purpose | |---|---|---| | POST | /wp-json/awcai/v1/conversation/open | Opens/creates a web conversation. | | GET | /wp-json/awcai/v1/conversations | Lists conversations for agents. | | GET | /wp-json/awcai/v1/conversation/{id} | Reads conversation state/details. | | GET | /wp-json/awcai/v1/conversation/{id}/messages | Reads conversation messages. | | POST | /wp-json/awcai/v1/conversation/{id}/send | Sends a user message with non-streaming response. | | POST | /wp-json/awcai/v1/conversation/{id}/send-stream | Sends a user message with streaming response. | | POST | /wp-json/awcai/v1/conversation/{id}/agent-send | Sends an agent reply. | | POST | /wp-json/awcai/v1/conversation/{id}/takeover | Switches conversation to human/agent mode. | | POST | /wp-json/awcai/v1/conversation/{id}/handoff-ai | Returns conversation to AI mode. | | POST | /wp-json/awcai/v1/conversation/{id}/close | Closes a conversation. |
Live chat permissions distinguish guest users, conversation owners, logged-in users, and agents. Agent actions require the awcai_live_chat_agent capability and REST nonce verification where appropriate.
SMS and Voice Routes
| Method | Route | Purpose | |---|---|---| | POST | /wp-json/awcai/v1/sms | Handles inbound SMS/Twilio webhook messages. | | GET | /wp-json/awcai/v1/sms-context | Debug route for sender/customer context. | | GET | /wp-json/awcai/v1/sms-search | Debug route for SMS product search. | | POST | /wp-json/awcai/v1/voice | Handles Twilio Voice webhook requests. |
---
Data Model
Database Tables
#### wp_awcai_conversations
| Column | Notes | |---|---| | id | Primary key. | | channel | Conversation channel such as web/SMS/voice. | | sender_key | User, phone, session, or call-derived sender key. | | session_key | Session identifier. | | created_at | Conversation creation time. | | updated_at | Last update time. |
Indexes include channel_sender and channel_sender_session.
#### wp_awcai_messages
| Column | Notes | |---|---| | id | Primary key. | | conversation_id | Parent conversation ID. | | role | system, user, assistant, tool, or agent. | | content | Message content. | | meta | JSON metadata. | | created_at | Message timestamp. |
Indexes include conv_created and conv_role.
#### wp_awcai_conversation_state
| Column | Notes | |---|---| | conversation_id | Primary key and link to conversation record. | | mode | Conversation mode, default ai. | | status | Conversation status, default open. | | assigned_agent | Optional user ID of assigned agent. | | meta | JSON metadata. | | last_user_seen_at | User read marker. | | last_agent_seen_at | Agent read marker. | | updated_at | Last state update timestamp. |
Indexes include mode_status, assigned_agent, and updated_at.
File-Based Index Data
The catalog index is stored as:
uploads/awcai-index/index.jsonThe index contains products and _meta details such as build time, schema version, source count, and indexed product count. Atomic writes reduce the risk of partial/corrupt index files during rebuilds.
Debug Log
The plugin includes a JSON-line debug logger that writes to:
uploads/awcai-debug/chat.logDebug entries are used across chat, prefetch, index rebuild, search, and related observability flows.
---
Admin Workflow
A typical merchant/admin workflow is:
- Install and activate the plugin.
- Configure credentials through Athenian Secure API Key Manager or plugin-local settings.
- Open Settings → Athenian AI Chat.
- Enter or verify OpenAI configuration.
- Customize the chat theme colors.
- Review or override the system prompt template.
- Rebuild the WooCommerce product index.
- Run the index integrity check.
- Add
[awc_ai_chat]to a page or template area. - Add
[awc_ai_chat_popup]or enable auto-injection for the floating widget. - Grant selected staff the
awcai_live_chat_agentcapability. - Use WooCommerce → Live Chat to monitor, take over, reply to, or close conversations.
---
Customer and Agent Workflow
Shopper Workflow
- Shopper opens chat on the storefront.
- Shopper asks a product or support question.
- The plugin normalizes the message and pre-searches the WooCommerce product index when the prompt looks like a catalog lookup.
- Matching products are returned as recommendation cards when available.
- For broader support questions, OpenAI receives structured context and available tool schemas.
- The assistant responds with grounded product/account/order guidance.
- If the conversation needs a human, support staff can take over the same thread.
Authenticated Customer Workflow
- Logged-in customer asks about orders, tracking, or account details.
- Customer context resolves from the active WordPress user.
- Tool calls can retrieve account, order, and tracking data.
- Address-update operations require explicit confirmation safeguards before changing metadata.
Live Agent Workflow
- Agent opens WooCommerce → Live Chat.
- Agent reviews open conversations.
- Agent selects a thread and reads context/history.
- Agent clicks Take over to switch the conversation away from AI mode.
- Agent sends a human reply.
- Agent can click Return to AI or Close when complete.
---
Security and Privacy Notes
- OpenAI credentials are looked up through Athenian Secure API Key Manager when available.
- Plugin-local OpenAI key entry is still available as a fallback.
- Agent routes require the
awcai_live_chat_agentcapability. - Management/index routes require
manage_options. - Logged-in REST POST actions use nonce verification where appropriate.
- Guest live chat is tracked with a generated
awcai_sidcookie instead of requiring a user account. - Customer account/order tools require authenticated customer context.
- Address updates require both tool-level confirmation and recent-message verification.
- The system prompt explicitly instructs the AI not to fabricate products, customer data, bookings, orders, or completed actions.
- SMS opt-outs are tracked in the
awcai_sms_optoutsoption.
---
Implementation Notes from Code Inspection
- PHP syntax checks passed for all PHP files in the uploaded package.
- The package does not register custom post types or taxonomies.
- The plugin uses custom database tables for conversations and live chat state.
- The plugin uses file-based JSON indexing rather than a custom product-index database table.
- The main OpenAI call currently targets
https://api.openai.com/v1/chat/completions. AWC_AI_TTS::synthesize_to_url()is currently a lightweight extension point and does not implement a production TTS provider by itself.- The voice and SMS endpoints are public webhook endpoints by design, and should be protected in production with shared-secret validation, Twilio request validation, WAF rules, or gateway restrictions where appropriate.
- The
get_openai_api_key()helper in the bootstrap readsawcai_openai_api_key, whileAWC_AI_Credsprefers SecureStore and then readsawcai_settings. This is workable as layered fallback behavior, but production configuration should standardize where credentials are stored. - The admin settings page currently registers
awcai_openai_api_key,awcai_theme, andawcai_system_prompt; additional credential fields for Twilio/model settings appear to be read fromawcai_settingsor filters rather than fully exposed in the inspected admin page. - The bundled
docs/response-contract-training-fixtures.jsonreinforces safe response behavior for no-results catalog searches, catalog matches, and account-address update confirmation.
---
Install
- Reviewed source folder: athenian-ai-chat-woocommerce
- Plugin version reviewed: 1.0.1
- Local source inventory: 33 files (temporary, test, and Git metadata excluded).
- GitHub baseline: https://github.com/Athenian-Brands/athenian-ai-chat-woocommerce at baseline/devdocs-1.0.1-20261006c / 8da23d249e210154eeb012bfebc4dd7fb9712e2e.
- WordPress and WooCommerce.
- AI provider credentials, paid requests, and live conversational behavior require separate target-environment verification.
Configuration
- Document Purpose — see the linked technical reference excerpt.
- Plugin Identity — see the linked technical reference excerpt.
- Executive Summary — see the linked technical reference excerpt.
- Marketing Positioning — see the linked technical reference excerpt.
- Problem It Solves — see the linked technical reference excerpt.
- Best-Fit Use Cases — see the linked technical reference excerpt.
- Core Feature Set — see the linked technical reference excerpt.
- Technical Architecture — see the linked technical reference excerpt.
- REST API Surface — see the linked technical reference excerpt.
- Data Model — see the linked technical reference excerpt.
- Admin Workflow — see the linked technical reference excerpt.
- Customer and Agent Workflow — see the linked technical reference excerpt.
- Security and Privacy Notes — see the linked technical reference excerpt.
- Athenian Platform Fit — see the linked technical reference excerpt.
Usage
- Shortcodes detected in local PHP source: 2
- Static action/filter hooks detected in local PHP source: 19
- REST route registrations detected in local PHP source: 4
Shortcodes
- awc_ai_chat_popup — includes/class-awcai-livechat.php
- awc_ai_chat — includes/class-awcai-shortcode.php
REST Endpoints
- awcai/v1 — includes/class-awcai-livechat-rest.php
- awcai/v1 — includes/class-awcai-rest.php
- awcai/v1 — includes/class-awcai-sms-router.php
- awcai/v1 — includes/class-awcai-voice-router.php
Hooks
- admin_enqueue_scripts — includes/class-awcai-livechat-admin.php
- admin_init — includes/class-awcai-admin.php
- admin_init — includes/class-awcai-livechat.php
- admin_menu — includes/class-awcai-admin.php
- admin_menu — includes/class-awcai-livechat-admin.php
- admin_post_awcai_check_index — includes/class-awcai-admin.php
- admin_post_awcai_rebuild_index — includes/class-awcai-admin.php
- awcai_enforce_slim_query_prompt — includes/class-awcai-core.php
- init — includes/class-awc-ai-conversations.php
- init — includes/class-awcai-livechat.php
- plugins_loaded — athenian-ai-chat-woocommerce.php
- rest_api_init — includes/class-awcai-livechat-rest.php
- rest_api_init — includes/class-awcai-rest.php
- rest_api_init — includes/class-awcai-sms-router.php
- rest_api_init — includes/class-awcai-voice-router.php
- rest_pre_serve_request — includes/class-awcai-sms-router.php
- wp_enqueue_scripts — includes/class-awcai-livechat.php
- wp_enqueue_scripts — includes/class-awcai-shortcode.php
- wp_footer — includes/class-awcai-livechat.php
Data Model
- Data Model — described in the local technical reference.
API Reference
- Local source digest: 540b897bf674601d5e5c8e5c9ea0902a2bb8762f932707843d6783b8c63010fb
- Repository URL: https://github.com/Athenian-Brands/athenian-ai-chat-woocommerce
- Repository reference: baseline/devdocs-1.0.1-20261006c
- Repository commit: 8da23d249e210154eeb012bfebc4dd7fb9712e2e
Source files include: assets/css/admin-livechat.css, assets/css/chat-popup.css, assets/css/chat.css, assets/js/admin-livechat.js, assets/js/chat-popup.js, assets/js/chat.js, athenian-ai-chat-icon.png, athenian-ai-chat-woocommerce.php, athenian-ai-chat-woocommerce.zip, docs/athenian-platform-marketing.md, docs/athenian-platform-technical.md, docs/awcai-marketing-document.md, docs/response-contract-training-fixtures.json, docs/technical-marketing.md, includes/class-awc-ai-conversations.php, includes/class-awcai-admin.php, includes/class-awcai-config.php, includes/class-awcai-core.php, includes/class-awcai-creds.php, includes/class-awcai-customer-context.php, includes/class-awcai-index-search.php, includes/class-awcai-indexer.php, includes/class-awcai-livechat-admin.php, includes/class-awcai-livechat-rest.php, includes/class-awcai-livechat.php, includes/class-awcai-rest.php, includes/class-awcai-router.php, includes/class-awcai-shortcode.php, …
Troubleshooting
- This baseline documents the reviewed chat/recommendation architecture. It does not claim that an external AI provider request or end-user conversation has been exercised.
- Confirm the deployed plugin version, active dependencies, and current repository tree before using implementation details as a release contract.
Treat payment, carrier, vendor, shipment, inventory, account, credential, tax, AI, and external-provider behavior as integration-dependent until exercised in the target environment.
FAQ
What is this page intended to establish?
A versioned, product-linked starting point for iterative developer documentation. It combines the local implementation reference with a detected-code inventory and a committed GitHub baseline.
Is the linked repository baseline verified?
Yes. The repository URL, ref, and commit recorded on this page were verified from the clean GitHub baseline prepared for this documentation pass. That does not by itself prove fleet deployment parity.
What remains for release-grade documentation?
Reconcile the recorded source baseline with the deployed plugin version, then exercise the relevant authenticated, store, provider, payment, tax, carrier, or generated-artifact paths in the target environment.