=== Commagic Chat ===
Contributors: easetech
Tags: chat, ai chatbot, live chat, lead capture, contact form
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add your Commagic AI assistant to your site as a chat button, and send entries from popular contact form plugins to Commagic as leads.

== Description ==

Commagic Chat connects your WordPress site to your [Commagic](https://commagic.ai/help/wordpress) account. Commagic is an AI assistant service: it answers your visitors in a chat on your website and collects leads for you. This plugin is the bridge between your site and that service.

**A Commagic account and project are required.** The plugin does nothing on its own until you connect it with a one-time connection code from your Commagic dashboard. The plugin is free, and the Commagic service is currently free to use.

= What it does =

* **Connects with one code.** In your Commagic dashboard you get a one-time "WordPress connection code". Paste it into Settings → Commagic Chat and click Connect. There are no API keys to copy and no code to paste into your theme.
* **Adds the chat to your site.** Once connected, a chat button appears in the corner of every public page. You can change the button text and colour, or hide the chat on this site at any time without disconnecting.
* **Sends contact form entries in as leads.** When lead capture is switched on for your Commagic account, entries from supported form plugins are sent to Commagic in the background. Your forms keep working exactly as before: they never wait for Commagic, and they still work when Commagic cannot be reached.

= Supported form plugins =

* Contact Form 7
* Elementor Forms (requires Elementor Pro)
* WPForms
* Fluent Forms
* Gravity Forms
* Ninja Forms

The settings page shows which of these it found on your site.

= What is never sent =

The plugin never sends passwords, hidden fields, captcha or security tokens, uploaded files, cookies, your visitors' IP addresses, or anything about your WordPress users, posts or settings. The full list of what is sent, and when, is under "External services" below.

== Installation ==

1. In your WordPress admin, go to Plugins → Add New Plugin, search for "Commagic Chat", click Install Now, then Activate.
2. In your Commagic dashboard, open Integrations → Website chat → WordPress plugin and click "Get a WordPress connection code". Copy the code.
3. In WordPress, go to Settings → Commagic Chat, paste the code and click Connect. Your site must be reachable from the internet while it connects, because Commagic briefly checks that the code is being used on your site.
4. Visit your site. The chat button is in the bottom corner.

A step-by-step guide with troubleshooting is at [commagic.ai/help/wordpress](https://commagic.ai/help/wordpress).

The code works once and expires after a short time. If it expires, get a new one in your dashboard.

To disconnect, click Disconnect on the same settings page. The plugin asks Commagic to revoke this site's connection and website key, then removes the chat and stops form sending on this site. If Commagic cannot be reached at that moment, the site stays connected and you are asked to try again.

== Frequently Asked Questions ==

= Do I need a Commagic account? =

Yes. The plugin connects your site to your Commagic account and project, and the chat answers with the assistant you set up there. Without an account the plugin has nothing to connect to.

= Does it cost anything? =

The plugin is free. The Commagic service is currently free to use.

= The connection says this website could not be verified =

While connecting, Commagic makes one quick request to your site's REST API (under /wp-json/) to confirm the code is being used on your site. Make sure your site is public (not a staging site behind a password or on a private network) and that no security plugin or firewall blocks the WordPress REST API, then try again with the same code.

= Can I hide the chat without disconnecting? =

Yes. Untick "Show the chat on this website" under Settings → Commagic Chat. The connection stays, and form entries are still sent if lead capture is on.

= How do I stop form entries being sent? =

Lead capture is switched on or off for your account in your Commagic dashboard, and the settings page in WordPress shows whether it is on. Disconnecting the plugin also stops form entries being sent from this site straight away.

= Will it slow down my site? =

The chat script loads in the footer with the defer attribute, so it does not block your pages. Form entries are queued and sent in the background with WP-Cron, so a visitor submitting a form never waits for Commagic.

= My site has WP-Cron disabled =

That is fine as long as a real server cron job runs wp-cron.php. Queued form entries and the daily connection check are sent when cron runs. Entries that cannot be sent within a day are dropped.

= What do I need to tell my visitors? =

Your visitors' form entries and chat messages are processed by Commagic. Mention this in your site's privacy policy, and link to the [Commagic privacy policy](https://commagic.ai/privacy).

= What happens when I deactivate or delete the plugin? =

Deactivating hides the chat and stops the background tasks. Your connection is kept for when you activate the plugin again. Deleting the plugin removes everything it stored on your site: the connection, the settings and any form entries still waiting to be sent. To switch the website off on the Commagic side as well, click Disconnect before deleting the plugin, or disconnect the site in your Commagic dashboard.

= Where can I get help? =

Step-by-step setup and troubleshooting are at [commagic.ai/help/wordpress](https://commagic.ai/help/wordpress). For anything else, post in this plugin's support forum on WordPress.org, see [commagic.ai/support](https://commagic.ai/support), or email support@commagic.ai.

== Screenshots ==

1. Settings → Commagic Chat before connecting: paste the one-time connection code from your Commagic dashboard.
2. Settings → Commagic Chat once connected: connection status, chat button text and colour, and the contact form plugins found on the site.
3. The chat open on a website, answering a visitor.
4. A Contact Form 7 form with the chat button: entries from supported form plugins are sent to Commagic as leads.

== External services ==

This plugin connects your site to Commagic, an AI assistant and lead capture service at [https://commagic.ai](https://commagic.ai/help). The service is needed for everything the plugin does: the chat, and receiving your form entries as leads. Nothing is sent to Commagic until a site administrator connects the plugin with a connection code.

Commagic is reached at two addresses:

* https://api.commagic.ai receives calls made by your site's server (connecting, the daily check and form entries).
* https://chat.commagic.ai serves the chat that runs in your visitors' browsers.

**1. When you connect** (an administrator pastes a connection code and clicks Connect), your server sends to https://api.commagic.ai: the connection code; your site's address (Site Address and WordPress Address); your site title; your WordPress, PHP and plugin versions; your site language; and your site timezone. While the code is being exchanged, Commagic makes one request to your site's REST API to confirm the code is being used on your site. The answer contains only a one-time proof made from the code.

**2. Once a day while connected**, straight after connecting, and when you click "Check connection", your server sends to https://api.commagic.ai: the list of forms in your supported form plugins (each form's plugin, ID and title, and its fields' names, labels and types, never what anybody typed), together with the same site details as in step 1 (title, versions, language and timezone). The reply tells the plugin whether lead capture is on, and whether the site was disconnected in the dashboard.

**3. When a visitor submits a supported form**, but only while connected and while lead capture is on for your account, your server sends to https://api.commagic.ai in the background:

* the form plugin, the form ID and the form title;
* each field the visitor filled in: its name, label, type and value;
* the page the form was sent from (an address on your own site, without its query string);
* the time it was sent and an entry ID, used so that the same entry is not counted twice;
* only when the visitor ticked a box whose wording mentions text messages (SMS) or WhatsApp: the fact that they agreed, the box's wording and the time.

Passwords, hidden fields, captcha and security tokens, uploaded files, cookies and IP addresses are not sent. An entry that cannot be sent is tried again up to 5 times within a day, then deleted from your site.

**4. On your public pages while connected**, unless you have hidden the chat, your visitors' browsers load the chat script from https://chat.commagic.ai/widget.js. As with any file loaded from another website, this request shows Commagic the visitor's IP address, browser details and the page they are on. The page carries your website key, which is public by design, and your button text and colour. When a visitor opens the chat, the address of the page they are on and the messages they type are sent to https://chat.commagic.ai so the assistant can answer. The chat keeps the conversation's ID in the browser's session storage for that tab. It does not set cookies.

**5. When you click Disconnect**, your server sends one request to https://api.commagic.ai, authorised with your site's connection credential and with no other data, asking Commagic to revoke this site's connection and its website key. Once Commagic confirms, the connection stored on your site is deleted. Deactivating or deleting the plugin sends nothing.

Commagic [Terms of Service](https://commagic.ai/terms) and [Privacy Policy](https://commagic.ai/privacy).

== Changelog ==

= 1.0.0 =
* First release: connect with a one-time code, chat on your site, button text and colour, and contact form entries sent as leads (Contact Form 7, Elementor Forms, WPForms, Fluent Forms, Gravity Forms, Ninja Forms).

== Upgrade Notice ==

= 1.0.0 =
First release.
