=== PetrichorCraft Chatbot ===
Contributors: csoftech, petrichorcraft
Donate link: https://petrichorcraft.com/
Tags: chatbot, faq, ai, live chat, customer support
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 8.0
Stable tag: 1.6.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Hybrid FAQ + optional AI answers and live agent chat in a floating site widget.

== Description ==

PetrichorCraft Chatbot adds a floating help widget so visitors can browse FAQ topics, ask free-text questions (optional AI), or talk to a human agent.

= Features =

* Site-wide floating chat button with configurable colors, size, and mobile layout
* FAQ categories and question chips (works with no AI key)
* Optional free-text answers grounded in your FAQ content
* On WordPress 7.0+, uses the core WordPress AI Client (Settings → Connectors) when a connector is available
* Optional provider API keys (OpenAI, Anthropic Claude, or Google Gemini) as a fallback, including on WordPress 6.x
* Feedback buttons on answers (satisfied / not satisfied / unsure)
* Optional live chat: agents, live inbox, reopenable threads, offline leave-a-message emails
* Shortcode `[pccalc_live_agent]` for “Agent is live” / email fallback inside FAQ answers
* Encrypted API keys at rest, public AJAX rate limiting

= External services =

Free-text AI is **optional**. FAQ chip answers never call an AI service.

On WordPress 7.0 or later, if the site has an AI connector, free-text questions are sent through the WordPress AI Client. The site owner chooses the provider under **Settings → Connectors**. That request is handled by WordPress core and the connector the site owner configured.

If no core connector is available (WordPress 6.x, or no connector set up), and you add a provider API key and enable free-text questions, the plugin sends the question plus selected FAQ context to the provider you configure:

* OpenAI — [Terms](https://openai.com/policies/terms-of-use/) · [Privacy](https://openai.com/policies/privacy-policy/) · API: `https://api.openai.com/`
* Anthropic (Claude) — [Terms](https://www.anthropic.com/legal/consumer-terms) · [Privacy](https://www.anthropic.com/legal/privacy) · API: `https://api.anthropic.com/`
* Google Gemini — [Terms](https://ai.google.dev/gemini-api/terms) · [Privacy](https://policies.google.com/privacy) · API: `https://generativelanguage.googleapis.com/`

Live chat stays on your WordPress site (AJAX); notification emails use `wp_mail`.

= Privacy =

Depending on settings, the plugin may store visitor questions, answers, feedback, and (if enabled) name / email / phone for live chat. Ask logs may store a hashed IP for rate limiting. Review **Settings → Privacy** in WordPress and your own privacy policy. Suggested policy text is registered with WordPress when the plugin is active.

== Installation ==

1. Upload the `pcc-ai-live-chat` folder to `/wp-content/plugins/`, or install the zip via **Plugins → Add New → Upload Plugin**.
2. Activate **PetrichorCraft Chatbot** under **Plugins**.
3. Open **Chatbot** in the admin menu and configure Behavior, Appearance, and (optionally) AI Provider.
4. Edit or replace the sample FAQs under **Chatbot → FAQs** (or Import).
5. Optional (WordPress 7.0+): add an AI connector under **Settings → Connectors**.
6. Optional: add an OpenAI, Claude, or Gemini API key for free-text answers when no core connector is available.
7. Optional: enable Live chat, add agents under **Chatbot → Agents**, and monitor **Chatbot → Live inbox**.

== Frequently Asked Questions ==

= Does free-text AI work without an API key? =

FAQ chips work without any AI setup. Free-text needs “Allow free-text” enabled, plus either a WordPress 7.0 AI connector (Settings → Connectors) or a provider API key.

= Is live chat required? =

No. Leave Live chat disabled if you only want FAQ / AI.

= Where do visitor messages go when agents are offline? =

Visitors can leave a message in the widget. The plugin emails configured notify addresses / support email / linked agent WordPress users.

= Will uninstall delete my FAQs? =

Settings are removed on uninstall. FAQ posts, chat tables, and logs are deleted only if you enable **Delete chatbot content on uninstall** in Behavior settings.

== Screenshots ==

1. Floating help widget with FAQ topics
2. Chatbot settings — Behavior
3. Live inbox for agents

== Changelog ==

= 1.6.4 =
* Prefix uninstall locals; silence one-time meta_key migration warning

= 1.6.3 =
* Use unique `pccalc` prefixes for options, AJAX, CPT, scripts, and shortcodes
* Use the WordPress AI Client on WP 7.0+ when a site connector is available
* Add WordPress.org username to Contributors

= 1.6.2 =
* Silence Plugin Check DB warnings with $wpdb->prefix table SQL and phpcs ignores

= 1.6.1 =
* Align text domain and zip slug with WordPress.org plugin slug `pcc-ai-live-chat`

= 1.6.0 =
* Live chat: agents, live inbox, reopenable sessions, offline messaging and email alerts
* Shortcode `[pccalc_live_agent]` for agent-online / email fallback in FAQ answers
* Mobile panel size settings; visitor resume via localStorage
* Admin doorbell on new / reopened chats; chat close control top-right
* WordPress.org packaging: readme, license, privacy text, external admin JS assets

= 1.0.0 =
* Initial release: floating widget, FAQ CPT, hybrid AI chat

== Upgrade Notice ==

= 1.6.3 =
Uses the WordPress AI Client when available. Existing settings, FAQs, and chat tables are migrated automatically.

= 1.6.0 =
Adds optional live chat, agents, and inbox. Review Behavior → Live chat after updating.
