=== Zvani – AI phone agent ===
Contributors: loftion
Tags: woocommerce, phone, voice assistant, ai, customer service
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Your Zvani voice agent answers callers about their orders and your products from WooCommerce, and knows the pages you choose.

== Description ==

[Zvani](https://zvani.lv/) is an AI voice agent that answers your business phone around the clock, in Latvian, Lithuanian, Estonian, Russian and English. This plugin connects it to your WordPress site and WooCommerce shop.

**During a call the agent can:**

* tell a caller where their order is: status, items, payment, delivery method and tracking number, and the notes you sent them. An order is told only to the phone it was placed from, or to a caller who names the email it was placed with;
* find a caller's recent orders by the number they are calling from, when they do not know the order number;
* search your catalogue: name, price, sale price, whether it is in stock and how many;
* describe a product: options such as colour and size, each option's price and stock, weight and dimensions;
* give your address, delivery methods and prices, and payment methods.

**Knowledge base.** Tick "Use in Zvani knowledge base" on any page or post — delivery, returns, warranty, contacts — and the agent knows it. The page is sent again whenever you change it, and taken out when you unpublish, trash or untick it. The WooCommerce terms and returns pages and a "Shop facts" page (address, delivery, payment) can be sent automatically.

Nothing about your orders or products is copied to Zvani: the agent asks your site during the call, with a token only Zvani has, and your site answers only what is listed above. The street address, the customer's other contacts, private order notes and payment details are never sent.

Works without WooCommerce too: then the agent gets your pages and your site's basics.

= You need =

* a Zvani workspace — sign up at [zvani.lv](https://zvani.lv/);
* for the knowledge base, a Zvani API key with the "Keep the knowledge base" permission.

= External service =

This plugin connects your site to Zvani, a service of LOFTION SIA, Latvia:

* Zvani calls your site's endpoint `/wp-json/zvani/v1/mcp` during phone calls, to look up orders, products and your shop's basics. It sends the order number, the caller's phone number and, if the caller gives it, their email.
* Your site sends the pages you mark, and the shop facts, to the Zvani API (`https://zvani.lv/api/v1`) when they change, and once a day.

[Terms of Service](https://zvani.lv/terms) · [Privacy Policy](https://zvani.lv/privacy) · [Data Processing Agreement](https://zvani.lv/dpa)

== Installation ==

1. Install and activate the plugin.
2. Open **Settings → Zvani**. Copy the **MCP endpoint** and the **Bearer token** (the token is shown once).
3. In the Zvani panel, open **Modules → Tools from your MCP server**, paste both, and set "Arguments filled with the caller's number" to `get_order.phone, find_orders_by_contact.phone`. Save and switch the module on.
4. In the Zvani panel, open **Members → API keys → Create key**, tick only "Keep the knowledge base", and paste the key into **Settings → Zvani → Zvani API key**. Press **Test connection**.
5. Open your delivery, returns and contacts pages, tick **Use in Zvani knowledge base** in the Zvani box, and update them. Or press **Sync now**.

If your host strips the Authorization header (some Apache and CGI set-ups do), add this to `.htaccess` above the WordPress rules:

`SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1`

== Frequently Asked Questions ==

= Can a caller hear someone else's order? =

No. The phone number comes from the phone line, not from what the caller says, and an order is told only when it matches the order's billing or shipping phone (the last 8 digits), or when the caller names the email the order was placed with. A wrong number and an unverified one get the same answer.

= My order numbers come from a numbering plugin =

Numbers kept in `_order_number` (the usual sequential-numbering plugins) are found. For anything else, use the `zvani_order_by_number` filter.

= Where do tracking numbers come from? =

From WooCommerce Shipment Tracking and Advanced Shipment Tracking. Others can add theirs with the `zvani_order_tracking` filter.

= How do I stop the agent looking things up? =

Untick "The endpoint answers" in Settings → Zvani, or make a new token.

== Changelog ==

= 1.0.1 =
* By an email alone the agent learns only how many recent orders there are and their statuses; an order's details need its number together with the email, or the phone the call comes from.
* The MCP token is shown once in the response that made it and is kept nowhere; none is made until you ask.
* A right token is answered even when its address is over the failure limit; the endpoint says nothing about itself to anyone without the token.
* Knowledge pages carry the site in their id, so two sites in one workspace no longer overwrite each other's pages (the first Sync now after the update moves them).
* Pages are rendered as a visitor who is not logged in sees them; members-only text stays out of the knowledge base.
* Zvani's own error hints are shown, the write limit is waited out, and the settings explain redirects.
* The site's admin email is given as the shop's email only when a store address is set.

= 1.0.0 =
* Orders, products and shop basics for the Zvani agent over MCP.
* Pages and posts in the Zvani knowledge base, kept up to date.
