=== Agentica Chatbot ===
Contributors: agentica
Tags: chatbot, ai assistant, woocommerce, persian, customer support
Requires at least: 4.9
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connect your WordPress or WooCommerce site to your Agentica AI chatbot: it answers from your live pages and products and passes leads to you.

== Description ==

Agentica is a multi-tenant AI chatbot service with full Persian (right-to-left) support. This plugin is the bridge between your WordPress site and your Agentica workspace.

**What it does**

* **Live lookups.** The plugin serves a small MCP server (Model Context Protocol) from your site. Your chatbot uses it to search and read your pages and posts, list the newest content, read your opening hours and policies, and, with WooCommerce, search products, check price and stock, compare products, estimate shipping and look up an order.
* **Persian-aware search.** Search ignores the differences that break normal WordPress search: Arabic and Persian yeh and kaf, ZWNJ, diacritics, tatweel, and Persian, Arabic-Indic and Latin digits.
* **Chat widget.** Adds the Agentica chat bubble to your site.
* **Logged-in customers (optional, off by default).** Lets the chatbot recognise a logged-in customer, so it can answer "where is my order?" without asking for an order number.
* **Leads.** Visitors can ask the chatbot to pass on a message, a callback request or a quote request. You get an email, and the lead is stored privately under Agentica > Leads.
* **Owner MCP (optional, off by default).** A read-only endpoint for your own AI app, with a token of its own: site overview, recent leads, recently changed content and, with WooCommerce, sales summaries, recent orders, low stock and best sellers. Customer addresses, phone numbers and email addresses are never included.

**You stay in control**

* Only published, public, not password-protected items of the content types you tick are readable by the assistant. A "Hide from assistant" box on every edit screen keeps single items out.
* Drafts, private items, users, comments and orders are never shared. The two order tools are off by default.
* Every request from Agentica to your site carries a secret token that only your site and your Agentica workspace know. Only a hash of that token is stored on your site.

The interface and all messages are translated to Persian (fa_IR) and work right to left.

You need an Agentica account and a licence from your Agentica dashboard (Tools > WordPress).

== External services ==

This plugin connects your site to **Agentica**, a hosted AI chatbot service. It cannot work without it. Nothing is sent until you paste your licence and click Activate.

The service address is fixed: it is the Agentica app you downloaded this plugin from, written into the plugin when the download is prepared. It is not a setting and nothing on your site can change it. The terms of use and the privacy policy of the service are published by the Agentica app at that address.

**What is sent to Agentica, and when**

1. *On Activate and Deactivate, and about every six hours (a heartbeat), and when plugins or the settings that decide which tools exist change:* your licence (as an authorisation header), a random site ID, your site address and home address, site name, the addresses of the plugin's REST endpoints, the site language and time zone, the WordPress, plugin and (if installed) WooCommerce version and currency, and two random secrets the plugin generates (a token Agentica must present to your site, and a key that signs customer identity tokens). No personal data of your visitors is part of this.
2. *When Agentica's chatbot answers a visitor:* Agentica sends requests to your site's REST endpoint (`/wp-json/agentica/v1/mcp`). Your site answers with the public content it is allowed to share (see above), your business information, your shop's product data, and, only if you enabled the order tools, order status details for the order the visitor identified. If a visitor leaves a message for you through the chatbot, the text and contact details they gave are stored on your site and emailed to you; they are not sent back to Agentica by the plugin.
3. *Chat widget (on by default after activation):* every page of your site loads one script from the Agentica app (the address stored at activation). Your visitors' browsers therefore contact Agentica, which receives what a normal web request contains (IP address, browser information, the page) and the chat messages the visitor sends.
4. *Logged-in customer recognition (only if you turn it on):* the widget asks your site for a short-lived signed token containing the WordPress user id and first name of the logged-in visitor and passes it to Agentica with the chat message. Email, phone and address are not included.

The plugin makes no request to any other third-party service. It does not contact Agentica when a visitor loads a page.

== Installation ==

1. Download the plugin from your Agentica dashboard (Tools > WordPress), then in WordPress go to Plugins > Add New > Upload Plugin, or unzip it into `wp-content/plugins/`.
2. Activate "Agentica Chatbot".
3. Open **Agentica** in the admin menu, paste the licence from your dashboard and click **Activate**.
4. Choose which content types the assistant may read, fill in your business information, and decide about customer recognition.

A copy that was not downloaded from the dashboard does not know where Agentica is and says so on the settings page: download it again from the dashboard and reinstall it.

== Frequently Asked Questions ==

= Does the plugin load anything from other websites? =

No fonts, scripts or images are loaded from third parties by the settings screen. It ships with the Vazirmatn typeface (SIL Open Font License 1.1, see assets/fonts/OFL.txt), which the browser downloads from your own site and only when the page shows Persian text. The chat bubble on your site loads its script from your Agentica app, which is the service you connect to (see "External services" above).

= Does it slow down my site? =

No request to Agentica is made while a visitor loads a page. The widget is one deferred script. Searches use a small index table in your database, updated when you save content.

= Can I keep a page out of the assistant? =

Yes. Tick "Hide from assistant" in the Agentica box on its edit screen. Password-protected, private, draft and scheduled items are never shared in any case.

= It says Agentica cannot reach my site. =

Agentica must be able to reach `https://your-site/wp-json/agentica/v1/mcp`. Check that the REST API is not blocked by a security plugin or firewall rule and that the site is reachable from the internet. Some hosts remove the Authorization header; the plugin also accepts the `X-Agentica-Token` header.

= How do I add my own tools? =

Use the `agentica_register_tools` filter. See the developer notes in the plugin repository.

= Is members-only content safe? =

The assistant answers visitors from the content types you tick under Agentica > Settings > "Content the assistant can read", so that list is the main control: tick only what you are happy for any visitor to be told about. A membership, paywall or login-only plugin cannot be detected automatically; WordPress sees such posts as ordinary published ones. Either do not tick their content type, or tick "Hide from assistant" in the Agentica box on each such post. Developers can hide posts in code with the `agentica_post_visible` filter (return false to hide a post): search, the search index, `get_content` and the lists all follow it, and it can only hide, never reveal.

= Does it work with WooCommerce and HPOS? =

Yes, with WooCommerce 3.6 or newer. The plugin declares compatibility with High-Performance Order Storage and reads orders only through WooCommerce's own functions, so it works with both order storage modes. Hidden, draft, private and password-protected products are never shared.

= What is removed when I delete the plugin? =

The settings, the search index table, scheduled jobs and the hidden flags. Saved leads are kept unless you ticked the box to delete them. Disconnect (Deactivate) in the settings before deleting the plugin so your licence is freed.

== Changelog ==

= 1.0.0 =
* First release: MCP server with content tools, Persian search, leads, widget and customer recognition.

== Upgrade Notice ==

= 1.0.0 =
First release.
