=== Layerworks AI Chatbot ===
Contributors: layerworks2026
Tags: chatbot, ai, openai, support, knowledge-base
Requires at least: 6.5
Tested up to: 7.0
Requires PHP: 8.1
Stable tag: 0.1.62
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

An AI chatbot for WordPress sites. It helps small businesses and site administrators answer visitor questions using reviewed site knowledge.

== Description ==

Layerworks AI Chatbot adds an AI chatbot to WordPress sites. It is designed for small businesses, shops, local organizations, and service websites that want to answer visitor questions based on reviewed site knowledge.

The plugin uses administrator-reviewed basic knowledge and supplemental knowledge collected from published content to answer visitor questions based on the site. Basic knowledge is created from selected published pages, then reviewed and saved by an administrator. Supplemental knowledge can be collected from published posts and custom post types.

Developed by LAYERWORKS Co., Ltd.

This plugin does not automatically train or fine-tune an AI model from conversations. Administrators review site content and inquiry records manually. Basic usage counts are shown from saved logs.

Main features:

* Chat widget for the front end
* Safe readable formatting for chatbot replies, including lists, bold text, and links
* OpenAI Responses API integration
* Separate OpenAI model settings for chat responses and knowledge design
* Basic knowledge setup from selected published pages with editable review flow
* Editable fixed knowledge sections
* Background supplemental knowledge collection from published posts and custom post types
* Protected terms to keep product names, service names, and brand names unchanged
* Widget position and margin adjustment to avoid overlap with fixed page buttons
* Widget motion effect setting
* Bundled chatbot icon selection
* Response style selection
* Device visibility controls for desktop, tablet, and mobile
* Excluded page ID setting to hide the widget on specific posts, pages, and custom posts
* Inquiry form and inquiry management screen
* Inquiry email notifications with configurable recipient, subject, body, and test sending
* Chat log review, search, deletion, and CSV export
* Chat log storage retention and cleanup settings
* Basic usage insights from saved chat logs
* Rate limit and safety settings visibility
* Automatic multilingual response handling
* English source strings with bundled Japanese translation files

The core chatbot, knowledge management, inquiry form, inquiry management, inquiry email notifications, chat log review, CSV export, log storage settings, basic usage insights, and response style features are included in this plugin.

== External Services ==

This plugin connects to the OpenAI API, using the API key configured by the site administrator, to generate chatbot responses and to help administrators create editable knowledge drafts.

Service: OpenAI API
Endpoint used: https://api.openai.com/v1/responses

The plugin does not send data to OpenAI until an administrator configures an OpenAI API key and uses a feature that requires AI processing, such as a visitor chat response, the admin test chat, the OpenAI connection test, or basic knowledge creation.

When OpenAI settings are configured and a visitor sends a message, the plugin may send the following information to OpenAI:

* The visitor's message
* Recent conversation history
* Basic knowledge configured by the site administrator
* Supplemental knowledge collected from published posts and custom post types
* Protected terms configured by the site administrator
* The current page URL, when it is used as part of the chat context

When an administrator creates basic knowledge, the plugin may also send selected published page content, current knowledge sections, protected terms, and the site name and URL to OpenAI.

When an administrator uses the test chat, the test message and the same knowledge context may be sent to OpenAI. Test chat conversations are not stored as chat logs by this plugin.

The OpenAI API key is stored in the WordPress database and is not exposed to visitors. Saved API keys are not printed back into the settings field. The plugin should not automatically include private administrator-only information, such as the WordPress admin email address, in generated knowledge.

OpenAI terms and privacy information:

* https://openai.com/policies/terms-of-use/
* https://openai.com/policies/privacy-policy/

== Chatbot Response Languages ==

The chatbot response language is not limited to Japanese and English.

The chatbot detects the visitor's language and tries to answer in the same language where possible. Important business, pricing, contract, disclaimer, and contact information should be based on administrator-configured knowledge and should not be guessed.

== Plugin Interface Languages ==

The plugin interface uses English source strings and includes bundled Japanese translation files so that both English-speaking and Japanese site administrators can use it.

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/layerworks-ai-chatbot/` directory.
2. Activate the plugin through the Plugins screen in WordPress.
3. Open `Layerworks AI Chatbot > Settings` and set your OpenAI API key and model.
4. Run the OpenAI connection test next to the API key field.
5. Open the knowledge screen, select the published pages to use, and create the basic knowledge.
6. Test the chatbot on the front end.

== Frequently Asked Questions ==

= Does this plugin automatically learn from conversations? =

No. It does not automatically train or fine-tune an AI model. Administrators review site information and inquiry records manually. Basic usage counts are shown from saved logs.

= Which languages are supported? =

The chatbot can automatically respond in multiple languages where possible. The plugin admin interface uses English source strings and includes Japanese translation files.

= Does this plugin require an external API? =

Yes. It requires an OpenAI API key to generate responses.

= Why is the chat widget not visible after activation? =

The widget is not shown to visitors until an administrator saves an OpenAI API key. This prevents an unconfigured chatbot from appearing on a live site.

= Are chat logs saved? =

The plugin stores public chat messages, AI replies, page URL, IP address, user agent, token usage, and estimated cost in the WordPress database so that safety controls, basic usage insights, retention cleanup, and privacy export/erasure can work. Old chat logs are automatically deleted after the configured retention period. Administrators should review their privacy policy and avoid collecting unnecessary personal information.

= Does the inquiry form save personal information? =

If the inquiry form is enabled, the visitor's name, email address, phone number, message, page URL, IP address, user agent, inquiry status, and administrator notes may be stored in the WordPress database. Administrators should disclose this in their privacy policy and handle the data carefully.

= Can stored personal data be exported or erased? =

Yes. The plugin registers with the WordPress personal data export and erasure tools for inquiry records and related chat logs that can be matched by email address or inquiry session.

= What happens when the plugin is deleted? =

When the plugin is uninstalled, plugin settings, generated knowledge, supplemental knowledge queues, scheduled events, chat log tables, and inquiry tables are removed.

== Screenshots ==

1. Chat widget
2. Settings screen
3. Basic knowledge setup and review screen
4. Supplemental knowledge collection targets and status
5. Knowledge source overview

== Changelog ==

= 0.1.62 =

* Fixed admin screen JavaScript output so supplemental knowledge target panels open correctly after the WordPress.org package conversion.

= 0.1.61 =

* Fixed missing admin screen styling in the WordPress.org package for knowledge setup and related management screens.

= 0.1.60 =

* Improved basic knowledge fact extraction by filtering UI noise, reducing duplicates, and pruning redundant rendered lines.
* Added a knowledge source overview panel to make basic and supplemental knowledge status easier to understand.
* Collapsed basic and supplemental setup sections after setup, while keeping important progress and error states visible.
* Improved the setup accordion headers so re-setup and collection actions are easier to find.
* Improved the first basic knowledge setup flow by hiding manual additional-item editing until basic knowledge exists.
* Improved basic knowledge wording cleanup so missing business-hour details become natural visitor guidance.
* Improved contact/application knowledge cleanup so temporary announcements and campaign excerpts are not mixed into stable contact guidance.
* Improved contact/application cleanup to remove footer text, copyright text, duplicated address/phone blocks, and long business-description excerpts.
* Applied contact/application cleanup when displaying existing drafts or saved basic knowledge.
* Added character counters and save-time length checks for basic knowledge content fields.
* Made reply rule sections visually distinct and moved the Add Item button into the Additional Items area.
* Replaced the supplemental auto-recollection checkbox with explicit enable/stop buttons.
* Added supplemental knowledge collection target settings for all content, selected post types, or selected public taxonomy terms.
* Improved persistence for supplemental collection target settings so selected scopes remain active after saving.
* Added a stop button for supplemental knowledge collection that cancels the remaining queue while keeping already collected knowledge.
* Added supplemental knowledge item and content-size limits for large sites, with filters for site-specific tuning.
* Added a queue-processing lock for supplemental knowledge collection to avoid overlapping cron runs.
* Raised the widget z-index so it is less likely to appear behind fixed theme elements.
* Expanded the bundled chatbot icon selection to eight choices and placed the newest icons first.
* Added color-code input, preview, presets, and default reset controls for chatbot button colors.
* Improved duplicate filtering for AI-suggested knowledge sections, including English standard-section labels.
* Ensured inquiry email notifications, chat log review, CSV export, log storage settings, and basic usage insights work without external dependencies.
* Replaced hardcoded admin script and style tags with WordPress inline asset APIs.

= 0.1.59 =

* Hardened public REST behavior for cached pages by removing the front-end nonce dependency.
* Added chat log retention cleanup and clarified the privacy wording.
* Improved site-language handling for chat prompts and supplemental knowledge prompts.
* Improved user-facing error messages, widget accessibility labels, and Japanese translations.
* Cleaned up obsolete knowledge setup code paths and submission-readiness details.

= 0.1.0 =

* Initial development version.
* Added chat widget and REST API endpoints.
* Added OpenAI Responses API integration.
* Added fixed-section knowledge editing.
* Added basic knowledge setup and supplemental knowledge collection.
* Added chat logs and insight view.
* Added automatic multilingual chatbot response handling.
* Added internationalization foundation for Japanese and English plugin UI.

== Upgrade Notice ==

= 0.1.0 =

Initial development version.
