=== PMS Chat AI ===
Contributors: pmscripts
Tags: ai chat, chatbot, woocommerce, customer service, openai
Requires at least: 6.9
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.2.27
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An AI advisor that recommends your products or services and answers questions about your business, using your own OpenAI or Anthropic key.

== Description ==

Add a chat window that helps visitors choose products or services and get answers about your business. The advisor works only with your content: your website, WooCommerce products and the topics you allow. It politely deflects everything else.

= Features =

* Product recommendations from your WooCommerce catalogue, with live prices, stock, variants and product cards.
* Learns your whole website automatically: pages, services, portfolio and courses as visitors see them (page builders included), plus your contact, booking and quote forms. New and edited pages are learned right after you save them.
* Points visitors to the right service, page or form with clickable links.
* Topic guard: homework, maths, programming, general knowledge and attempts to change the rules are refused or deflected.
* Warnings for abuse; the third attempt ends the conversation.
* Budget limits per conversation, day and month, with alerts before your provider balance runs out.
* Setup wizard, test chat in the admin panel and a live preview of the chat window.
* Greeting, suggested questions, tone, colours, font, position, layer (z-index), opening hours and pages where the chat appears.
* Six entrance animations for the chat button and optional short messages next to it, such as “How can we help you?”, that take turns and can show every time on the home page.
* Contact form with consent, conversation history, statistics and automatic deletion of old conversations.
* Call-back requests: when a visitor leaves a phone number or an email in the chat and agrees to be contacted, your team gets an email with a short summary.
* Conversations and messages with contact details are marked in the history.
* Optional Google reCAPTCHA v3 against bots.
* Admin panel in English, Polish and Swedish; chat in English, Polish or Swedish.

= Why PMS Chat AI? =

You pay your AI provider directly at their prices, with the cheapest suitable model selected by default. The plugin checks prices and availability in WooCommerce every time, so the advisor does not invent products, prices or discounts. Your API key is encrypted on your server and never sent to the browser.

The public chat stays off until you test the connection and turn it on.

= Need more tools? =

PMS Chat AI Pro is a separate add-on from PMScripts.com that works together with this plugin:

* Cart suggestions while the visitor shops, and answers from your own documents such as a menu, an allergen list or a price list.
* Matching sets and higher-priced alternatives from WooCommerce cross-sells and upsells.
* Priority and excluded categories.
* Conversation statuses, notes, filters and CSV export.
* Product clicks, add-to-cart and orders started from the chat.
* Quotes in the chat: saved step by step in online quote configurators and emailed to your team when the visitor is happy.
* Replies in each visitor's own language (for example Arabic), with translations into your language in the history.
* Extra chat templates and a quality check.

See [features and plans](https://pmscripts.com/chat-ai/).

= Privacy =

This PMScripts.com version checks for updates at `https://pmscripts.com/updates/pms-chat-ai/update.json` when you open the Plugins or Updates screen; WordPress sends your site address and the plugin version in standard request headers. Updates are installed only after the PMS signature and checksum are verified. There is no licence manager or telemetry. Conversations, contacts and usage records are stored in your WordPress database and deleted after the period you choose (90 days by default). The plugin adds suggested text to your privacy policy and supports the WordPress personal data export and erasure tools.

You must inform your visitors that the chat uses an AI provider. The chat window always shows a short AI notice.

== External services ==

This plugin connects to the AI provider you choose. Nothing is sent until you save an API key and test the connection or a visitor writes in the enabled chat.

**OpenAI API** (when OpenAI is selected): `https://api.openai.com/v1/responses`. Sent: the visitor's messages, recent conversation history, matching excerpts from your selected pages, product data found by the plugin and the advisor instructions. Requests use `store: false`. [Terms](https://openai.com/policies/terms-of-use/), [privacy policy](https://openai.com/policies/privacy-policy/).

**Anthropic API** (when Claude is selected): `https://api.anthropic.com/v1/messages`. Sent: the same data as above. [Terms](https://www.anthropic.com/legal/commercial-terms), [privacy policy](https://www.anthropic.com/legal/privacy).

**Google reCAPTCHA v3** (optional, off by default): when enabled and a visitor opens the chat, the browser loads `https://www.google.com/recaptcha/api.js`, and your server checks the resulting token at `https://www.google.com/recaptcha/api/siteverify`. Google receives the visitor's browser data and IP address through its script. [Terms](https://policies.google.com/terms), [privacy policy](https://policies.google.com/privacy).

The "Powered by PMS" credit is a plain link to PMScripts.com; in this free store version it stays on. Read our [privacy policy](https://pmscripts.com/privacy-policy/) and [service terms](https://pmscripts.com/terms-and-payments/).

== Installation ==

1. Install and activate PMS Chat AI on WordPress 6.9 or later with PHP 7.4 or later.
2. Open PM Scripts > PMS Chat AI and follow the setup wizard.
3. Create an API key with OpenAI or Anthropic, set a spending limit there and paste the key in the AI provider step.
4. Test the connection and try the test chat.
5. Turn on the public chat in the Activation step.

== Frequently Asked Questions ==

= How much does it cost to run? =
The plugin is free. You pay your AI provider for usage. With the default model a typical answer costs a fraction of a cent; the panel shows the estimated cost of every conversation and enforces the limits you set.

= Do I need WooCommerce? =
No. Without WooCommerce the advisor answers questions about your business from the pages you select.

= Can visitors use it as a free ChatGPT? =
No. A separate topic check runs before every answer. Questions outside your topics get a short deflection, made-up calculations are refused, and repeated attempts end the conversation.

= Where is my API key stored? =
Encrypted in your WordPress database. It is never shown in the browser, in exports or in logs. Anyone with full access to your server can still read site secrets, so use a key with a spending limit.

= Can I see the conversations? =
Yes, in the History tab, with 10 conversations per page and deletion of selected conversations. Shop managers can get read access to history and statistics.

= Does it work with page caching? =
Yes. The chat loads its data through the REST API. With full-page caching, a change of opening hours may appear after the cache is cleared.

== Screenshots ==

1. Chat window with product recommendations.
2. Setup wizard.
3. Appearance settings with a live preview.

== Changelog ==

= 0.2.27 =
* On phones the chat button no longer shows on top of the open chat window.

= 0.2.26 =
* The appearance preview follows every field while you edit, before saving.
* The Save button stays at the bottom of the screen while you edit a section.

= 0.2.25 =
* The close button of the message next to the chat button shows its × exactly in the centre, whatever the theme font.

= 0.2.24 =
* Views of the home page no longer count towards the limit for other pages.

= 0.2.23 =
* The message next to the chat button can show every time on the home page and up to a chosen number of times per visit on other pages (default 2).
* Up to 5 messages that take turns, one per line.

= 0.2.22 =
* New pages and posts are learned right after they are saved, without waiting for the next visit.

= 0.2.21 =
* Choose how long the message next to the chat button stays: 6 seconds by default, longer, or until the visitor closes it.

= 0.2.20 =
* The message next to the chat button also waits while a cookie banner covers the place where it would appear.

= 0.2.19 =
* The message next to the chat button waits until the button can be seen, for example until a cookie banner is closed.
* The message stays until the visitor closes it or opens the chat; the close button is on its right.

= 0.2.18 =
* Choose how the chat button appears: fade, slide up, pop, bounce, slide in from the side or wiggle (no animation for visitors who prefer less motion).
* Optional short message next to the chat button, for example “How can we help you?”: appears right away and floats gently, once per visit, disappears after a moment, never while the chat is open.

= 0.2.17 =
* Translations are loaded from WordPress language packs (translate.wordpress.org) when they are not bundled.

= 0.2.16 =
* The appearance preview keeps the whole chat window inside the frame, with its header visible.
* API key and reCAPTCHA keys are masked, with a Show button for what you type.

= 0.2.15 =
* A slowly pulsing green dot on the closed chat button when a reply arrives in the background.
* Hooks for add-ons: extra knowledge results, a one-time suggestion shown with the dot, page context sent with a message.

= 0.2.14 =
* New Appearance setting “Layer (z-index)”: lower it when the chat button shows on top of your site menu or pop-ups. The open chat window still comes to the front.

= 0.2.13 =
* Corrected the readme: conversations are kept for 90 days by default.
* PMScripts links in the plugin point to the PMS Chat AI page.

= 0.2.12 =
* Updated shared PMS admin theme: the admin class is kept apart from classes added by other plugins.

= 0.2.11 =
* The settings panel keeps its styles when another plugin adds its own class to the admin page without a space (for example Tutor LMS).
* Shorter answer length described correctly; dates in the history no longer wrap on phones.

= 0.2.10 =
* Messages in right-to-left languages such as Arabic are shown in the correct direction, in the chat and in the history.

= 0.2.9 =
* Conversations where the visitor left contact details are marked in the history, and so are the messages with an email or a phone number.

= 0.2.8 =
* When a visitor leaves a phone number or an email in the chat and agrees to be contacted, the team gets an email with the contact and a short summary of the conversation.

= 0.2.7 =
* The chat button no longer covers cookie consent banners; the open chat window stays on top.
* Shorter answers with one question at a time; every answer leads the visitor to the next step.

= 0.2.6 =
* The shadow under the chat button and window can be turned off in Appearance.

= 0.2.5 =
* The AI notice folds to one line after 5 seconds; a small arrow shows the full text.
* The chat button can be moved away from other buttons, such as “back to top”, in Appearance.
* A light brand colour (such as lime or yellow) marks only the chat button and the frames; inside the chat the header, messages and buttons use dark colours that are easy to read.

= 0.2.4 =
* More room inside product cards.
* A visitor who describes a need that your products or services solve gets help instead of an off-topic reply.

= 0.2.3 =
* On phones and tablets the page no longer zooms in when the visitor types, and the keyboard opens only after tapping the message field.
* On phones the chat stays above the keyboard, with the header and the message field visible.
* Products without their own image are shown without an image box.

= 0.2.2 =
* Answers include the full address of the matching page, shown as a clickable link.

= 0.2.1 =
* The advisor links to the matching page whenever it talks about something that has its own page.

= 0.2.0 =
* The advisor learns the whole website automatically, including page-builder content, and recognises contact, booking and quote forms.
* Links to your own pages in answers are clickable.
* Services and packages as an allowed topic.

= 0.1.0 =
* First release.

== Upgrade Notice ==

= 0.2.27 =
On phones the chat button no longer covers the open chat window. Existing settings are kept.

= 0.2.26 =
The appearance preview follows every field before saving and the Save button stays in view. Existing settings are kept.

= 0.2.25 =
The close button of the message next to the chat button is centred. Existing settings are kept.

= 0.2.24 =
The message limit for other pages ignores home page views. Existing settings are kept.

= 0.2.23 =
Rotating messages next to the chat button and how often they appear. Existing settings are kept.

= 0.2.22 =
New content is learned right after saving. Existing settings are kept.

= 0.2.21 =
Choose how long the message next to the chat button stays. Existing settings are kept.

= 0.2.20 =
The message next to the chat button waits for cookie banners to close. Existing settings are kept.

= 0.2.19 =
The message next to the chat button is no longer hidden behind cookie banners. Existing settings are kept.

= 0.2.18 =
Chat button entrance animations and an optional message next to the button. Existing settings are kept.

= 0.2.17 =
Translation loading for WordPress.org language packs. Existing settings are kept.

= 0.2.16 =
Appearance preview and key field fixes. Existing settings are kept.

= 0.2.15 =
Shows a dot on the chat button when a reply is waiting. Existing settings are kept.

= 0.2.14 =
Adds a layer (z-index) setting for the chat button. Existing settings are kept.

= 0.2.13 =
Readme and link corrections. No changes to settings or data.

= 0.2.12 =
Shared admin theme update.

= 0.2.11 =
Settings panel styles fixed next to some other plugins.

= 0.2.10 =
Correct text direction for right-to-left languages.

= 0.2.9 =
Contact details are easy to spot in the conversation history.

= 0.2.8 =
Call-back requests from the chat reach your team by email.

= 0.2.7 =
Shorter answers that lead visitors to the next step.

= 0.2.6 =
Optional shadow under the chat.

= 0.2.5 =
Readable chat with light brand colours.

= 0.2.4 =
Roomier product cards and comfortable typing on phones.

= 0.2.3 =
Comfortable typing on phones and tablets.

= 0.2.2 =
Clickable links to your own pages in answers.

= 0.2.1 =
Better links to your own pages in answers.

= 0.2.0 =
Learns your whole website automatically. Existing installations switch to automatic learning; choose "Use only the pages I select" to keep the old behaviour.
