# Agenized — v0.2.3

Install a plugin zip, connect your Agenized account via OAuth, select your **Chats** channel, and the widget will be embedded sitewide.

## Install (customer)
1. In WordPress Admin: **Plugins → Add New → Upload Plugin**
2. Upload `agenized-chat-widget.zip`, click **Install Now**, then **Activate**
3. Go to **Agenized** (in the admin menu)

## Configure
### 1) Set base URLs + OAuth client id
In **Agenized → Connection**:
- **Merchant API Base URL**: your Merchant API as reachable from WordPress/PHP (e.g. `https://api.agenized.com` or `http://host.docker.internal:8010` in local Docker)
- **Widget API Base URL**: your Merchant API as reachable from the browser (often `https://api.agenized.com` in prod, `http://localhost:8010` in local dev)
- **Merchant Portal Base URL**: your Merchant Portal (hosts `/oauth/authorize`)
- **Widget Script URL**: URL of the **embed snippet** (iframe widget). If empty, the plugin uses a minimal placeholder and the chat launcher will not appear. Set this to your hosted embed script (e.g. from the Agenized dashboard or CDN) so the widget and proactive messaging work.
- **OAuth Client ID** (+ optional secret) and scopes

### 2) OAuth connect
Click **Connect via OAuth** and approve access. You must whitelist the **Redirect URI** shown on the page in the Agenized OAuth client configuration.

### 3) Select Chats channel
Choose your existing **Chats** channel (provider `chat_widget`) and save.

### 4) Proactive messaging (optional)
The plugin sends store events (product view, add to cart, cart view, search, etc.) to the widget so the channel’s agent can send proactive messages. To use this:
- **Widget Script URL** must be set to the real embed snippet (see step 1). The bundled placeholder does not support proactive.
- In the Agenized dashboard, enable **Proactive messaging** for the channel (channel settings).
- Configure proactive instructions and limits in the agent’s **Proactive** tab.

## Build the distributable zip (internal)
From `agenized-woocomerce/`:
1. Copy `plugin-build.env.example` to `plugin-build.env`
2. Edit values for dev vs prod
3. Build:

```bash
make plugin-zip
```

Output:
- `dist/agenized-for-woocommerce.zip` (root folder inside the zip matches the WordPress.org slug so Plugin Check and gettext stay aligned)

## Local dev with Docker WordPress
This repo’s `docker-compose.yml` mounts the plugin into the container at:
- `wp-content/plugins/agenized-chat-widget`

This means **edits you make locally apply immediately** (no zip upload needed). If changes don’t show up, restart the WordPress container.

Run:
```bash
make up
```

Then open:
- `http://localhost:8082/wp-admin/` (admin/admin)
- **Agenized** (in the admin menu)
