=== TwilperChat ===
Contributors: twilper
Tags: chatbot, ai, woocommerce, customer support, live chat
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI chat assistant for your site and WooCommerce store: answers questions, finds products, gives advice and shows order status to verified customers.

== Description ==

TwilperChat adds the Twilper Chat assistant to your website. It answers visitor questions 24/7 from your own content and, with WooCommerce, works with live shop data. Your team sees every conversation and can take over at any moment.

**For every website**

* Answers from your pages, posts and other content, with links to the source
* Speaks the language of each page (works with WPML and Polylang)
* Your team takes over any conversation in the Twilper Chat inbox (the assistant then stops) and can follow up by email, phone or WhatsApp
* Lightweight widget that works on phones and desktops, with page rules and optional cookie consent (WP Consent API)

**For WooCommerce stores**

* **Product search and advice:** the assistant searches your catalogue, compares products and options (size, colour, ...) and links to the right product page
* **Live prices and stock:** prices including or excluding tax, stock status or exact quantities, as you choose
* **Price quotes:** price for a quantity and a chosen variation
* **Order status (off by default):** customers get status, items and tracking after giving their order number plus email address and/or postcode. Names, addresses and other personal data are never shared. Wrong attempts are limited.
* **Handoff:** when the assistant cannot help, it can email the question to your team from your own site
* Compatible with High-Performance Order Storage (HPOS) and the block checkout

**Secure by design**

* The AI tools only answer requests signed by Twilper with a key that only your site and Twilper know (HMAC-SHA256, five-minute window, replay protection)
* The public widget key cannot change anything; content sync uses a separate secret sync key
* Knowledge sync and the AI tools stay off until you turn them on

**About Twilper Chat**

The widget is one channel of Twilper Chat, an AI assistant for customer conversations for small and medium-sized businesses. Website chat, phone, WhatsApp and email come together in one shared team inbox, with assignment, internal notes and leads.

* **Phone:** an AI phone assistant on a local number that answers from the same knowledge (paid add-on)
* **WhatsApp:** connect your WhatsApp Business number; the assistant answers and your team takes over in the same inbox (activated per workspace)
* **Email:** connect your mailbox; the AI prepares reply drafts that your team reviews and sends
* **Apps:** web dashboard, Android app, and a web app for iPhone, iPad and desktop
* **Data:** workspace data is stored in the EU and AI answers are generated by Mistral AI in the EU

**Account and pricing**

A Twilper Chat account is required. Every plan starts with a 14-day free trial; a payment method is required to start. See https://twilper.com/en/pricing for current plans.

**Privacy**

The plugin adds suggested text to the WordPress privacy policy guide (Settings > Privacy). Twilper processes chat data on your behalf as a processor; business customers sign a data processing agreement. Details: https://twilper.com/en/privacy

== External services ==

This plugin connects to the Twilper Chat service, operated by Twilper (https://twilper.com), at api.twilper.com. The plugin cannot work without it.

* **Chat widget:** when the widget is enabled and a widget key is saved, each front-end page where the widget is shown loads the widget script from https://api.twilper.com/static/widget.js, so the visitor's browser connects to api.twilper.com (IP address and user agent, as with any web request) even if the visitor does not chat. When a visitor uses the chat, their messages, the page URL, the browser language and a random conversation ID are sent to api.twilper.com to generate answers. You can limit the widget to certain pages, to WooCommerce pages, or to visitors who gave consent via the WP Consent API.
* **Key check:** when you save the widget key, it is sent to api.twilper.com to verify it. When you click "Test connection", the widget key and, if saved, the sync key are sent to verify both.
* **Knowledge status:** when you click "Show status" on the Knowledge sync tab, the widget key is sent to api.twilper.com to read the number of documents in your knowledge base.
* **Knowledge sync (off by default):** only when you enable it, the title, text and URL of the selected published content (and of WooCommerce products: short description, price, stock status, SKU, categories and attributes) are sent to api.twilper.com, with the widget key and sync key, when you click "Full resync now" and, if you also enable automatic updates, after changes and once a day.
* **AI tools (off until you click "Connect AI tools"):** the plugin sends this site's REST endpoint URL and a newly generated signing key to api.twilper.com. After that, Twilper sends signed requests to your site to search products, quote prices and (if enabled) look up order status after verification. Answers contain product data and order status, items, totals and tracking; never names, addresses, phone numbers or email addresses. "Disconnect" tells api.twilper.com to remove the connection.
* **Uninstall:** if the AI tools are connected, deleting the plugin tells api.twilper.com to remove the connection, unless you turned this off on the Privacy tab.

The handoff email is sent by your own site with wp_mail(), not through Twilper.

Twilper terms of service: https://twilper.com/en/terms
Twilper privacy policy: https://twilper.com/en/privacy

The widget script is the client of this service; its source is maintained by Twilper. The plugin itself loads no other external scripts, fonts or trackers.

== Installation ==

1. Install the plugin via Plugins > Add New Plugin and activate it.
2. Create a Twilper Chat account at https://twilper.com/en/products/twilperchat. Every plan starts with a 14-day free trial; a payment method is required to start.
3. Go to Settings > TwilperChat and paste your widget key (tc_live_...) from the Twilper Chat dashboard.
4. Optional: create a sync key in the dashboard under Integrations, save it on the Connection tab, enable Knowledge sync and click "Full resync now".
5. WooCommerce: open the "WooCommerce AI tools" tab, choose what the assistant may share and click "Connect AI tools". Your site must use https.

== Frequently Asked Questions ==

= Where do I find my widget key and sync key? =

Log in at https://chat.twilper.com. The widget key (tc_live_...) is under Integrations > Website. The sync key (tc_sync_...) is created under Integrations > Sync key and is shown only once; create a new one if you lose it.

= Is WooCommerce required? =

No. Without WooCommerce the assistant answers from your content. With WooCommerce it can also search products, quote prices and show order status.

= How does the order status check protect my customers? =

The assistant asks for the order number and the billing email address and/or postcode (your choice) and the plugin checks them like WooCommerce's own order tracking form. Only status, dates, items, total and tracking are shared. After five wrong attempts an order number is locked for an hour.

= Which data is shared with Twilper? =

See "External services" above. Nothing is synced until you enable Knowledge sync, and the AI tools only answer after you connect them.

= Does it work with caching and security plugins? =

Yes. If a security plugin blocks the REST API, allow /wp-json/twilperchat/v1/. Use "Test tools" on the WooCommerce AI tools tab to check.

= Can developers add their own tools or change the data? =

Yes, with the filters twilperchat_tools_manifest, twilperchat_custom_tool, twilperchat_order_summary, twilperchat_order_tracking, twilperchat_sync_items and twilperchat_show_widget.

== Screenshots ==

1. WooCommerce AI tools: products and advice, prices, stock, order status and the one-click connection.
2. Connection tab with the public widget key and the secret sync key.
3. Widget settings: language, position, phone button size, page rules and cookie consent.
4. Knowledge sync: choose what is sent, automatic updates and a full resync.

== Changelog ==

= 2.0.1 =
* Translations are now delivered through translate.wordpress.org; the bundled translation files and the manual text domain loading were removed.

= 2.0.0 =
* New: WooCommerce AI tools - product search and advice, product options, price quotes, verified order status and handoff to your team by email.
* New: one-click "Connect AI tools" with signed requests (HMAC-SHA256, timestamp window and replay protection).
* New: settings in tabs - Connection, Widget, Knowledge sync, WooCommerce AI tools, Handoff and Privacy.
* New: widget language, position, phone button size, page rules, WooCommerce-only and WP Consent API options.
* New: secret sync key for content sync; the public widget key can no longer change your knowledge base.
* New: choose which post types are synced; knowledge sync is now opt-in.
* New: suggested privacy policy text, Dutch translation, HPOS and block checkout compatibility.
* Improved: all scripts are enqueued; settings are removed when the plugin is deleted.

= 1.1.0 =
* WooCommerce product sync improvements.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 2.0.0 =
Adds WooCommerce AI tools and a secret sync key. Create a sync key in the Twilper Chat dashboard and save it on the Connection tab to keep syncing content.
