=== gmss-agent ===
Contributors: gmsspress
Tags: chat, chatbot, faq, knowledge base, support
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Floating chat widget that answers visitor questions from a JSON knowledge base on your own server. No external API, no data leaves your site.

== Description ==

gmss-agent adds a customizable floating chat widget to every page of your WordPress site. Visitor questions are answered by matching them against a JSON knowledge-base file you provide. Everything runs locally on your server — no API key, no third-party service, no visitor data sent anywhere.

The plugin is designed for support, FAQ, and lightweight pre-sales conversations where you want answers limited to information you have written and approved.

**Features**

* Floating chat widget with configurable title, welcome message, primary color, and corner position (bottom-right or bottom-left).
* Local matcher with weighted token-overlap scoring: title hits and explicit keyword hits are ranked above body hits, with a phrase bonus when the visitor's full query appears in an entry.
* Optional `keywords` array on each entry to handle synonyms the body text does not contain.
* Configurable fallback reply when no entry matches the visitor question.
* JSON knowledge base loaded from a single `knowledgebase.json` file at the root of your WordPress install.
* Ships with a sample knowledge base so the widget answers something out of the box.
* REST endpoint protected by a WordPress nonce.
* Translation-ready (text domain: `gmss-agent`).

**Requirements**

* WordPress 5.8 or newer and PHP 7.4 or newer.

== Installation ==

1. Upload the `gmss-agent` folder to `/wp-content/plugins/` (or install through the Plugins screen in WordPress).
2. Activate the plugin through the **Plugins** screen.
3. Go to **Settings > gmss-agent** and customize the widget title, welcome message, fallback message, primary color, and position.
4. Create a file named `knowledgebase.json` at the root of your WordPress install (the same folder as `wp-config.php`). The Settings page shows the exact expected path and a format example. A sample file ships with the plugin at `wp-content/plugins/gmss-agent/knowledgebase-sample.json` — until you create your own, the widget will answer using the sample.
5. Visit your site front-end; the chat widget will appear in the configured corner.

== Frequently Asked Questions ==

= Does this plugin send anything to a third party? =

No. Visitor questions are matched against your local `knowledgebase.json` file on your own server. No external service is contacted, no API key is required, and no visitor data leaves your site.

= How does the matching work? =

For each question, the plugin scores every entry in your knowledge base. A point is awarded each time a query word matches the entry's body, three points when it matches the entry's title, and five points when it matches one of the entry's optional `keywords`. The entry with the highest non-zero score wins; if nothing scores above zero, the visitor sees your configurable fallback message.

= What is the knowledge base file format? =

A JSON array of objects, each with a `content` string and an optional `title` and `keywords` array. The Settings page shows a complete example, and a sample file is bundled with the plugin.

= Can I use synonyms or alternate phrasings? =

Yes — add a `keywords` array to any entry. For example, an entry titled "Pricing and Quotes" might list `["price", "cost", "quote", "discount"]` so the widget answers regardless of which word the visitor types.

= What happens when no entry matches? =

The visitor sees the fallback message you configured on the Settings page. The default is "I'm not sure how to answer that. Please contact our team for help."

= Does it work on multisite? =

Yes. Each site stores its own settings. The uninstall routine cleans options across the entire network.

= Where is the knowledge base file expected? =

In the root of your WordPress installation — the same folder as `wp-config.php`. The Settings page shows the exact filesystem path on your server.

== Screenshots ==

1. The floating chat widget answering a visitor question from the knowledge base.
2. The Settings > gmss-agent page with widget appearance options.
3. The knowledge base status panel showing the file path and detected entry count.

== Changelog ==

= 1.1.0 =
* Removed all external API dependencies. Replies are now generated locally by matching visitor questions against the knowledge base file.
* Renamed `knowledgebase.js` to `knowledgebase.json` and dropped the JS-wrapper parser in favor of pure JSON.
* Added optional `keywords` array on each entry for synonym matching.
* Added a configurable fallback message setting for unmatched queries.
* Removed the Anthropic API key and AI model settings.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.1.0 =
The plugin no longer contacts any external API. If you previously stored an Anthropic API key, it is now ignored (and will be removed on uninstall). Rename `knowledgebase.js` to `knowledgebase.json` in your WordPress root and ensure the file is valid JSON.

== Privacy ==

The plugin does not set cookies, does not write to any custom database tables, does not contact any external service, and does not log visitor messages on your server. Settings are stored in the standard WordPress `wp_options` table and are removed when the plugin is uninstalled via the Plugins screen. The knowledge base file you create is read from disk on each request and is never transmitted off your server.
