=== Nexu SmartChat AI ===
Contributors: nexuvibe
Tags: chatbot, ai, openai, gemini, claude, mistral, rag, chat, customer support, live chat
Requires at least: 6.0
Tested up to: 6.8
Requires PHP: 8.0
Stable tag: 1.0.36
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI-powered chatbot with RAG technology that auto-indexes your site content and provides smart, accurate answers to visitors.

== Description ==

**Nexu SmartChat AI** is a powerful WordPress chatbot plugin that uses Retrieval-Augmented Generation (RAG) to automatically index your website content and provide intelligent, context-aware responses to visitors.

= Key Features =

* **RAG Technology** — Automatically indexes posts, pages, WooCommerce products, and custom post types.
* **Multiple AI Providers** — Works with OpenAI, Google Gemini, Anthropic Claude, Mistral, and Azure OpenAI.
* **Real-time Streaming** — SSE-based streaming responses for a smooth chat experience.
* **Multi-Bot Support** — Create multiple bots with different personas and settings.
* **Shortcode & Block** — Embed the widget inline via shortcode, Gutenberg block, or Elementor widget.
* **Human Handoff** — Automatically escalate to a human via email or webhook.
* **Lead Generation** — Capture visitor info before or during chat.
* **Security** — AES-256 encryption, rate limiting, IP blocking, and prompt injection protection.
* **GDPR Compliant** — IP anonymization and automatic data retention/cleanup.
* **RTL Support** — Full right-to-left language support.
* **Fully Customizable** — Colors, fonts, position, dimensions, and custom CSS.
* **Analytics** — Track conversations, messages, tokens, and ratings.

= Supported Providers =

1. OpenAI (GPT-4, GPT-3.5, text-embedding-3-small)
2. Google Gemini (gemini-pro, embedding-001)
3. Anthropic Claude (claude-3, claude-2)
4. Azure OpenAI

= Usage =

1. Install and activate the plugin.
2. Go to **SmartChat AI > API Settings** and configure your AI provider.
3. Go to **Content Sources** and start indexing.
4. Customize the widget in **Appearance** and **Display** tabs.
5. The chatbot will appear on your site automatically.

**Shortcode:** `[nexu_smartchat bot_id="1"]`

== Installation ==

1. Upload the `nexu-smartchat-ai` folder to `/wp-content/plugins/`.
2. Activate the plugin through the Plugins menu.
3. Navigate to SmartChat AI in the admin menu.
4. Follow the setup wizard to configure your AI provider.

== Frequently Asked Questions ==

= Which AI providers are supported? =
OpenAI, Google Gemini, Anthropic Claude, and Azure OpenAI.

= Does it work with WooCommerce? =
Yes! It can index WooCommerce products, including price, SKU, and description.

= Is it GDPR compliant? =
Yes. You can enable IP anonymization and set automatic data retention periods.

= Can I have multiple chatbots? =
Yes, you can create multiple bots with different personas and configurations.

== Changelog ==

= 1.0.36 =
* Make product answers shorter and more focused; enforce multi-line formatting in prompt
* Preserve line breaks in KNOWLEDGE to improve readable answers
* Add server-side line break safeguard for long single-paragraph replies
* Widget typography: default font size set to 13px and passed to frontend for customization; remove default "Vazir" setting

= 1.0.35 =
* Fix incorrect sources on greetings/small-talk: skip RAG retrieval and hide sources
* Improve sources accuracy: only show sources that are referenced in the final answer (streaming included)
* Fix typing indicator placement in streaming: show dots inside the current bot message bubble

= 1.0.34 =
* Complete RAG system overhaul: hybrid search (FULLTEXT keyword + semantic embedding with RRF fusion)
* Smart product chunking: each product indexed as a single compact card with all info
* Binary-packed embeddings: 60% smaller storage, faster decode
* Pre-computed magnitude column: eliminates runtime vector magnitude calculation
* Conversation-aware query expansion: follow-up questions inherit context from history
* New KeywordSearch class: MySQL FULLTEXT for exact term matching
* Simplified retrieve_context with single hybrid_search call

= 1.0.33 =
* Complete rewrite of AI system prompt for natural, human-like responses: bot now acts as a shop assistant, never mentions "context" or "available text"
* Bot suggests alternatives when requested product/spec is unavailable instead of just saying "no info"
* Follow-up questions use conversation history seamlessly

= 1.0.32 =
* Fix product follow-up questions in Persian (capacity/GB): improve product-query detection and allow safe follow-up answers using conversation history

= 1.0.31 =
* Improve greeting handling: allow short natural replies for greetings/thanks without requiring RAG context (prevents "no info" replies to "سلام")

= 1.0.30 =
* Fix indexing progress stuck when WP-Cron loopback is blocked: process a small queue batch during progress polling (with lock)

= 1.0.29 =
* Add policy pages auto-indexing: detect WooCommerce Terms and WordPress Privacy Policy pages and always include them in indexing
* Add optional manual policy page selection in Content Sources (for return/refund policy page)
* Auto-queue policy pages when their linked options change or when settings are saved
* Fix embeddings deletion helper to delete by source_id (was using a wrong column)

= 1.0.28 =
* Fix RAG product retrieval: remove unreliable language filter that excluded mixed-language products
* Add product-level deduplication so the bot sees up to 8 unique products instead of repeated chunks from 1-2 products
* Rewrite AI prompt rules to list ALL products from context as a numbered list for product queries
* Improve product content extraction: add stock status, full description, product tags, and variations
* Fix language detection during indexing: detect from full text instead of first chunk only

= 1.0.26 =
* Improve product queries: prefer WooCommerce product chunks in RAG context retrieval with smart fallback
* Reduce irrelevant sources by using two-pass similarity search and language-aware filtering with fallback
* Enhance prompt context formatting with source titles so the bot can list multiple options when available

= 1.0.25 =
* Fix chat bubble inline-block issue causing messages to overlap vertically

= 1.0.24 =
* Fix chat bubble width calculation: restore flex-direction and box-sizing to prevent overlapping
* Revert broken width: 100% logic and properly set display to inline-block for precise max-width wrapping

= 1.0.23 =
* Completely rewrite chat bubble flexbox layout to fix width and text overflow issues natively
* Remove legacy RTL flex overrides (allow flex-start/flex-end to flip correctly per locale)

= 1.0.21 =
* Fix chat bubble expanding: bubble background now properly covers all text content
* Add flex layout properties (flex:1, min-width:0, word-break) to message bubbles
* Shorten AI responses: rewrite system prompt for concise, conversational answers (2-4 sentences)
* Remove filler phrases and excessive verbosity from bot behavior

= 1.0.20 =
* Add PO file fallback loader for translations when .mo is not available
* Improve translation loading with locale fallbacks

= 1.0.19 =
* Increase bottom padding in chat messages area for better spacing above input
* Fix streaming bot replies persistence (save streamed content to localStorage so messages remain after refresh)

= 1.0.18 =
* Fix frontend widget text becoming invisible under Elementor/theme gradient text rules (force -webkit-text-fill-color)
* Enqueue RTL font CSS only when IMedium.woff2 exists (prevent broken font loading)
* Improve translation loading with locale fallbacks (fa_IR -> fa) and generic `nexu-smartchat-ai.mo`

= 1.0.17 =
* Full CSS isolation for frontend chat widget to prevent Elementor / theme / plugin style bleed
* All widget selectors now use high-specificity scoping and !important guards
* Fix list-style, table display, and font inheritance issues caused by third-party CSS resets

= 1.0.16 =
* Add typing indicator for streaming bot responses
* Normalize chat bubble typography (consistent font-size, line-height, headings)
* Redesign source links as pill/chip buttons with hover effects

= 1.0.15 =
* Fix stale similarity-cache causing empty RAG context after re-indexing

= 1.0.14 =
* Apply local RTL font (IMedium.woff2) consistently on frontend widget and admin settings when RTL is enabled

= 1.0.13 =
* Fix RAG context retrieval after switching AI providers (prevent cross-embedding mismatches)
* Auto-clear embeddings when provider/embedding model changes before re-indexing

= 1.0.11 =
* Add Mistral provider (Chat + Embeddings) with connection test
* Add recommended Mistral models (Large + Mistral Embed) in API Settings

= 1.0.9 =
* Add "Only Index In-Stock Products" option for WooCommerce stores
* Skip out-of-stock products during bulk indexing
* Auto-remove embeddings when a product goes out of stock
* Auto-requeue product for indexing when it comes back in stock

= 1.0.8 =
* Fix admin conversation table layout for long IP addresses (truncated display)

= 1.0.7 =
* Fix admin modal positioning and entrance animation (center align with flexbox)

= 1.0.6 =
* Fix similarity search caching (cache key now includes threshold/top_k)
* Use practical default similarity threshold for RAG context retrieval

= 1.0.5 =
* Fix OpenAI connection test (use GET /models)

= 1.0.4 =
* Fix “Saved key” display formatting in API Settings

= 1.0.3 =
* Show masked “Saved key” status in API Settings for clarity

= 1.0.2 =
* Improve admin save error visibility (show real AJAX/server errors)
* Add safe exception handling to settings save handler

= 1.0.1 =
* Fix admin settings saving across all tabs (proper serialization for arrays and bracketed keys)
* Prevent accidental API key wipe when saving other settings

= 1.0.0 =
* Initial release
* RAG engine with content extraction, chunking, and vector embeddings
* Support for OpenAI, Gemini, Claude, and Azure OpenAI
* SSE streaming chat
* Multi-bot management
* Shortcode, Gutenberg block, and Elementor widget
* Human handoff and lead generation
* Rate limiting, IP blocking, and encryption
* Full admin panel with 9 tabs
* RTL support
* GDPR compliance features
