=== Spirit Store Chat ===
Contributors: automatedintelligentsolutions
Tags: chat, chatbot, woocommerce, storefront, n8n
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A brandable store-assistant chat widget for Spirit Store sites, powered by your own n8n chatbot workflow. Auto-themes to each group's colors.

== Description ==

Adds a polished chat experience to your storefront. Visitors ask about products, packages, prices, and order deadlines; answers come from YOUR automation workflow (an n8n webhook you host and control) reading live store data — so the assistant never guesses stock or prices.

Built as the companion to the Spirit Store plugin, which runs branded storefront sections for every group you sell to — schools, teams, leagues, companies, chapters. The widget follows Spirit Store's Terminology setting, so its options speak your language ("Team pages only", "Team Colors", and so on).

**Features**

* **Entity theming**: on a group's storefront pages the widget automatically adopts that group's primary and secondary colors and its logo (via the Spirit Store plugin); your configured brand colors and logo apply everywhere else. Can be disabled to force one fixed brand.
* Movable, resizable, dockable chat window; launcher as icon bubble or text pill; bottom-left or bottom-right
* Fully brandable: colors, logo/avatar, company and assistant names, greeting + secondary message, status text, input placeholder, connection-error message
* Optional booking/contact button below the input (e.g. "Contact Your Sales Rep")
* Conversation and window position remembered across pages (optional, browser storage)
* Auto-open after a configurable delay (once per visitor)
* Display rules: all pages, homepage only, group pages only, or only pages with the [ssf_chatbot] shortcode
* Inline embed mode: [ssf_chatbot] renders the chat in-page (Elementor Shortcode widget friendly); [ssf_chatbot mode="floating"] marks a page for the floating widget in shortcode display mode
* Safe rich replies: minimal Markdown (links, images, lists, bold/italic) with HTML-escaped input and http(s)-only URLs
* Custom CSS box and z-index control

**External service disclosure:** this plugin sends data only to the webhook URL the site administrator configures — typically your own n8n instance. Nothing is sent until a webhook URL is set and a visitor voluntarily types a message. Sent per message: the message text, a random session identifier, the current group's slug, the logged-in customer's chosen home-group slug and a logged-in yes/no flag (no name, email, or other personal details), and your configured terminology label (e.g. "team"). What your workflow does with messages (e.g., calling an AI provider) is under your control and should be reflected in your site's privacy policy.

== Installation ==

1. Upload and activate the plugin.
2. Go to Settings → Spirit Chat, paste your n8n chatbot workflow's production webhook URL, and brand the widget.
3. Optionally add a booking/contact link, choose the launcher style and display rules.
4. Visit the site — the launcher appears once the webhook URL is set.

Works with the Spirit Store Chatbot Agent workflow (expects {message, sessionId, school}, returns {reply}) and with n8n Chat Trigger URLs (sends chatInput/sessionId, reads output).

== Frequently Asked Questions ==

= Does the widget follow each group's colors? =
Yes — with the Spirit Store plugin active, the widget reads each storefront page's colors automatically. Toggle the colors checkbox off in settings to always use your configured brand colors.

= Does it work without the Spirit Store plugin? =
Yes. It becomes a general store-assistant widget using your configured brand colors; the per-group theming and "group pages only" display rule simply have nothing to attach to.

= Can I embed the chat in a page instead of floating? =
Yes: [ssf_chatbot] (attributes: height, width, max_width). The floating launcher hides automatically on pages with an inline embed.

== Changelog ==

= 0.4.0 =
* Member-aware chat: when a logged-in customer has picked a home entity (Spirit Store 0.8.0's My Account field), the widget sends that slug (userEntity) and a logged-in flag with each message, so the assistant knows their storefront even on general pages. Page context still wins when present. No names or personal details are sent.

= 0.3.1 =
* On entity pages the widget now also wears that entity's logo (same toggle as the colors); the configured logo is the fallback elsewhere.
* The webhook payload now includes entityLabel (the site's lowercase Terminology singular) so the chatbot workflow can speak your nomenclature; payload otherwise unchanged.

= 0.3.0 =
* Renamed to Spirit Store Chat with plugin slug/folder `spirit-store-chat` and matching text domain. Upgrading from School Storefronts Chat: deactivate and delete the old plugin, then install and activate this one — all settings carry over (the option key is unchanged).
* Labels now follow the Spirit Store plugin's Terminology setting (School, Team, Company, ...); generic "Entity" wording when the main plugin is absent. Settings menu is now Settings → Spirit Chat.
* No functional changes: shortcode [ssf_chatbot], webhook payload ({message, sessionId, school}), CSS prefixes, and color-variable theming are all identical.

= 0.2.1 =
* Compatibility with School Storefronts 0.5.0 (renamed internal prefix) while remaining compatible with older versions. Declared WordPress 7.0 compatibility.

= 0.2.0 =
* Complete redesign on the AIS Chatbot engine: movable/resizable/dockable window, launcher styles, booking button, greeting pair, persistence, auto-open, display modes, inline [ssf_chatbot] embeds, Markdown replies, custom CSS.
* School-color theming retained and now toggleable; new "School pages only" display mode.
* Settings migrate automatically from 0.1.x.

= 0.1.0 =
* Initial release.
