=== Spark SEO Free AI Website Chatbot Widget ===
Contributors: sparkseo, fion1983
Tags: chatbot, ai, sales, woocommerce, lead generation
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 2.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI-powered sales chatbot with action-based setup, AI site scanner, lead capture, and Claude AI streaming.

== Description ==

Spark SEO Free AI Website Chatbot Widget adds an intelligent conversational sales assistant to your WordPress site. It uses Anthropic's Claude AI to engage visitors, qualify leads, and drive conversions.

**Action-based setup** — Tell the chatbot what you want visitors to do (book a meeting, contact you, learn about your services, etc.) and it tailors its conversation accordingly.

**AI-powered site scanner** — The setup wizard scans your website and uses Claude to auto-generate a business-specific system prompt, welcome message, and chatbot personality. No prompt engineering required.

**Key features:**

* 4-step setup wizard with AI site scanner
* Persuasive sales tactics adapted to visitor behaviour (pain-driven, desire-driven, curious, sceptical)
* Real-time SSE streaming (tokens appear as they are generated)
* Automatic fallback to JSON if streaming is blocked
* Lead capture with WordPress admin list, CSV export, and chat transcripts
* WooCommerce product search and recommendations
* Page/post content search
* Brevo CRM integration
* Zapier/Make webhook support
* Configurable branding (avatar, colours, bot name, tone)
* WCAG 2.1 AA accessible (focus trap, screen reader support, keyboard navigation)
* Quick-reply buttons and conversation persistence
* Daily auto-reindex via WP Cron

== External Services ==

This plugin connects to the following third-party services:

= Anthropic API (Required) =

The plugin sends chat messages and website content to Anthropic's Claude AI API for processing.

* **Service:** [Anthropic API](https://www.anthropic.com/)
* **When data is sent:**
  * During initial setup — your website's homepage, about page, contact page, and page excerpts are sent to generate the chatbot's system prompt (one-time, uses Claude Opus).
  * During each chat conversation — visitor messages and conversation history are sent to generate AI responses (uses your selected model).
* **Data transmitted:** Chat messages, conversation history, website content (during setup only). No personal visitor data is sent unless the visitor shares it in the chat.
* **Terms of Service:** [https://www.anthropic.com/terms](https://www.anthropic.com/terms)
* **Privacy Policy:** [https://www.anthropic.com/privacy](https://www.anthropic.com/privacy)
* **API key required:** Yes. You must provide your own API key from [console.anthropic.com](https://console.anthropic.com/). Your API key is encrypted at rest using AES-256-CBC.

= Brevo API (Optional) =

If configured, the plugin sends captured lead details to your Brevo (formerly Sendinblue) account.

* **Service:** [Brevo](https://www.brevo.com/)
* **When data is sent:** When a visitor provides their name and email during a chat conversation.
* **Data transmitted:** Lead name, email address, and phone number (if provided).
* **Terms of Service:** [https://www.brevo.com/legal/termsofuse/](https://www.brevo.com/legal/termsofuse/)
* **Privacy Policy:** [https://www.brevo.com/legal/privacypolicy/](https://www.brevo.com/legal/privacypolicy/)

= Anonymous Usage Telemetry =

When a visitor opens the chat widget, the plugin sends a lightweight ping to a Spark SEO server. This helps the developer understand how many sites actively use the plugin.

* **Service:** Spark SEO telemetry server (telemetry.sparkseo.uk)
* **When data is sent:** Each time the chat widget is opened by a visitor.
* **Data transmitted:** The site's domain name and plugin version number. No personal visitor data, cookies, or IP addresses are stored.
* **Privacy Policy:** [https://sparkseo.net/privacy-policy](https://sparkseo.net/privacy-policy)

= Webhook (Optional) =

If configured, the plugin sends a POST request with lead data to your specified webhook URL (e.g. Zapier, Make).

* **When data is sent:** When a visitor provides their contact details during a chat.
* **Data transmitted:** Lead name, email, phone, and notes.

== Installation ==

1. Upload the `sparkseo-ai-chatbot-widget` folder to `/wp-content/plugins/`
2. Activate the plugin through the Plugins menu
3. Go to **AI Chatbot** in the admin menu
4. **Step 1:** Choose what action you want visitors to take (book a meeting, contact you, etc.)
5. **Step 2:** Optionally choose a secondary/fallback action
6. **Step 3:** Enter your company name and Anthropic API key, then click **Test Connection**
7. **Step 4:** Click **Run Setup** — the AI will scan your site and generate the chatbot's prompt
8. Customise settings on the dashboard as needed

== Frequently Asked Questions ==

= Do I need my own API key? =

Yes. You need an Anthropic API key from [console.anthropic.com](https://console.anthropic.com/). The plugin connects directly to Anthropic's API — there is no intermediary server.

= Which Claude model should I use? =

Haiku 4.5 is recommended for day-to-day chat. It is fast, affordable, and follows instructions well. Sonnet 4.5 and Opus 4.6 are available for higher-quality responses at a higher cost. The setup wizard always uses Opus for best results (one-time cost of approximately $0.05-$0.15).

= Does streaming work on shared hosting? =

Most modern hosts support SSE. If your host blocks it (output buffering), disable streaming in Display settings — the chatbot will automatically fall back to standard JSON responses.

= Is my API key stored securely? =

Yes. API keys are encrypted using AES-256-CBC with a key derived from your WordPress security salts before being stored in the database.

= Does the product search require WooCommerce? =

Yes. Product search tools require an active WooCommerce installation. If WooCommerce is not installed, the chatbot will still work for lead capture and page/post content search.

== Changelog ==

= 2.1.0 =
* Renamed plugin to "Spark SEO Free AI Website Chatbot Widget"
* Renamed custom post type from `chatbot_lead` to `aisc_lead` (auto-migrates existing data)
* Credit link defaults to hidden; option to display a subtle attribution
* Improved input sanitization: hex colour validation, boolean clamping, integer and ID list validation, tone allowlist
* Added `fion1983` as contributor

= 2.0.0 =
* Complete redesign: action-based setup replaces business type selection
* AI-powered site scanner generates business-specific prompts automatically
* 4-step setup wizard with progress tracking
* Persuasive sales tactics with objection handling (3A framework)
* WCAG 2.1 AA accessibility (focus trap, aria-live, screen reader support)
* Quick-reply buttons in chat
* Conversation persistence across page navigation
* Chat transcript storage on lead records
* Avatar/logo upload with green online indicator
* API key encryption at rest (AES-256-CBC)
* 20 security fixes including atomic rate limiting, SSRF protection, and input validation
* New conversation button
* Markdown image rendering in chat
* v1 to v2 automatic migration

= 1.0.0 =
* Initial release
