=== Scrapia Webchat Widget ===
Contributors: carlupi
Tags: chat, chatbot, ai, support, live chat
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Adds the Scrapia AI chat widget to your WordPress site. You only need the widget ID.

== Description ==

Scrapia Webchat Widget connects your WordPress site to your Scrapia assistant. The widget appears as a floating button. Colors, avatar, welcome message, and starter buttons are configured in the Scrapia dashboard, not in WordPress.

Features:

* Setup with a single field: the widget ID.
* The ID is checked when you save: you are told if the widget does not exist or is inactive.
* Place the widget at the bottom right (default) or bottom left of the screen.
* Hide the chat from site administrators.
* Exclude specific paths (for example checkout).
* Compatible with the most common caching plugins.

You need a Scrapia account with a Webchat widget configured.

== External services ==

This plugin relies on an external service: the Scrapia API (https://api.scrapia.ai). The widget does not work without it.

What is sent, and when:

* When you save the settings in the WordPress dashboard, the plugin calls `GET /api/v1/webchat/demo/{widget_id}` to confirm that the widget exists. Only the widget ID is sent.
* On the front end, the plugin loads `embed.js` from the API. That script runs in the visitor's browser and, when the visitor sends a message, sends the message text, an anonymous visitor identifier, and the widget ID to the API. It also loads the history of that conversation.
* The script stores an anonymous visitor identifier in the browser's `localStorage`, so the conversation continues across pages.
* The plugin does not send WordPress account data or the content of the site.

Terms of service: https://scrapia.ai/cl/terminos/
Privacy policy: https://scrapia.ai/cl/politica/

If your site requires consent before cookies or local storage, keep the widget hidden until the visitor accepts by using the `scrapia_chat_should_render` filter.

== Installation ==

1. Upload the `scrapia-webchat-widget` folder to `/wp-content/plugins/`, or install the .zip from Plugins → Add New.
2. Activate it from the Plugins screen.
3. Go to Settings → Scrapia Webchat Widget.
4. Paste the widget ID shown in the Scrapia dashboard, under Channels → Webchat.
5. Save. You should see "Widget connected" with your widget name.

== Frequently Asked Questions ==

= Where do I find the widget ID? =

In the Scrapia dashboard, under Channels → Webchat. It is the same ID shown in the embed code.

= Can I change the colors or the welcome message from WordPress? =

No. Those are configured in the Scrapia dashboard and apply to the widget without changing WordPress.

= Can I show the widget on the left? =

Yes. In Settings → Scrapia Webchat Widget, set "Position" to "Bottom left". The default is bottom right. On phones the chat window opens full screen, so only the button changes side.

= How do I hide it on some pages? =

In Settings → Scrapia Webchat Widget, use the "Excluded paths" field. One path per line, with a trailing `*` to include subpaths.

= Can I control it from code? =

Yes, with the `scrapia_chat_should_render` filter:

`add_filter( 'scrapia_chat_should_render', function ( $render ) {
    if ( is_singular( 'product' ) ) {
        return false;
    }
    return $render;
} );`

= The widget does not appear =

Check that "Show the chat" is enabled, that the ID is correct, and, if you are logged in as an administrator, that "Hide from administrators" is off.

== Changelog ==

= 1.1.0 =
* New: "Position" setting to show the widget at the bottom right (default) or bottom left.

= 1.0.0 =
* Initial release.
