=== Hey Trisha ===
Contributors: Manikandan Chandran - Founder, Architect & Lead Developer,
              Keerthana Kalidoss - Lead,
              Maha Krishnan S - Lead, 
              Ashwin B A,
              Ramasamy T, 
              Rohit Kumar S.
Tags: chatbot, ai, openai, woocommerce, nlp
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.4.3
Stable tag: 2.2.7
License: MIT
License URI: https://opensource.org/licenses/MIT
Text Domain: hey-trisha

AI-powered chatbot for WordPress and WooCommerce. Natural language questions are answered from your store data through the HeyTrisha API.

== Description ==

Hey Trisha is an AI chatbot for WordPress and WooCommerce. This plugin is a thin client: natural-language processing runs on the HeyTrisha API (https://api.heytrisha.com). The plugin executes validated read-only SQL on the local WordPress database and stores chat history in WordPress.

Account, site API keys, billing, Google Ads, and the Shiprocket add-on are managed in the HeyTrisha Account dashboard (https://app.heytrisha.com). WordPress Settings is used to connect the site and to turn the storefront widget on or off.

= Key Features =

* 🤖 **Natural Language Chat** - Ask questions in plain English from wp-admin
* 📊 **Read-Only Analytics** - SQL is limited to SELECT, WITH, SHOW, DESCRIBE, and EXPLAIN. Write and delete intents are blocked
* 🛍️ **WooCommerce** - Orders, products, and customers for administrators
* 💬 **Storefront Widget** - Shoppers can ask about the catalog and, when logged in, their own orders. Daily caps default to 20 for customers and 5 for guests
* 📁 **Knowledge & Schema Specification** - Upload text, CSV, SQL, or JSON so answers stay inside your data model
* 🧠 **Hybrid Architecture** - Optional mix of local database answers and web knowledge
* 📈 **Google Ads Chat** - Ask about spend, CPC, CTR, conversions, and ROAS. Credentials and sync live in the account dashboard
* 🚚 **Shiprocket** - Compare courier rates and ship WooCommerce orders. Configure the add-on in the dashboard
* 🔒 **Administrator Admin Chat** - Admin screens require `manage_options`
* 🌐 **Shared Hosting** - The plugin does not need Composer or a shell on the WordPress host

= How It Works =

1. Install and activate this plugin, accept the terms, then open Hey Trisha → Settings
2. Sign in with the username and password from your HeyTrisha Account, or choose Sign up
3. Sign up opens https://app.heytrisha.com. After the account is created, WordPress signs you in automatically. Signing in on the dashboard does not do this
4. Save the database host, name, user, and password in Settings. If the database is not on this server, allow inbound TCP port 3306. A firewall that blocks port 3306 stops the HeyTrisha API from connecting. localhost is not reachable from api.heytrisha.com
5. Administrators use Hey Trisha → New Chat
6. The plugin sends the question to the API, validates the returned SQL, runs it locally, and saves the reply

= Example Queries =

* "Show me all orders from last week"
* "What are my top-selling products?"
* "How many users registered this month?"
* "What is my Google Ads spend and ROAS?"
* "Which Google Ads campaigns perform best?"

= Requirements =

* WordPress 5.0 or higher
* PHP 7.4.3 or higher (PHP 8.0+ recommended)
* MySQL 5.7 or higher
* A HeyTrisha Account and a site API key from https://app.heytrisha.com
* WooCommerce, if you want catalog, order, and Shiprocket features
* An AI provider key stored on the site (OpenAI, Anthropic, Google, or xAI), configured with the account

= Shared Hosting Support =

This plugin runs on shared WordPress hosting. It does not install Laravel or Composer on the store. The API is a separate service.

1. Upload and activate the plugin
2. Connect it with the API key from your HeyTrisha Account
3. Start chatting from Hey Trisha → New Chat

== Installation ==

= Automatic Installation =

1. Log in to your WordPress admin panel
2. Navigate to Plugins → Add New
3. Search for "Hey Trisha"
4. Click "Install Now" and then "Activate"
5. Go to Hey Trisha → Settings
6. Connect with the API key from your HeyTrisha Account, or sign in
7. Open Hey Trisha → New Chat

= Manual Installation =

1. Download the plugin ZIP file
2. Log in to your WordPress admin panel
3. Navigate to Plugins → Add New → Upload Plugin
4. Choose the downloaded ZIP file and click "Install Now"
5. Activate the plugin
6. Go to Hey Trisha → Settings
7. Connect with your site API key or HeyTrisha Account

= Configuration =

After activation:

1. **HeyTrisha Account**: Register at [app.heytrisha.com](https://app.heytrisha.com), add this store as a WooCommerce site, and copy the API key
2. **WordPress connect**: Hey Trisha → Settings. Set the API server URL (default `https://api.heytrisha.com`) and paste the API key, or sign in with the account email/username and password
3. **Storefront (optional)**: Enable the storefront chatbot on the same Settings screen. Name, subtitle, model, and query limits can follow the site settings from the API
4. **Google Ads (optional)**: Configure the customer ID and OAuth credentials on the site’s Google Ads page in the account dashboard, then sync. Chat in WordPress reads those metrics. There is no Google Ads screen in wp-admin
5. **Shiprocket (optional)**: Enable it under MCP Add-ons in the account dashboard. The WordPress MCP Add-ons screen shows status. Courier rates and Ship now appear on WooCommerce orders

The Plugins screen “Settings” link opens the HeyTrisha Account dashboard.

= Admin menu =

* **New Chat** (`heytrisha-new-chat`) — administrator chat
* **Chats** (`heytrisha-chats`) — saved conversations
* **Archive** (`heytrisha-archive`) — archived chats
* **Settings** (`heytrisha-chatbot-settings`) — API connection and storefront toggle
* **MCP Add-ons** (`heytrisha-mcp-addons`) — read-only add-on status
* **Terms and Conditions** — hidden page, required on first activation

= Local data =

Custom tables: `{prefix}heytrisha_chats`, `{prefix}heytrisha_messages`, `{prefix}heytrisha_credentials`.
Schema uploads: `wp-content/uploads/heytrisha-schema/`.
REST namespace: `/wp-json/heytrisha/v1/` (`/config`, `/schema`, `/execute-sql`, chat CRUD).

== Frequently Asked Questions ==

= Do I need technical knowledge to use this plugin? =

No. Create an account, add the site, paste the API key in Hey Trisha → Settings, and start chatting.

= Does this work on shared hosting? =

Yes. The plugin runs in WordPress. AI processing runs on the HeyTrisha API, not inside this plugin.

= What data does the chatbot have access to? =

Admin chat can read the WordPress database through validated read-only SQL. The storefront widget is limited to the public catalog and, for a logged-in shopper, that shopper’s orders.

= Is my data secure? =

The site API key is issued by the HeyTrisha Account and sent as a Bearer token. Analytics SQL is checked on the API and again in the plugin before it runs. Destructive database intents are blocked. AI keys used for queries are resolved by the API from the connected site, not typed into the public storefront.

= Does this require a separate server? =

The plugin needs the HeyTrisha API (default `https://api.heytrisha.com`). You do not run Laravel on the WordPress host. Self-hosting the API is supported by pointing Settings at your own API URL.

= What's the cost? =

The plugin is MIT-licensed. Query volume is limited by the organization’s HeyTrisha subscription. AI provider usage is billed by that provider.

= Can I use this with WooCommerce? =

Yes. WooCommerce is optional for basic WordPress questions and required for the storefront catalog, orders, and Shiprocket shipping.

= What happens if I ask something the bot can't understand? =

The assistant returns an error or a short explanation, including when a question is outside the storefront scope or would require a write.

== Screenshots ==

1. Chatbot interface in WordPress admin
2. Natural language query example
3. Database query results
4. Settings page
5. Shared hosting detection

== Changelog ==

= 2.2.7 - 2026-10-29 =
* Sign in on Settings uses the HeyTrisha Account username and password
* Sign up opens the HeyTrisha Account. After registration, an encrypted one-time login returns to WordPress and signs the site in. Dashboard sign-in does not return to the plugin
* Database host, port, name, username, and password are saved in the plugin and sent to the HeyTrisha API
* Settings explains that a firewall blocking TCP port 3306 prevents the API from reaching a remote database

= 2.2.6 - 2026-10-28 =
* FIXED: OpenAI, Anthropic, Gemini, and xAI keys saved in the HeyTrisha Account are used by the plugin. A second copy of the key in WordPress is no longer required

= 2.2.5 - 2026-10-28 =
* FIXED: The WordPress database host falls back to DB_HOST. An empty host uses localhost so MySQL stays on the local socket
* The plugin sends that database host to the HeyTrisha account after an API key connection or sign-in
* Settings shows the database host this site will use

= 2.2.4 - 2026-10-28 =
* FIXED: Production sites no longer keep localhost, private-network, or tunnel API and dashboard URLs. Empty or development hosts fall back to https://api.heytrisha.com and https://app.heytrisha.com
* FIXED: Knowledge and schema ingest uses the resolved API URL
* IMPROVED: Readme describes the HeyTrisha Account, storefront widget, Google Ads, and Shiprocket as they work in this release
* Local and development WordPress installs can still use development URLs

= 2.2.0 - 2026-05-28 =
* NEW: Knowledge & Schema Specification — upload .txt, .md, .csv, .log, .sql, or .json files on the settings page to index business rules and constrain AI answers
* NEW: Schema Manager — stores uploaded specifications, syncs with the HeyTrisha API ingest endpoint, and tracks specification version and allowlist
* NEW: Read-only SQL validation — analytics queries must be SELECT/WITH/SHOW/DESCRIBE/EXPLAIN; write operations are rejected before execution
* NEW: User-facing chat error messages — clearer, consistent feedback for blocked intents, sensitive tables, and API errors
* NEW: Hybrid architecture toggle — enable or disable hybrid routing per chat from the New Chat admin screen
* IMPROVED: Effective schema resolution — uploaded schema, live database tables, and specification allowlists are combined intelligently per query
* IMPROVED: Asset cache busting — CSS/JS versions use file modification time so updates apply reliably after upgrading
* IMPROVED: Chat admin UI styling and hybrid toggle control
* SECURITY: Blocks natural-language delete/write database intents and sensitive system tables from analytics queries

= 2.1.3 - 2026-02-26 =
* CHANGED: Email, First Name, and Last Name fields are now fully editable
* IMPROVED: Users can now update their email, first name, and last name from the settings page
* IMPROVED: Email changes are synced to the API server

= 2.1.2 - 2026-02-26 =
* FIXED: Changed API sync from POST to PUT method to match API endpoint requirements
* FIXED: Only sync API-compatible fields (openai_key) to API server
* FIXED: Improved error messages and logging for API sync failures
* IMPROVED: Username, password, and database credentials are stored locally only (not synced to API)

= 2.1.1 - 2026-02-26 =
* FIXED: AJAX configuration now embedded directly in JavaScript to fix "heytrishaPersonalDataAjax is not defined" error
* FIXED: Removed dependency on wp_localize_script for more reliable AJAX functionality

= 2.1.0 - 2026-02-26 =
* NEW: Added AJAX endpoints for fetching and updating personal data
* NEW: Settings page now uses AJAX instead of form submission for better UX
* NEW: Data is stored locally first, then synced to API server
* IMPROVED: Real-time feedback when saving personal data
* IMPROVED: Better error handling and user feedback for API sync operations
* SECURITY: All AJAX endpoints use proper nonce verification and API authentication

= 2.0.9 - 2026-02-26 =
* FIXED: Data fetching now prioritizes local storage as primary source
* FIXED: Removed non-existent /api/user endpoint, using only /api/site/info
* IMPROVED: Better handling of empty fields with proper fallback to local storage
* IMPROVED: All fields now properly populated from local storage during registration

= 2.0.8 - 2026-02-26 =
* IMPROVED: Enhanced API data fetching with multiple endpoint support and better error handling
* IMPROVED: API fetching now tries /api/user and /api/site/info endpoints for better compatibility
* IMPROVED: Better response format handling for different API response structures
* FIXED: Database credentials now properly stored during registration
* FIXED: All fields now properly pre-filled from API or local storage

= 2.0.7 - 2026-02-26 =
* NEW: Added API data fetching to pre-fill all fields from HeyTrisha API server
* NEW: Added Database Information section with DB Name, DB Username, and DB Password fields
* NEW: All personal data and keys are now automatically fetched and pre-filled from API
* IMPROVED: Settings page now syncs with API server to display current data
* IMPROVED: Database credentials can now be viewed and updated in settings

= 2.0.6 - 2026-02-26 =
* NEW: Added Personal Data & Keys section in settings page
* NEW: Email and name fields are now read-only (cannot be changed)
* NEW: Added eye icon toggle for password/key fields to show/hide values
* NEW: HeyTrisha API key is now read-only with eye icon for viewing
* NEW: Username, password, and OpenAI API key can be updated in settings
* Improved settings page with better organization and user experience

= 2.0.5 - 2026-02-26 =
* CRITICAL FIX: Added nonce verification helper function to handle expired nonces for admin users
* CRITICAL FIX: Added React 18 CDN loading to ensure chatbot widget displays correctly
* CRITICAL FIX: Improved React initialization with retry mechanism and better error handling
* Updated all AJAX handlers to use robust nonce verification
* Enhanced React rendering with fallback support for React 17 compatibility

= 1.0.0 - 2025-12-17 =
* Initial release
* Natural language processing with OpenAI GPT
* WordPress and WooCommerce integration
* Shared hosting support
* Dynamic configuration management
* Secure API authentication
* Automatic dependency handling
* Name-based product/post editing
* Conversational response formatting

== Upgrade Notice ==

= 2.2.6 =
The plugin uses the AI provider keys saved in your HeyTrisha Account. Chat no longer requires a separate key inside WordPress.

= 2.2.5 =
WordPress database connections keep localhost on the local MySQL socket. After the plugin connects, the HeyTrisha account stores that host.

= 2.2.4 =
Production installs now ignore saved localhost and tunnel API or dashboard URLs and use https://api.heytrisha.com and https://app.heytrisha.com. Development environments are unchanged.

= 2.2.0 =
Recommended update: adds Knowledge & Schema Specification uploads, read-only SQL safety, hybrid architecture toggle, and improved chat error messages. After upgrading, review Settings to upload a specification file if you use custom data rules.

= 2.1.3 =
NEW FEATURE: Email, First Name, and Last Name fields are now editable. You can update these fields from the settings page.

= 2.1.2 =
CRITICAL FIX: Fixed HTTP 403 error when syncing settings to API server. Changed API request method from POST to PUT and only syncs API-compatible fields.

= 2.1.1 =
CRITICAL FIX: Fixed JavaScript error that prevented AJAX functionality from working. Personal data save feature now works correctly.

= 2.1.0 =
NEW FEATURE: Personal data management now uses AJAX for better user experience. Data is stored locally first, then automatically synced to the API server. Real-time feedback is provided when saving settings.

= 2.0.9 =
CRITICAL FIX: Fixed data population issue. All fields now properly load from local storage. If fields are empty, please re-enter your information in the settings page.

= 2.0.8 =
IMPROVED: Enhanced API data fetching with better error handling and multiple endpoint support. All fields now properly pre-filled from API or local storage.

= 2.0.7 =
NEW FEATURE: Settings page now automatically fetches and pre-fills all data from HeyTrisha API. Added Database Information section with DB credentials fields.

= 2.0.6 =
NEW FEATURE: Added Personal Data & Keys management section. Email and name fields are now read-only for security. Eye icon toggle added for password/key fields.

= 2.0.5 =
CRITICAL UPDATE: Fixes security check errors and React loading issues. All users should update immediately.

= 1.0.0 =
Initial release of Hey Trisha chatbot plugin.

== External Services ==

This plugin requires an external AI service to function. All natural language query processing is handled by the HeyTrisha AI Engine.

**Service Provider:**
- Service Name: HeyTrisha AI Engine
- Default API URL: https://api.heytrisha.com
- Provider: HeyTrisha Technologies

**Purpose & Functionality:**
The external service turns natural language questions into safe, read-only SQL for your WordPress database. The model (OpenAI, Anthropic, Google, or xAI) is the one configured on the connected site. This plugin runs that SQL locally. Site keys, billing, Google Ads, and Shiprocket are managed in the HeyTrisha Account at https://app.heytrisha.com.

**What Data is Transmitted:**
The plugin sends the following information to the API service:
- Your natural language questions (e.g., "Show me today's orders")
- WordPress database schema (table structure and column names only — not row data)
- WordPress site URL (for site identification)
- Site API key (Authorization: Bearer)
- Conversation context needed to answer follow-up questions
- Knowledge & Schema Specification text, when you upload one

Google Ads OAuth credentials and the store database password for hosted Chat API sites are saved in the HeyTrisha Account, not typed into this plugin’s Settings screen.

**What Data is NOT Transmitted:**
- Customer payment information or credit card data
- User passwords or authentication tokens
- Actual database records or content
- Personal identifying information (unless you specifically include it in your question)
- WordPress admin credentials

**When Data is Transmitted:**
- During initial plugin setup (one-time credential registration)
- Each time you submit a question via the chatbot interface
- When updating plugin settings
- When uploading a Knowledge & Schema Specification file (file contents are sent to the API for indexing)
- NO other automatic or background transmissions occur

**Service Terms & Privacy:**
- Terms of Service: https://heytrisha.com/terms-of-service
- Privacy Policy: https://heytrisha.com/privacy-policy
- Data Processing Agreement: Available upon request

**Self-Hosting Option:**
Advanced users can configure a custom API endpoint in the plugin settings to host their own instance of the HeyTrisha AI Engine. The engine source code and deployment instructions are available separately.

**Required for Functionality:**
This external service is mandatory for the plugin to work. The plugin acts as a lightweight client that delegates all AI processing to the external service, ensuring compatibility with WordPress.org hosting requirements.

== Privacy Policy ==

This plugin transmits data to the HeyTrisha external service. Please review the "External Services" section above for complete details on what data is sent, when, and how it is used. Your data privacy is protected in accordance with our Privacy Policy (https://heytrisha.com/privacy-policy).

== Support ==

For support, please visit:
* [GitHub Repository](https://github.com/manikandanchandran/HeyTrisha)
* [Report Issues](https://github.com/manikandanchandran/HeyTrisha/issues)
* [Documentation](https://github.com/manikandanchandran/HeyTrisha#readme)

== Credits ==

WordPress plugin client for the HeyTrisha API. Account UI is the dashboard at https://app.heytrisha.com.

== License ==

This plugin is licensed under the MIT License. See LICENSE file for details.









