=== WP Support Agent - AI Chatbot Trained on Your Site Content ===
Contributors: techcreative
Tags: ai chatbot, chatbot, customer support, live chat, ai assistant
Requires at least: 6.2
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 0.5.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An AI chatbot for WordPress that answers from your own pages, posts and custom post types. Two minute setup, no per-message fees.

== Description ==

**WP Support Agent** adds an AI chatbot to your WordPress site that answers visitor questions using *your* content - your pages, your posts, your courses, your products - instead of making things up.

Setup takes about two minutes. A four step wizard asks who you are, which content the chatbot may read, and which AI service to use. It tests your API key against the real service before it finishes, so you find out immediately if something is wrong instead of discovering it when a customer sees an error.

= Bring your own AI, including the cheap ones =

You connect your own AI account, so there are no per-message fees from us and no middleman holding your data. The wizard walks you through getting a key, step by step, with a direct link to the right page:

* **Google Gemini** - generous free tier, no credit card
* **Groq** - free and extremely fast
* **OpenAI**, **Anthropic Claude**, **Mistral**, **DeepSeek**, **Cerebras**
* **OpenRouter** - one key, hundreds of models, several free
* **Z.ai GLM Coding Plan** and **Moonshot Kimi** - flat monthly subscriptions instead of per-token billing
* **Any OpenAI-compatible or Anthropic-compatible endpoint** - paste a base URL and key
* **Local models** via Ollama or LM Studio, so nothing leaves your server

Available models are read live from your provider, so the list never goes stale.

= Answers from your content, not from the internet =

Choose which post types the chatbot may read - pages, posts, courses, lessons, events, products, anything. It answers from those, links to the right page, and says "I do not have that information" rather than inventing a price or a policy.

A **Primary Context** box lets you write facts that override everything else. Put your real prices, hours and refund policy there and they win over anything out of date elsewhere on the site.

= Built to be affordable and safe to leave running =

* **Daily spend cap** - a hard ceiling on what the site will spend in a day
* **Per-visitor rate limits** so nobody can run up your bill
* **Conversation length limits** so one long chat cannot balloon your costs
* API keys stored **encrypted**, never shown again, never sent to us
* Visitor IP addresses are **never stored** - they are hashed so chats can be rate limited without keeping personal data
* Automatic deletion of old conversations after a period you choose

= Looks like part of your site =

* 24 built-in avatars that take your accent colour automatically - no image editing, no cropping
* Upload your own image instead if you prefer; it is cropped to a square for you
* Accent colour with a **live contrast check** that warns you when a colour will be hard to read
* Light, dark, or follow the visitor's system setting
* Floating button in any corner, or place it yourself with the `[wp_support_agent]` shortcode

= Fast, accessible, and light on your pages =

* Replies **stream in word by word** rather than appearing after a long pause
* Assets load only on pages where the chat actually appears
* No always-running animations draining phone batteries
* Screen reader announcements, full keyboard support, Escape to close
* Respects `prefers-reduced-motion`

== Installation ==

1. Install and activate the plugin.
2. The setup wizard opens automatically. If it does not, go to **Support Agent** in the admin menu.
3. Answer four short steps. You will need an API key from one of the supported AI services - the wizard links you straight to the right page, and two of the options are free.
4. Your chatbot is live.

== Frequently Asked Questions ==

= Do I need to pay for anything? =

The plugin is free. You need an account with an AI service, and two of the supported options - Google Gemini and Groq - have free tiers that need no credit card.

= Will it make things up? =

It is set to answer only from the content you give it. When it does not know, it says so and points the visitor at your support email. You can also write authoritative facts in the Primary Context box that override everything else.

= Can I use my ChatGPT or Claude subscription? =

Not with these services directly - a consumer chat subscription is separate from API access, which is what a website needs. Flat-fee plans that *do* work this way, such as the Z.ai GLM Coding Plan and Moonshot Kimi, are supported as built-in options.

= Does it work with WooCommerce, LearnDash, MemberPress, or my custom post type? =

Yes. The wizard lists every public post type on your site with a count of published items, and you choose which ones the chatbot may read.

= Where is my API key stored? =

Encrypted in your own database, using a key derived from your site's security salts. It is never displayed again after you save it and is never sent anywhere except your chosen AI provider.

= Is it GDPR friendly? =

Visitor IP addresses are never stored - only a salted hash used for rate limiting. You can require consent before the first message, link your privacy policy, and set conversations to delete automatically after a chosen number of days.

== Screenshots ==

1. The four step setup wizard, with guided instructions for getting an API key.
2. The connection test, run against the real service before setup completes.
3. The chat widget on the front end.
4. The avatar picker - 24 built-in icons that take your accent colour.

== Changelog ==

= 0.5.1 =
* Fixed: replies from reasoning models were being cut off mid-sentence. Models such as GLM-4.6 and DeepSeek spend part of the reply budget thinking, and those tokens are billed and counted against the reply length — so the answer a visitor read was clipped. Thinking is now switched off by default, which makes replies complete again and several times cheaper.
* Fixed: the connection test showed a blank reply on those same models, so a healthy connection looked broken. It now allows room to think, and says so explicitly if a model still returns no text.

= 0.5.0 =
* Appearance is now a single screen with a live preview, no longer duplicated as a settings tab.
* Every settings screen shares one set of controls.
* Sticky bar, header and footer placements expand in place instead of opening a popup.
* The settings screen now shows when the API key was last checked, and why a check failed.
* Fixed: the widget could bind its listeners twice if a caching or optimisation plugin loaded the script twice, so one click sent two messages.
* Fixed: the conversation export read every message into memory at once.
* Hardened: cross-site requests to the chat endpoints are refused consistently.

= 0.3.0 =
* Appearance designer: presets, bubble and header styles, depth, fonts, launcher label.
* Placement modes, avatar auto-cropping, per-reply ratings.
* Conversations log with search, filtering, bulk actions and CSV export.

= 0.2.0 =
* Knowledge base built from your content, editable by hand and grouped by post type.
* Reads Markdown from AgentPress MD where present, so page-builder content is understood.
* Answers cite the pages they came from.

= 0.1.0 =
* Initial release.
