> ## Documentation Index
> Fetch the complete documentation index at: https://docs.woopilot.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Reactive Event Automations

> Edge-compiled natural language business rules executing at native PHP speeds with zero recurring AI token costs

# Reactive Event Automations ⚡

**WooAuto Events** execute real-time business logic at the edge (inside your WordPress/WooCommerce server) the instant a customer interacts with your store.

```text theme={null}
┌─────────────────────────────────────────────────────────────────────────────┐
│ 💬 YOU TYPE IN PLAIN LANGUAGE:                                              │
│ "When an order over $500 is placed from Germany, tag it 'VIP-EU', add a     │
│ private order note, and send an urgent alert to Telegram"                   │
├─────────────────────────────────────────────────────────────────────────────┤
│ 🤖 WOOPILOT AI COMPILES IN 1 SECOND:                                        │
│ • Trigger: woocommerce_checkout_order_created (Order Placed)                │
│ • Condition: payload.shipping_country == 'DE' AND payload.total >= 500      │
│ • Action 1: Add private note "VIP-EU"                                       │
│ • Action 2: Send formatted Telegram alert with order details                │
│ [ 🚀 Activate Rule (1-Click) ]                                              │
└─────────────────────────────────────────────────────────────────────────────┘
```

***

## 🏗️ The Compilation Pipeline

```mermaid theme={null}
flowchart TD
    A[Natural Language Prompt in TMA] --> B[Cloud Core AI Compiler]
    B --> C{Decision Triad}
    C -->|READY| D[Deterministic JSON Blueprint]
    C -->|CLARIFY| E[Follow-up Prompt Question]
    C -->|REJECTED| F[Error / Out-of-Scope Warning]
    D --> G[Synced to WordPress via POST /sync-rules]
    G --> H[Stored in autoload = true RAM]
```

1. **Natural Language Translation:** The Cloud Core compiler extracts the relevant WooCommerce action hook, required data payload fields, AST condition tree, and actions.
2. **Instant Sync to WordPress:** The compiled blueprint is synced to the WordPress database with `autoload = true`.
3. **Sub-10ms Edge Execution:** When the hook triggers in WordPress, native PHP evaluates the condition tree in memory ($< 0.05$ ms) without calling external AI servers.

***

## 🎯 Supported Triggers & Hooks

| Category      | Event Trigger                                    | Description                                                             |
| :------------ | :----------------------------------------------- | :---------------------------------------------------------------------- |
| **Orders**    | `woocommerce_checkout_order_created`             | Fires the instant a checkout order is created.                          |
| **Orders**    | `woocommerce_order_status_changed`               | Fires when an order status changes (e.g. `pending` $\to$ `processing`). |
| **Orders**    | `woocommerce_order_refunded`                     | Fires when a full or partial refund is processed.                       |
| **Inventory** | `woocommerce_low_stock`                          | Fires when product stock falls below the threshold.                     |
| **Inventory** | `woocommerce_no_stock`                           | Fires when product stock reaches zero.                                  |
| **Customers** | `user_register` / `woocommerce_created_customer` | Fires when a new customer registers on the shop.                        |

***

## 💡 Example Prompt Recipes

### 1. VIP Customer & High-Value Order Alerting

```text theme={null}
"When an order total exceeds $1,000, add order note 'High-Value Priority' and send a Telegram alert with customer phone and shipping address"
```

### 2. Stock Health Protection

```text theme={null}
"When stock drops to 3 units or fewer for any item in 'Electronics', send an immediate Telegram alert with current price and supplier SKU"
```

### 3. Payment Gateway Failure Monitoring

```text theme={null}
"If an order status changes to Failed or Cancelled on Stripe gateway, alert me in Telegram with the customer's billing email for follow-up"
```

### 4. Automated Order Tagging & Notes

```text theme={null}
"When an order with express shipping is placed before 14:00, add note 'Same-Day Dispatch Eligible'"
```

***

## 🛡️ Built-in Edge Safeguards

* **Recursive Loop Guard:** Internal session flags prevent rules from triggering infinite cascades if an action updates the same order.
* **Fail-Closed Execution:** If an external API or Telegram alert fails, core WooCommerce checkout operations **never fail or interrupt the customer**.
* **Zero Database Overhead:** All active rules are cached in RAM during the PHP-FPM lifecycle, requiring zero extra SQL queries on checkout.


## Related topics

- [WooAuto: The 24/7 Autopilot](/wooauto/overview.md)
- [Introduction](/introduction.md)
- [Frequently Asked Questions](/faq.md)
- [System Architecture](/architecture.md)
- [Hardware Safeguards & Blocklists](/security/hardware-safeguards.md)
