=== UnravelX Sales ===
Contributors: unravelx
Tags: chatbot, ai, sales, seo, lead generation
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.8.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

AI chatbot, inbound automation, and programmatic SEO page generation for WordPress.

== Description ==

UnravelX Sales connects your WordPress site to the UnravelX platform — giving you an AI chatbot that handles inbound conversations and (on the Pro plan) automatically publishes SEO-optimised pages that match your site's active theme.

**Setup takes under a minute:**

1. Install and activate the plugin
2. Go to **Settings → UnravelX Sales → Inbound tab**
3. Enter your Chatbot ID and click **Connect**
4. Enable the chatbot and save

**Inbound — Spark (free)**

* AI chatbot widget embedded on every page
* Up to 50 conversations per month
* 1 channel, 1 seat
* Handles lead qualification, objections, and meeting bookings 24/7
* Customisable button colour and gradient
* Enable / disable without losing settings

**Inbound — Grow ($49/month)**

* Everything in Spark
* Up to 2,000 conversations per month
* 4 channels, up to 10 seats
* Unified inbox
* Company-level AI training
* Email campaigns
* Learning loop (monthly)

**SEO (Pro plan)**

* Programmatic SEO page creation — enter a keyword, get a fully optimised page
* Pages are published as native WordPress pages and inherit your active theme automatically (fonts, colours, header, footer — everything)
* 10 pages published in your first week, then 2 new pages every week
* Auto-generated meta descriptions compatible with Yoast SEO, Rank Math, and AIOSEO

**External services**

This plugin connects to the UnravelX platform (unravelx.app) to:

* Authenticate your site via a secure site token
* Check your account plan
* Generate SEO page content on the Pro plan
* Serve the chatbot widget iframe

Data sent includes your Chatbot ID, site URL, site name, and active theme name. See our [Privacy Policy](https://unravelx.app/privacy/) and [Terms of Service](https://unravelx.app/terms/) for full details.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/unravelx-chatbot/`, or install directly via the WordPress Plugins screen.
2. Activate the plugin.
3. Go to **Settings → UnravelX Sales**.
4. On the **Inbound** tab, enter your Chatbot ID and click **Connect**.
5. Enable the chatbot and save.

== Frequently Asked Questions ==

= Where do I find my Chatbot ID? =

Log in to your UnravelX dashboard at unravelx.app, open your chatbot's settings, and copy the ID shown there.

= The chatbot isn't showing up. What do I do? =

Try clearing your site cache and visiting the site in a private/incognito window. Make sure the Enable toggle is on and the site is connected (green dot on the Inbound tab).

= Does this slow down my site? =

No. The chatbot script loads asynchronously and deferred, so it does not block page rendering.

= What data does this plugin store? =

The plugin stores your Chatbot ID, SEO ID, a secure site token, button style settings, and the enable/disable state in wp_options. On the Pro plan, IDs of SEO pages generated by UnravelX and synced into WordPress are also stored. No visitor data is collected.

= Do I need a Pro plan to use the plugin? =

No. The chatbot widget works on all plans including the free Spark plan. The SEO tab shows generated SEO pages and links to UnravelX for configuration.

= What happens if I disconnect? =

The site token is revoked on the UnravelX side and cleared locally. The chatbot widget will stop appearing until you reconnect.

== Screenshots ==

1. Inbound tab — connect your site with a single click.
2. Connected state — chatbot ID and site shown with a green status.
3. SEO tab — review generated SEO pages and open UnravelX SEO configuration.
4. Upgrade wall — shown on Spark and Grow plans.

== Changelog ==

= 1.8.3 =
* Added SEO ID linking and sync so generated UnravelX SEO pages can be published as native WordPress pages.
* Synced SEO pages now update existing WordPress pages instead of creating duplicates.

= 1.8.2 =
* Restyled Configure and SEO page action buttons with UnravelX brand colors instead of WordPress admin blue.

= 1.8.1 =
* Renamed the SEO admin tab to SEO.
* Moved SEO onboarding, CTA, writing-style, and generation configuration to UnravelX.
* Added Configure links for connected inbound agents and SEO setup.
* Made connected Chatbot IDs read-only in WordPress.

= 1.8.0 =
* Questionnaire now asks 5 questions first, then offers a checkpoint: generate immediately or answer 5 more questions to improve SEO content quality.

= 1.7.0 =
* Add icon colour setting — control the chatbot button icon colour independently of the background.
* Live preview now shows the icon inside the button so both colours can be checked before saving.
* Sync version with app dashboard (1.6.0 was released without a readme update).

= 1.6.0 =
* SEO questionnaire with 16-question content preference flow.
* Questionnaire answers synced to UnravelX server and restored on new installs.
* Writing style selector — pick existing posts, pages, or entire categories as tone references.
* Folder/category suggestion when 3+ items from the same category are selected.

= 1.5.0 =
* Replace batch generate with sequential per-page generation — each page appears as it completes.
* Progress bar shows live generation status.
* Job state saved in wp_options — closes tab and comes back, generation resumes from where it left off.
* Greyed-out placeholders show which pages are still being generated.

= 1.4.0 =
* First run generates 10 cross-linked SEO pages automatically.
* Weekly Monday 08:00 cron generates 2 new pages with internal links to existing pages.
* All generated pages link to each other for topical authority.

= 1.3.9 =
* Pass existing SEO pages to generator so new pages include internal links to related articles.

= 1.3.8 =
* Detect editor type (Gutenberg blocks vs classic HTML) and generate matching page content.

= 1.3.7 =
* Fix SEO page generation — route through unravelx.app proxy, fix missing endpoint.

= 1.3.6 =
* Route keyword suggestions through unravelx.app proxy (Cloudflare BIC/Bot Fight Mode disabled).

= 1.3.5 =
* Revert to calling Railway directly for keyword suggestions — confirmed working, unravelx.app blocked by Cloudflare from TasteWP hosts.

= 1.3.4 =
* Fix Cloudflare WAF blocking keyword suggestions — switch to GET request so server-to-server calls pass through.

= 1.3.3 =
* Fix keyword suggestions blocked by Cloudflare WAF — call Railway directly, bypassing proxy.

= 1.3.2 =
* Add debug info to keyword suggestions error response for diagnostics.

= 1.3.1 =
* Fix keyword suggestions URL to use unravelx.app proxy (api.unravelx.app unreachable from some WordPress hosts).

= 1.3.0 =
* SEO tab now shows 5 AI-generated keyword suggestions tailored to your business, fetched live from UnravelX using your onboarding context. Clicking a chip populates the keyword field instantly.

= 1.2.9 =
* Fixed iframe URL — pointed to chatbot-share (non-existent) instead of chatbot-public.
* Fixed widget button size and icon.
* Fixed chatbot iframe X-Frame-Options (requires server .htaccess update).

= 1.2.7 =
* Restored Chatbot ID field in settings form so widget works without going through the Connect flow.

= 1.2.6 =
* Fixed chatbot widget not showing — site token is only required for SEO features, not the widget itself.

= 1.2.5 =
* Fixed API base URL to unravelx.app.

= 1.2.4 =
* Fixed API base URL to app.unravelx.app.

= 1.2.3 =
* Fixed API URL — restored correct /api/ path prefix.

= 1.2.2 =
* Improved connection error messages to show the actual server response for easier debugging.

= 1.2.1 =
* Fixed API URL — removed duplicate /api/ path prefix that broke the Connect flow.

= 1.2.0 =
* Renamed plugin to UnravelX Sales.
* Added Inbound & SEO tab with programmatic SEO page generation (Pro plan).
* Added secure site token connection flow — sites now authenticate with a site-specific token instead of the raw Chatbot ID.
* Added plan-tier gating: Spark and Grow plans see an upgrade prompt on the Inbound & SEO tab.
* Added Connect / Disconnect UI on the Inbound tab.
* Added meta description injection compatible with Yoast SEO, Rank Math, and AIOSEO.

= 1.1.0 =
* Added tab navigation (Chatbot / SEO Pages).
* Added SEO page generation tab.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.2.0 =
Adds the Inbound & SEO feature (Pro plan) and a new secure connection flow. After updating, visit Settings → UnravelX Sales and reconnect your site using your Chatbot ID.
