=== Maca Tjatt ===

Contributors: macas

Tags: chat, chatbot, openai, ai, rag

Requires at least: 7.0

Tested up to: 7.0

Requires PHP: 7.4

Stable tag: 1.3.2

License: GPLv2 or later

License URI: https://www.gnu.org/licenses/gpl-2.0.html



AI chat for your WordPress website using the WordPress AI Client and a local search index.



== Description ==



Maca Tjatt adds a floating chat widget or inline shortcode to your site. Visitors can ask questions and get answers based on your website content.



* Uses the WordPress 7.0 AI Client (no plugin-managed API keys)

* Local search index — relevant website snippets are matched and sent with each question

* Index pages, posts, custom post types, custom knowledge text, and optional download/media plugin content

* Conversational follow-ups with short chat history and live site search when needed

* Floating widget or `[maca_tjatt]` shortcode

* Sensitive values such as API keys, tokens, and passwords are redacted before indexing and before AI requests



**Privacy:** On activation, deactivation, and uninstall, the plugin sends your site URL, plugin version, WordPress version, PHP version, and locale to Maca at `https://api.maca.se/v1/tjatt/events.php` so we can improve the plugin and count active installations. If you choose to send deactivation feedback, your selected reason and optional comment are included. No chat messages, indexed content, or visitor data are transmitted.



Source code: https://github.com/maca59/maca-tjatt



== External services ==



This plugin uses the WordPress AI Client introduced in WordPress 7.0. AI requests are routed through WordPress to whichever provider the site administrator has configured under **Settings → Connectors** (for example the official AI Provider for OpenAI, Anthropic, or Google plugins).



No AI data is sent unless the chat is enabled and a visitor or administrator asks a question, or when an administrator builds the local search index.



= AI providers (via WordPress Connectors) =



Used when an administrator or visitor sends a chat question: the visitor question, a short chat history (last few turns), and relevant indexed text snippets as context are sent through the WordPress AI Client to the configured provider.



Data sent when an administrator builds the search index: website content is stored locally in a custom database table on your site. Indexing does not call an external AI service.



The exact provider, terms, and privacy policy depend on which AI provider plugin the site owner installs and connects. Common official options include OpenAI, Anthropic, and Google.



== Installation ==



1. Use WordPress 7.0 or newer

2. Install and connect an AI provider under **Settings → Connectors**

3. Upload the plugin folder to `/wp-content/plugins/maca-tjatt/`

4. Activate the plugin

5. Go to **Maca Tjatt** in wp-admin

6. Configure content sources and build the index



== Frequently Asked Questions ==



= Who pays for AI usage? =



The site owner configures and pays for their chosen AI provider through WordPress Connectors. This plugin does not include or bill for AI access.



= Does it store visitor chat history? =



No. Questions are processed in real time and not saved to the database. Only the search index (website content chunks) is stored locally. A short conversation history is kept in the visitor’s browser during the open chat session.



= What content is indexed? =



Site name and tagline, optional custom knowledge text, published pages (including slug/URL path), posts, categories, tags, public/queryable custom post types, and when present maca DownList files, maca MediaList galleries/media, plus common third-party download plugins. Password-protected and private content is skipped. Secrets such as API keys, tokens, and passwords are redacted from indexed text.



= Are secrets or API keys indexed? =



No. Before indexing and before sending context to the AI, the plugin redacts common secret patterns (API keys, tokens, passwords, private keys, and similar). Rebuild the search index after updating so older chunks are replaced.



= What WordPress version is required? =



WordPress 7.0 or newer, with the built-in AI Client and at least one connected AI provider.



= What data is sent to Maca? =



On activation, deactivation, and uninstall, the plugin sends your site URL, plugin version, WordPress version, PHP version, and locale to `https://api.maca.se/v1/tjatt/events.php`. If you submit deactivation feedback, your chosen reason and optional comment are included. No chat messages, indexed content, or visitor data is sent.



= How do I uninstall completely? =



Deactivate and delete the plugin from **Plugins**. `uninstall.php` removes the search index table and plugin options.



== Screenshots ==



1. Maca Tjatt settings — enable chat, assistant name, and avatar

2. AI provider setup and preferred chat model

3. Knowledge index options and build index action

4. Admin test chat before publishing on the site

5. Floating chat widget on the front end

6. Inline chat embedded with the `[maca_tjatt]` shortcode



== Upgrade Notice ==



= 1.3.2 =



Use $wpdb->prefix directly in log/lead queries so Plugin Check no longer flags interpolated table variables.



== Changelog ==



= 1.3.2 =



* Fix remaining Plugin Check warnings for prepared SQL table identifiers in conversation logs and leads.



= 1.3.1 =



* Satisfy Plugin Check warnings around request sanitization, uninstall naming, and direct DB table identifiers.



= 1.3.0 =



* Welcome message and clickable quick-reply suggestions on chat open.

* Optional privacy-friendly conversation log (question/answer, hashed IP, retention window) with an admin "Clear log" action.

* Optional lead capture form (name + email) shown before or above the chat, with an admin "Clear leads" action.

* Index PDF attachments as extra knowledge sources (title, URL, and extracted text when available).

* Optional hybrid search: combine keyword scoring with AI embeddings when the connected provider supports them; keyword-only search still works when it does not.



= 1.2.15 =



* Inject page URL and slug into every context block so answers can cite the right page.

* Expand Swedish synonym/phrase matching (om oss, kontakt, öppettider, tjänster, FAQ, etc.).

* Prefer live page lookup for about/contact/download intents; stop dumping unrelated fallback pages.

* Avoid duplicate conversation history; lower temperature for more grounded answers.

* Soften refusals and improve ranking so simple site questions get useful replies.

* Show AI connection status (connected provider or setup needed) on the settings page.



= 1.2.14 =



* Fix fatal error: restore missing `get_custom_knowledge()` used by the settings page.



= 1.2.13 =



* Redact API keys, tokens, passwords, and private keys before indexing and before AI requests.

* Skip password-protected/private posts and common order/license post types from the index.



= 1.2.12 =



* Index maca DownList file titles, descriptions, filenames, and lists.

* Index maca MediaList galleries and media items when present.

* Broader custom post type indexing for blogs and content plugins.

* Rebuild the search index after updating to include new sources.



= 1.2.11 =



* Prioritize downloads/hämta pages for download questions.

* Match typos such as “lada ner” and rank download links above unrelated pages.



= 1.2.10 =



* Index page slug and URL path so pages like `/downloads/` are findable.

* Synonyms for download/hämta/nedladdning and better source link ranking.



= 1.2.9 =



* Press Enter to send a chat message (Shift+Enter for a new line).



= 1.2.8 =



* Include full conversation context for follow-up questions.

* Live WordPress site search fallback when the local index is not enough.



= 1.2.7 =



* Answer the latest question without repeating earlier unrelated answers.

* Clearer handling when the index has no info about a new topic (for example video).



= 1.2.6 =



* Stronger follow-up search using conversation topic terms.

* Conversation context passed to the model more reliably.



= 1.2.5 =



* Fix WordPress AI Client history: `UserMessage` / `ModelMessage` require `MessagePart` arrays.



= 1.2.4 =



* Show link buttons only when the visitor explicitly asks for a link/download.

* Improve chat history parsing and AI error handling.



= 1.2.3 =



* Smarter site URL resolution for api.maca.se telemetry (prefers public domain over 127.0.0.1/localhost on proxied hosts).

* Defer activation telemetry to shutdown so request headers and WordPress URL filters are available.



= 1.2.2 =



* Installation telemetry: sends activate, deactivate, and uninstall events to `api.maca.se/v1/tjatt/events.php` (privacy disclosure in Description and FAQ).

* Deactivation feedback is sent via the same API instead of email; skip and submit both report deactivation.



= 1.2.1 =



* Apply avatar ring color to the chat box (header, send button, links, and user messages)



= 1.2.0 =



* Fix avatar selection being reset to default when bundled avatar files are not readable on the server

* Apply ring color and avatar URL directly in HTML so settings are not overridden by cached CSS



= 1.1.9 =



* Replace the green background disc with a colored ring around the avatar image

* Hide the chat button until the avatar image has loaded



= 1.1.8 =



* Admin avatar preview now matches the selected avatar size (small, medium, large)



= 1.1.7 =



* Rename avatar color setting to "Avatar ring color" and show it next to the preview



= 1.1.6 =



* Make avatar button background color clearly visible as a ring around the avatar

* Fix color picker saving via a dedicated hidden settings field



= 1.1.5 =



* Fix avatar button background color not applying on the front end

* Fix admin color picker value not always being saved on submit

* Limit avatar preview size in settings to 50x50 px



= 1.1.4 =



* Built-in chatbot avatars with dropdown selection and preview in settings

* Floating chat button entrance animation and reminder after 30 seconds

* Fix avatar selection not applying on the front end after saving settings



= 1.1.3 =



* Deactivation feedback modal on the Plugins screen (like maca Restu)

* Plugin URI updated to maca.se/maca-tjatt-info/



= 1.1.2 =



* Add built-in default avatar when no custom image URL is set



= 1.1.1 =



* Fix AI availability detection when Connectors shows a provider as connected



= 1.1.0 =



* Migrate chat requests to the WordPress 7.0 AI Client

* Remove direct OpenAI API integration and plugin-managed API keys

* Local keyword-based search index (no external calls during indexing)

* Requires WordPress 7.0



= 1.0.4 =



* Readme: screenshots section and OpenAI billing FAQ for WordPress.org listing



= 1.0.3 =



* WordPress.org prep: GitHub URI, external services documentation, Plugin Check escaping fixes



= 1.0.2 =



* Avatar size setting

* Swedish translations when site or user locale is Swedish

* Plugin Check and packaging fixes



= 1.0.0 =



* Initial release extracted as standalone website chat plugin
