=== Sentient AI - WordPress AI Chatbot with Empathy Engine & Glass Box Transparency ===
Contributors: maidulcu
Tags: ai chatbot, chatbot, openai, customer support, faq, live chat, gpt, claude, gemini, wordpress chatbot, ai assistant, support chatbot, help desk, chat widget
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

The only WordPress AI chatbot with transparent confidence scoring and source attribution. Know why your AI answered what it answered.

== Description ==

**Sentient AI** is a revolutionary WordPress chatbot plugin that doesn't just answer questions — it *manages your site*. With WordPress Autopilot, continuous learning, emotion-aware AI, and transparent confidence scoring, it's the most powerful AI assistant for WordPress.

= Why Sentient AI is Different =

Unlike other chatbots that are black boxes, Sentient AI includes:

* **WordPress Autopilot** — AI agent that manages your site: check updates, find broken images, create posts, scan security
* **Sentient Memory** — Learns from every interaction, builds topic knowledge, and auto-generates FAQs
* **Empathy Engine** — Detects user emotion (frustrated, confused, urgent, happy) and adapts AI response tone
* **Glass Box Transparency** — Every response shows a confidence score (High/Medium/Low) and source attribution
* **5 AI Providers** — OpenAI (GPT-4, GPT-3.5), Claude (Anthropic), Google Gemini, OpenRouter, Hugging Face
* **Auto-Escalation** — Frustrated users and low-confidence answers automatically offer "Talk to a human"

= Perfect For =

* **SaaS companies** — Reduce support tickets with AI that understands user frustration
* **E-commerce stores** — Answer product questions with empathy during checkout issues
* **Agencies** — Deploy smart chatbots for clients with emotional intelligence
* **Membership sites** — Help members find answers without human support, adapting to their mood
* **Blogs & content sites** — Guide readers to relevant content with personalized tone

= Key Features =

**Empathy Engine (v1.4.0)**
* Real-time emotion detection (frustrated, confused, urgent, happy)
* Dynamic system prompts adapt AI tone based on user mood
* Persistent frustration detection auto-escalates to human
* Sentiment analytics dashboard with emotion distribution

**Glass Box Transparency (v1.3.0)**
* Confidence scoring on every AI response (0-100%)
* Source attribution showing which pages/FAQs were used
* Auto-escalation when confidence is low
* Low confidence dashboard for admin review

**Multi-Turn AI Conversations**
* AI remembers previous messages in the conversation
* Configurable context size (3-20 messages)
* Server-side conversation persistence for logged-in users
* Session-based history for guests

**Smart FAQ System**
* Custom FAQ post type with keyword matching
* Confidence-scored FAQ matches
* Auto-create FAQs from chat logs
* CSV import for bulk FAQ upload

**Training Assistant**
* Train AI on your WordPress pages and posts
* WooCommerce product training (Pro)
* Custom post type training (Pro)
* Preview before upload

**Enterprise-Ready Security**
* Rate limiting (5 requests/minute/IP)
* Nonce verification on all AJAX calls
* Capability checks on admin operations
* Input sanitization and output escaping

**Developer-Friendly**
* OOP architecture with namespaces
* Hooks and filters for customization
* REST API ready (coming soon)
* Translation-ready with text domain

= What Users Say =

> "Finally, a chatbot that doesn't just guess — it shows its work." — WordPress developer

> "The confidence scores helped me identify exactly which FAQs needed improvement." — E-commerce owner

> "Reduced our support tickets by 40% in the first month." — SaaS company

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/sentient-ai`
2. Activate the plugin from the **Plugins** menu
3. Go to **Sentient AI → Settings** to configure your AI provider and API key
4. Enable the chatbot and customize the welcome message
5. Place `[sentient_ai_chat]` on any page, or use the floating widget

== Frequently Asked Questions ==

= Does this work without an API key? =

No. You need your own API key from one of the supported providers (OpenAI, Claude, Gemini, OpenRouter, or Hugging Face). The plugin doesn't bundle any AI access.

= What makes this different from other chatbot plugins? =

**Transparency.** Every response shows a confidence score and source attribution. You know exactly why the AI answered what it answered. Other chatbots are black boxes.

= Does it work with WooCommerce? =

Yes! The chatbot works alongside WooCommerce. You can train the AI on your product pages and answer customer questions instantly.

= Can I customize the chatbot's appearance? =

Yes. You can change the welcome message, chat position (left/right), colors via CSS, and toggle confidence scores and source links.

= Does it slow down my website? =

No. The chatbot loads asynchronously in the footer and only loads when enabled. The CSS and JS are lightweight (~15KB combined).

= Is the chat history stored? =

Yes. For logged-in users, conversation history is stored in the database and persists across sessions. For guests, it's stored in the browser session. Admins can view and manage all conversations.

= What happens when the AI gives a wrong answer? =

When confidence is below your threshold (default 50%), the chatbot automatically shows a "Talk to a human" button. You can also review low-confidence queries in the admin dashboard and create FAQs for common questions.

= Does it support multiple languages? =

The chatbot UI supports translation via the standard WordPress text domain system. The AI can respond in any language your AI provider supports.

== Screenshots ==

1. AI chatbot on frontend with confidence badge and source attribution
2. Admin settings page with provider configuration
3. Glass Box: Confidence scores and source links on each response
4. Low confidence dashboard showing queries that need attention
5. Conversations page with full chat history
6. Training assistant for importing WordPress content

== External Services ==

This plugin connects to external AI service providers to generate intelligent chatbot responses. The plugin requires you to configure API credentials for your selected provider.

=== OpenAI ===
* **Service Purpose**: Provides AI-powered responses through OpenAI's GPT models and Assistants API
* **Data Sent**: User queries, conversation history, and your configured assistant context
* **When Data is Sent**: When a user submits a question that doesn't match an existing FAQ
* **API Endpoints Used**: https://api.openai.com/v1/chat/completions, https://api.openai.com/v1/threads, https://api.openai.com/v1/assistants
* **Terms of Service**: https://openai.com/terms
* **Privacy Policy**: https://openai.com/privacy

=== Claude (Anthropic) ===
* **Service Purpose**: Provides AI-powered responses using Anthropic's Claude models
* **Data Sent**: User queries and conversation history
* **When Data is Sent**: When a user submits a question that doesn't match an existing FAQ
* **API Endpoints Used**: https://api.anthropic.com/v1/messages
* **Terms of Service**: https://www.anthropic.com/legal/consumer-terms
* **Privacy Policy**: https://www.anthropic.com/legal/privacy

=== Google Gemini ===
* **Service Purpose**: Provides AI-powered responses using Google's Gemini models
* **Data Sent**: User queries and conversation history
* **When Data is Sent**: When a user submits a question that doesn't match an existing FAQ
* **API Endpoints Used**: https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent
* **Terms of Service**: https://policies.google.com/terms
* **Privacy Policy**: https://policies.google.com/privacy

=== OpenRouter ===
* **Service Purpose**: Provides access to multiple AI models through a unified API
* **Data Sent**: User queries, conversation history, and FAQ context
* **When Data is Sent**: When a user submits a question that doesn't match an existing FAQ
* **API Endpoints Used**: https://openrouter.ai/api/v1/chat/completions
* **Terms of Service**: https://openrouter.ai/terms
* **Privacy Policy**: https://openrouter.ai/privacy

=== Hugging Face ===
* **Service Purpose**: Provides access to open-source AI models
* **Data Sent**: User queries and conversation history
* **When Data is Sent**: When a user submits a question that doesn't match an existing FAQ
* **API Endpoints Used**: https://api-inference.huggingface.co/models/{model}
* **Terms of Service**: https://huggingface.co/terms-of-service
* **Privacy Policy**: https://huggingface.co/privacy

== Changelog ==

= 2.1.0 =
* **WordPress Autopilot** — AI agent that manages your site through chat
* Check for plugin, theme, and WordPress updates
* Find broken images in posts
* List and search posts by keyword
* Create draft posts/pages from chat
* Security vulnerability scanning
* Cache clearing (transient purge)
* Site statistics and health checks
* FAQ and chat log summaries
* Autopilot activity log for admin review
* Action approval system for destructive operations
* Added Autopilot_Agent, WP_Actions, Site_Health_Checker classes

= 2.0.0 =
* **Sentient Memory** — Continuous learning from every interaction
* Automatic topic clustering from user queries
* Thumbs up/down feedback tracking on AI responses
* Auto-FAQ generation for frequently asked questions
* Learning Dashboard with topic distribution and trending topics
* Low quality answer identification for improvement
* Batch FAQ creation from learning patterns
* New database tables: interactions, topics, answer_quality
* Added Memory_Handler, Topic_Clusterer, Auto_FAQ classes

= 1.4.1 =
* Added Quick Reply Suggestions — configurable suggested questions after welcome message
* Up to 5 clickable quick reply chips for faster engagement
* Improved UX with instant response on quick reply click

= 1.4.0 =
* **Empathy Engine** — Detects user emotion in real-time and adapts AI response tone automatically
* Frustrated users get direct, solution-first responses
* Confused users get step-by-step guidance with simple language
* Urgent queries get speed-first responses
* Happy users get warm, conversational engagement
* Persistent frustration detection auto-escalates to human support
* Sentiment Analytics dashboard with emotion distribution
* Frustrated queries review page for admin
* Added Sentiment_Analyzer and Empathy_Prompter classes

= 1.3.0 =
* **Glass Box Transparency** — Every AI response now shows confidence scoring (High/Medium/Low)
* **Source Attribution** — See which pages or FAQs the AI used to generate its answer
* **Auto-Escalation** — Low-confidence answers offer "Talk to a human" button
* **Low Confidence Dashboard** — Admin page to review and address weak AI answers
* **Confidence Settings** — Toggle confidence badges, sources, and escalation threshold
* Added Confidence_Scorer and Source_Tracker classes

= 1.2.0 =
* Added multi-turn conversation context — AI now remembers previous messages
* Added server-side conversation history persistence for logged-in users
* Added configurable context size setting (0-20 messages)
* Added Conversations admin page to view and manage chat history
* All 5 AI providers now support conversation history

= 1.1.1 =
* Fixed rate limiting using transients (works without object cache)
* Fixed FAQ meta save capability check bypass
* Fixed DROP TABLE syntax in uninstall script
* Reduced OpenAI polling max block from 20s to 15s
* Fixed transient bombing on logs page (20 transients -> 1)

= 1.1.0 =
* Added session-based conversation history persistence
* Added TXT export and clear history controls
* Added configurable chat bubble position (bottom-right or bottom-left)
* Improved chat accessibility with ARIA live region and log semantics

= 1.0.0 =
* Initial release with OpenAI, Claude, Gemini, Hugging Face, OpenRouter support
* FAQ response system with fallback AI logic
* Shortcode and floating widget
* Query logs, auto-FAQ generation, and training assistant

== Upgrade Notice ==

= 1.4.0 =
**Major update**: Empathy Engine — AI now detects user emotion and adapts its tone. Frustrated users get direct answers, confused users get step-by-step guidance.

= 1.3.0 =
**Major update**: Glass Box Transparency — see confidence scores and sources on every AI answer. Identify weak answers and improve your FAQs.

= 1.2.0 =
Multi-turn AI conversations and persistent chat history. AI now remembers context.

= 1.1.1 =
Security and performance hotfixes. Recommended update.

= 1.1.0 =
Chat history persistence, export, accessibility improvements.

= 1.0.0 =
First release with multi-AI support.
