=== AskX – Agentic AI Chatbot ===
Contributors: wpscaleops1
Tags: ai-chatbot, chatbot, woocommerce, customer-support, ai
Requires at least: 5.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: askx-agentic-ai-chatbot

Add an AI-powered agentic chatbot that uses your WordPress and WooCommerce content you expose. Secure, API-key-protected REST endpoints let AskX read only what you choose to share.

== Description ==

**Give your WordPress site an AI-powered customer support chatbot that uses your site content as context.**

AskX is an agentic AI chatbot that answers visitors using a knowledge base built from your own data. This plugin connects your WordPress site to AskX through **secure, API-key-protected REST endpoints** — so the chatbot can answer using the content you choose to expose.

= Why Use This Plugin? =

This plugin creates a **direct, authenticated data connection** between WordPress and AskX. You control exactly which content types are shared — posts, pages, WooCommerce products, custom post types — and AskX uses that content for customer support and site-related answers.

= Key Features =

* **Full WordPress Integration** — AskX connects directly with your WordPress
  site through secure REST APIs. You choose exactly which content types to
  share: posts, pages, comments, users, and custom post types.
* **WooCommerce Support** — When WooCommerce is active, product list/single
  endpoints and **single-order-by-ID** order endpoints are available. Orders
  cannot be listed in bulk; use a known order ID (for example for order-status
  lookups). Your chatbot can help visitors find products and answer
  store-related questions.
* **Works With Any Site** — Compatible with standard WordPress sites,
  WooCommerce stores, LearnDash courses, BuddyPress/BuddyBoss communities,
  booking platforms, and any site using custom post types.
* **Simple Setup** — Install the plugin, select your content types, download
  the JSON configuration file, and upload it to AskX. Your chatbot is connected.
* **Chatbot Display** — Enter your AskX Chatbot ID in the plugin settings.
  The widget loads automatically on your frontend using standard WordPress
  script enqueueing.
* **Customizable AI Behavior** — In AskX, configure how the chatbot responds:
  set system prompts, add predefined questions, and adjust parameters like
  creativity level and response length.
* **Visual Widget Builder** — Design your chatbot widget in AskX to match
  your site theme and branding.
* **Knowledge Base Training** — Train the AskX chatbot using uploaded documents,
  website URLs, or your WordPress content via this plugin API connection.
* **API-Key Security** — Every API request requires authentication. No data
  is exposed without a valid API key
= How AskX Uses Your Content =

AskX builds its knowledge base from three types of input: documents (PDFs), website URLs, and **WordPress content via API**. This plugin provides **a direct API integration**: authenticated REST endpoints so AskX can read structured WordPress and WooCommerce data you enable, keeping answers aligned with your site as content changes.

= How to Connect =

1. Install and activate the plugin.
2. Choose which content types to expose in the plugin settings.
3. Download the API Configuration JSON file.
4. In AskX, provide the JSON during chatbot creation or via the "Connect WordPress" option.
5. Enter your AskX Chatbot ID in the plugin to display the chatbot on your site.

= Available Endpoint Groups =

* **WordPress core:** posts, pages, users, comments
* **WooCommerce (if active):** products (list and single); **orders (single order by ID only, no list-all)**
* **Custom post types:** all public CPTs
* **Search:** unified search across all enabled types
* **Chatbot-optimized:** endpoints formatted for AI consumption

= Who Is This For? =

* WordPress site owners who want AI-powered customer support that uses their published content
* WooCommerce stores needing product-aware chatbot assistance
* Agencies managing multiple WordPress sites with AskX
* Developers building AI integrations with WordPress content

== Third-party services ==

This plugin integrates with AskX-related services used from your site or browser.

**1. AskX Blog API (admin screen)**

* Service: `https://askx.io`
* Purpose: display latest AskX news cards in the plugin admin page.
* Data sent: pagination parameters (`page`, `page_size`, `is_published`) in a server-to-server request. Your API key is not included.
* Trigger: when an admin opens the plugin settings screen or uses pagination controls.

**2. AskX connection flow (browser)**

* Service: AskX web application (e.g., `https://askx.io/admin`).
* Purpose: let AskX receive the configuration it needs to call your site's REST APIs.
* How it works: a site administrator completes the **AskX Website Connection** consent screen in wp-admin. On approval, the plugin sends a message to the AskX browser window using the standard `postMessage` API (no server-to-server HTTP request). On denial, only a denial status is sent.
* Trigger: only when an administrator explicitly approves or denies on the consent screen.

**3. AskX Chatbot Widget (frontend)**

* Service: `https://askx.io`
* Purpose: loads the AskX chatbot widget for site visitors.
* Data sent: visitor chat messages are sent to AskX servers for AI processing.
* Trigger: on every frontend page load when a valid Chatbot ID is saved and the widget is enabled.

**AskX legal pages:**

* Privacy policy: [https://askx.io/privacy](https://askx.io/privacy)
* Terms of service: [https://askx.io/terms](https://askx.io/terms)

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install directly from WordPress.org.
2. Activate the plugin from the Plugins screen.
3. Open **AskX – Agentic AI Chatbot** in wp-admin.
4. Under **Exposed API Types**, choose which content types AskX may read, then save.
5. Click **Download API Configuration JSON** and provide the file to AskX during chatbot creation or via AskX's Connect WordPress option.
6. In AskX, copy your Chatbot ID and paste it into the **AskX Chatbot ID** field to display the chatbot on your site.

== Frequently Asked Questions ==

= What is AskX? =

AskX is an agentic AI chatbot platform for websites. It builds a knowledge base from your content (documents, URLs, or WordPress via API) and answers visitor questions automatically. This plugin enables the WordPress API integration path.

= How does authentication work? =

All REST endpoints require a valid API key sent via the `X-API-Key` header (recommended) or `api_key` query parameter. No anonymous access is possible.

= Can I control which data is shared? =

Yes. The **Exposed API Types** section lets you enable or disable each content type individually — posts, pages, users, comments, WooCommerce products/orders, and custom post types.

= Does this plugin require WooCommerce? =

No. WooCommerce endpoints are only registered when WooCommerce is active. The plugin works with any WordPress site.

= How does the chatbot appear on my site? =

Enter your AskX Chatbot ID in the plugin settings. The plugin uses `wp_enqueue_script` to load the AskX widget on your frontend. No code editing required.

= What REST namespace does the plugin use? =

Routes are registered under the `askx-ai/v1` namespace. Example base URL:
`https://example.com/wp-json/askx-ai/v1/`

= Where do I find my API key? =

The API key is included in the **API Configuration JSON** file you download from the plugin settings.

= Is the plugin GDPR compliant? =

The plugin itself does not collect personal data. Visitor chat messages are processed by AskX — see the [AskX Privacy Policy](https://askx.io/privacy) for details on data handling.

== Screenshots ==


1. Screenshot 1: Dashboard Overview
This is the main user Dashboard. It provides a high-level summary of your account activity, showing the total number of chatbots created, total documents uploaded, and total conversations. Below the stats, you can see a grid of individual chatbots with options to edit, view analytics, or delete them.

2. Screenshot 2: Step 1 - Design (Appearance Settings)
This is the first step in the "Create New Chatbot" wizard. Here, you are customizing the visual appearance of the chat widget. You can see a live preview of the chat window and a pop-up menu to adjust the Chat Body colors (Body and Border hex codes) to match your brand.

3. Screenshot 3: Step 2 - Behavior Configuration
In this step, you define how the AI acts. You are setting the System Prompt (the instructions for the AI), adding Predefined Questions for users, and adjusting technical parameters like Creativity Level (Temperature) and Response Length.

4. Screenshot 4: Step 3 - LLM Model (Internal Model)
This step involves choosing the "brain" of the chatbot. In this specific view, the user has selected the AskX llm model option. You are also required to specify the Domain (URL) where this specific chatbot will be deployed to ensure it works on the correct website.

5. Screenshot 5: Step 3 - LLM Model (BYOK Option)
This is an alternative to Step 3 where you choose "Bring your own key (BYOK)". Here, you are connecting your own AI provider (like OpenAI) by selecting a specific model (e.g., o1 Reasoning) and entering your personal API Key.

6. Screenshot 6: Step 4 - Knowledge Base (Upload Documents)
The final step is building the chatbot's knowledge. This screenshot shows the Upload documents tab, where you can drag and drop PDF, DOCX, TXT, or JSON files. These documents serve as the primary data source the AI uses to answer questions.

7. Screenshot 7: Step 4 - Knowledge Base (Website Links)
This shows the Website links tab under the Knowledge Base step. Here, you can manually input specific URLs. The platform will crawl these individual pages to index their text, allowing the chatbot to answer questions based on your website's live content.

8. Screenshot 8: Step 4 - Knowledge Base (WordPress Integration)
This shows the WordPress Integration tab. You can download this plugin’s configuration or connect via API so AskX can sync the content types you allow.

9. Screenshot 9: WordPress Connection Authorization
This is a pop-up window showing the OAuth/API authorization process. You are granting the AskX chatbot platform permission to access your WordPress site's APIs (in this case, for `xfinitive.co`) so it can fetch data and integrate the chat widget.

10. Screenshot 10: Live Chatbot Deployment
This is the final result. The screenshot shows the active chatbot deployed on a live website (`Xfinitive`). The AI is responding to a user query ("tell me about your services") using the custom branding and knowledge base configured in the previous steps.

== Privacy ==

= Data stored on your site =

* **API key** — authenticates requests to this plugin's REST routes (stored in wp_options).
* **Exposed API types** — your content-sharing preferences.
* **AskX Chatbot ID** — used to load the chatbot widget.

= Data returned by REST API =

When a valid API key is supplied, responses include WordPress and WooCommerce data according to your Exposed API Types settings. Prefer the `X-API-Key` header over query parameters to prevent accidental key exposure in logs.

= Data sent to AskX =

* **Admin screen:** pagination parameters for blog/news cards (no API key sent).
* **Connection flow:** site URL and API key via browser `postMessage` on explicit admin approval.
* **JSON export:** downloaded locally — the plugin does not send it to AskX automatically.
* **Frontend visitors:** chat messages are sent to AskX for AI processing when the widget is active.

== Changelog ==

= 1.0.1 =
* Improved REST API permission handling for WordPress.org compliance by supporting capability-based authorization alongside existing API key checks.
* Kept API key authentication compatible with both `X-API-Key` header and `api_key` query parameter.

= 1.0.0 =
* Initial release.
* API-key-protected REST endpoints for WordPress core, WooCommerce, and custom post types.
* Selective content exposure controls.
* JSON configuration export for AskX onboarding.
* AskX Chatbot ID field for frontend widget display.
* Universal search endpoint across enabled content types.
* Browser-based AskX connection flow with admin consent.
* Full third-party service and privacy disclosures.

== Upgrade Notice ==

= 1.0.1 =
Security/compliance update for REST authorization flow. API key usage remains unchanged.

= 1.0.0 =
First public release. Configure your exposed content types before sharing your API key.