=== ZH Webhooks for n8n ===
Contributors: zainhassandeveloper
Tags: n8n, webhook, automation, chatbot, woocommerce
Requires at least: 5.8
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

Send WordPress forms, WooCommerce orders, users, and chat to n8n webhooks. HMAC-signed JSON, delivery logs, and an n8n chat widget.

== Description ==

**ZH Webhooks for n8n** sends WordPress events to your n8n webhook. It is not another Zapier clone, cookie banner, or cache plugin.

WordPress.org already has million-install plugins for GTM, consent, backups, and caching. It does **not** have a serious n8n webhook plugin. This one fills that gap:

* **WordPress → n8n** — form submits (WPForms, Contact Form 7, Gravity Forms, Elementor, Fluent Forms, Ninja Forms), new users, published posts/pages, WooCommerce orders.
* **Chat widget → n8n** — visitor messages wait for a `{"reply":"..."}` response from a Respond to Webhook node (the commercial “WordPress AI chatbot” use case). Brand colors, radius, offsets, theme, launcher, and avatar are configurable in wp-admin.
* **n8n → WordPress ping** — signed inbound REST route for a connection check.
* **HMAC + Header Auth** — `X-ZH-N8N-Key` for n8n Header Auth, plus `X-ZH-N8N-Signature` (`sha256=HMAC(timestamp + "." + raw body)`).
* **Delivery logs** — last 200 sends, payload kept only until success so retries work.
* **No n8n Cloud lock-in** — any self-hosted or Cloud webhook URL.

This plugin is **not affiliated with n8n GmbH**.

Need the workflow installed on a client site? See [n8n WordPress automation](https://hassanzain.com/n8n-wordpress-automation/).

== Installation ==

1. Upload the `zh-webhooks-for-n8n` folder to `/wp-content/plugins/`.
2. Activate **ZH Webhooks for n8n**.
3. Open **ZH Webhooks** in wp-admin.
4. Paste your n8n **Production** webhook URL and copy the shared secret into n8n Header Auth (`X-ZH-N8N-Key`).
5. Send a test ping, then enable the events you need.
6. Optional: open the **Chat** tab to style the widget and enable it site-wide or via `[zh_n8n_chat]`.

== Screenshots ==

1. Connection — webhook URL, shared secret, Header Auth (`X-ZH-N8N-Key`), and a test ping.
2. Events — choose which WordPress and WooCommerce events go to n8n.
3. Chat — brand colors, radius, offsets, and a live widget preview.
4. Logs — recent deliveries with event name and HTTP status.
5. Front-end chat widget on a dark site, powered by n8n Respond to Webhook.

== Frequently Asked Questions ==

= Does this replace Uncanny Automator or Bit Integrations? =

No. Those are generic “connect 400 apps” products. This plugin only talks to **n8n** with a stable JSON envelope and HMAC.

= Can I put AdSense in this plugin? =

No. WordPress.org plugins cannot be an ad network. Monetize by booking implementation work or a later Pro license.

= What JSON does n8n receive? =

`{ "id", "event", "timestamp", "site": { "name", "url", "timezone" }, "data": { ... } }` plus headers `X-ZH-N8N-Event`, `X-ZH-N8N-Timestamp`, `X-ZH-N8N-Signature`, `X-ZH-N8N-Key`.

= How does chat work? =

The widget POSTs to WordPress REST. WordPress forwards `chat.message` to n8n and **waits**. Your workflow must use **Respond to Webhook** with `{"reply":"text"}`. Other events are queued asynchronously so checkout stays fast.

= Why does live chat say it cannot reach n8n? =

The webhook URL is empty, not HTTPS, or not reachable from the server. `http://127.0.0.1` on your laptop is not reachable from Hostinger. Use n8n Cloud or another public HTTPS webhook.

= Is WooCommerce required? =

No. Order events fire only when WooCommerce is active.

== Changelog ==

= 1.0.0 =
* Initial release: outbound form, user, post, and WooCommerce events to n8n.
* HMAC-signed webhooks, delivery logs, and inbound ping.
* n8n chat widget with brand colors, radius, offsets, theme, launcher, and live admin preview.
* Chat mounts even when JS delay plugins (e.g. LiteSpeed) are active.

== Upgrade Notice ==

= 1.0.0 =
First public version.
