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

# EC Price & Inventory Monitoring

> Track competitor prices and stock levels across e-commerce sites with scheduled runbooks.

## Overview

Monitoring competitor pricing and inventory across multiple e-commerce sites is a common but tedious task. Manual checks don't scale, and scraping scripts break every time a site redesigns.

Refrain lets you describe what data to collect, generates a self-healing runbook, and runs it on a schedule. When a site's layout changes, the runbook adapts automatically.

## Example runbook

```yaml theme={null}
name: competitor-price-check
url: https://shop.example.com/products
variables:
  - name: product_url
    source: data
steps:
  - action: navigate
    url: "{{ product_url }}"
  - action: wait
    selector: ".product-detail"
  - action: extract
    selector: ".price-current"
    capture: price
  - action: extract
    selector: ".stock-status"
    capture: stock
  - action: export
    format: csv
    fields:
      - name: url
        value: "{{ product_url }}"
      - name: price
        value: "{{ price }}"
      - name: stock
        value: "{{ stock }}"
```

## Generate and execute

<Steps>
  <Step title="Generate the runbook">
    ```bash theme={null}
    npx @refrainai/cli generate -- \
      --url https://shop.example.com/products/sample \
      --goal "Extract the current price and stock status" \
      --context ./context.md \
      --output ./price-check.yaml
    ```
  </Step>

  <Step title="Prepare a product list">
    Create a CSV with the URLs to monitor:

    ```csv theme={null}
    product_url
    https://shop.example.com/products/001
    https://shop.example.com/products/002
    https://shop.example.com/products/003
    ```
  </Step>

  <Step title="Batch execute">
    ```bash theme={null}
    npx @refrainai/cli execute -- \
      --runbook ./price-check.yaml \
      --data ./products.csv \
      --output-dir ./reports
    ```
  </Step>
</Steps>

## Why this works well

* **Batch execution** — Monitor hundreds of products from a single CSV file.
* **Self-healing** — Site redesigns don't require script rewrites.
* **Scheduled runs** — Set up daily or hourly checks via the Web Console scheduler.
* **Slack alerts** — Get notified when prices drop or items go out of stock.

## What's next

<CardGroup cols={2}>
  <Card title="Execute a runbook" icon="play" href="/guides/execute-runbook">
    Learn about batch execution with CSV data.
  </Card>

  <Card title="Approval and notifications" icon="bell" href="/guides/approval-and-notifications">
    Set up Slack alerts for price changes.
  </Card>
</CardGroup>
