=== Yak — AI Chatbot ===
Contributors: oliverdoric
Tags: chatbot, ai, gemini, openai, live chat
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.5.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Self-hosted AI chatbot for WordPress. Bring your own Gemini or OpenAI API key. No subscription fees.

== Description ==

Yak adds a customizable AI chat widget to your WordPress site. Connect your own Google Gemini or OpenAI API key, choose a chatbot personality, and start engaging visitors in minutes.

**Key Features**

* **Bring Your Own Key** — Use Google Gemini (free tier: 500 requests/day) or OpenAI. Your API key, your costs. No middleman.
* **Chatbot Modes** — Sales (promote products, capture leads), Support (troubleshoot, FAQ, human handoff), Explain (educate, link to articles), or Custom (your own system prompt).
* **RAG from Site Content** — Automatically searches your WordPress posts and pages for relevant context to include in AI responses.
* **Lead Capture** — Asks for email when visitors show buying intent or request human help.
* **Quick Reply Buttons** — Show clickable suggestions after each response.
* **Rating System** — Visitors can rate responses with thumbs up/down.
* **Dark Mode** — Automatically adapts to visitor preference.
* **Webhook Integration** — Forward conversations to n8n, Zapier, Make, or any webhook-compatible platform for CRM, ticketing, or email automation.
* **GDPR Notice** — Optional "Powered by AI" notice for EU AI Act compliance.
* **Rate Limiting** — Prevent API cost overruns (configurable requests/minute).
* **Data Retention** — Auto-delete conversations older than N days.
* **Semantic Search Box** — Add the `[yakwp_search]` shortcode for a live, AJAX search box that finds posts, pages, and products by meaning (with "Did you mean?" spelling corrections and product prices).

**Pro Features** (available at [yakwp.com](https://yakwp.com/pricing/))

* 🔒 **White-label** — Remove "Powered by Yak" branding
* 🔒 **Conversation Export** — Export all conversations as CSV
* 🔒 **Custom Widget CSS** — Style the widget beyond color and position


**How It Works**

1. Install Yak and go to **Settings → Yak Chatbot**
2. Enter your Google Gemini API key (free at [aistudio.google.com/apikey](https://aistudio.google.com/apikey)) or OpenAI key
3. Choose a chatbot mode and customize the welcome message
4. The chat widget appears on your site — no coding required

**Privacy**

All conversations are stored in your WordPress database. No data is sent to third parties beyond your chosen AI provider (Gemini/OpenAI). Data retention is configurable (default: 30 days).

== Installation ==

1. Upload the `yakwp` folder to `/wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to **Settings → Yak Chatbot** and enter your API key
4. Customize your chatbot mode, welcome message, and widget appearance
5. The chat widget automatically appears on your site's frontend

== Frequently Asked Questions ==

= Do I need a paid API key? =

No. Google Gemini offers a free tier with 500 requests per day. Get your key at [aistudio.google.com/apikey](https://aistudio.google.com/apikey).

= Is my data shared with third parties? =

No. Conversations are stored in your WordPress database. Only your AI provider (Gemini or OpenAI) receives message content for processing.

= Can I customize the chatbot's personality? =

Yes. Choose from Sales, Support, Explain, or Custom modes. In Custom mode, write your own system prompt to define the chatbot's behavior.

= Does it work with page builders? =

Yes. Yak loads the chat widget in `wp_footer`, which is supported by all major page builders and themes.

= What about Pro features? =

The free plugin includes all core features: chatbot modes, RAG, semantic (vector) search, email capture, quick replies, ratings, dark mode, webhook integration, GDPR notice, rate limiting, and data retention.

Pro features shown as disabled in settings (white-label, conversation export, custom widget CSS) are available in Yak Pro at [yakwp.com](https://yakwp.com/pricing/). The Pro version is a separate download with the actual feature code — this is not trialware.

== Screenshots ==

1. Chat widget on a live site — welcome message, quick reply buttons, and GDPR notice
2. Settings page — AI model configuration, widget appearance, and feature toggles
3. Conversations log — review, search, and export all chatbot interactions
4. Analytics dashboard — message count, sessions, leads, response time, and rating
5. Advanced settings — webhook integration, rate limiting, data retention, and GDPR options

== Changelog ==

= 2.5.1 =
* Fixed: semantic search was silently broken on servers running MariaDB 11.7+ or MySQL 9. The embedding table has a column named `vector`, which became a reserved word there, so the table could not be created and every index query failed with a syntax error. The column is now quoted in both the table definition and the retrieval query.
* Added: automatic schema repair after updating, so affected sites recover on their own instead of needing the table recreated by hand.

= 2.5.0 =
* Added: `[yakwp_search]` shortcode — a live AJAX semantic search box that finds posts, pages, and products by meaning, with "Did you mean?" spelling corrections, live product prices, per-visitor throttling, and keyword-search fallback when the embedding index is off.
* Added: "Search box in navigation menu" setting — adds the live search box to the top navigation menu (block themes and classic menus).

= 2.4.0 =
* Added: Product-aware semantic search that scales to large catalogs — products are indexed with price, SKU, and categories (so the chatbot can quote prices), and vector retrieval is bounded for fast answers even with thousands of products.
* Fixed: the daily index cron now self-schedules on every page load, so sites upgraded in place (FTP/file update) get automatic daily indexing without needing to deactivate and reactivate the plugin.

= 2.3.4 =
* Semantic (vector) search is now available on the free plugin — no license required. Previously the embedding index was gated behind a Pro check; free installs can now index post/page/product content and answer by meaning (not just keywords).

= 2.3.2 =
* Better default Quick Reply buttons — natural, visitor-phrased questions that engage and work well with semantic search
* Auto-upgrade: sites still on the old default Quick Reply questions update automatically (custom questions preserved)

= 2.3.1 =
* Default system prompt handles identity questions (who you are / where you're located / are you human)
* Points visitors to the site's contact page for contact/location queries instead of hedging

= 2.3.0 =
* Semantic (vector) search is now FREE — matches content by meaning (e.g. "how much does it cost?" finds "$29")
* Free sites include the "Powered by Yak" footer link; Pro can white-label

= 2.2.3 =
* System prompt copies cited URLs character-for-character from the context (no more slightly-misspelled page links in AI replies)
* Semantic (vector) search: index refresh/rebuild improvements

= 2.1.0 =
* RAG snippet size increased from 300 to 800 chars for better context
* Current page content (1500 chars) now included in prompt for page-specific answers
* Fixed widget script loading order — config now renders before JS (no more invisible widget)
* Default mode changed from 'sales' to 'support'
* Default system prompt updated to use website RAG context, not plugin-specific

= 2.0.9 =
* Replaced litespeed_purge hook with direct LiteSpeed_Cache_API::purge_all() call
* Inlined table names in all prepared SQL queries to satisfy Plugin Check static analysis
* Reduced PCP warnings to 34 (all DirectDB/NoCaching/SchemaChange, which are standard for custom tables)

= 2.0.8 =
* Replaced inline script output with wp_register_script/wp_add_inline_script for WP.org compliance
* Removed hidden .gitkeep file from submission package
* Removed Domain Path header (auto-loaded by WP.org)
* All remaining PCP warnings are false positives (DirectDB for custom tables, third-party hooks, readfile for REST JS serving)

= 2.0.7 =
* Replaced curl with WordPress HTTP API (wp_remote_post) for WP.org compliance
* Added load_plugin_textdomain() for i18n support
* Added live mode preview in settings (shows effective prompt when mode changes)

= 2.0.5 =
* Added webhook integration (n8n, Zapier, Make, or any platform)
* Added rating endpoint (thumbs up/down now saves to database)
* Fixed session ID sanitization for ratings
* Removed multi-site license from Pro placeholder (now volume pricing on site)

= 2.0.0 =
* Complete feature set: all modes (Sales, Support, Explain, Custom) unlocked
* RAG, email capture, quick replies, ratings, dark mode, webhook integration — all included
* Removed license key system for WordPress.org compatibility
* Added Pro upgrade notice (link to yakwp.com)
* Widget JS served via REST API to bypass static file blocking