Web Monitoring: Notified the Moment a Page Changes
💡 One-line summary: use OpenClaw to build a 7×24-hour web sentinel — automatic fetching, change comparison, notify only on change.
The second lesson on the creation track, solving the "watching" problem: watching a product's price, an announcement page, a sign-up entry. This lesson combines Scheduled Tasks Automations scheduling and delivery with its advanced formcondition watcher (officially called condition watcher) into one workflow — the script fetches the page on a schedule → compares against the last snapshot → only wakes Claw if something changed → writes a notification and delivers it to your IM. Checks with no change burn no model turns — that's the fundamental difference from "letting AI glance at the page every few minutes," and it's the lowest-cost form of web change monitoring. All examples are based on OpenClaw v2026.10.9.
What You'll Be Able to Do
- Build a "notify me the moment the page changes" monitoring task: the script fetches and compares automatically, and only wakes Claw to write a notification and deliver it to IM when something changes
- Write your own change detection script: compare only the fields you've scoped (price, stock, body text), without false alarms from ad slots and timestamps
- Use the first trigger as an end-to-end smoke test, and distinguish "forced run skips the gate" from "--due respects the gate"
- Add active hours to your monitoring (silent at night) and a one-shot "fire once and done" mode
Why OpenClaw, Instead of Manual Refreshing / Web-based AI?
| Capability | Manual Refresh / Web-based AI | OpenClaw Condition Monitoring |
|---|---|---|
| Check cadence | ❌ Relies on your own discipline to refresh on schedule; nine out of ten refreshes are wasted | ✅ --every 30s runs automatic evaluations; whether anything changed is up to it |
| Remembers the last time | ❌ Web-based AI can't remember what the page looked like last time | ✅ trigger.state stores the last snapshot; comparison is fully automatic |
| Notification delivery | ❌ Changes sit in a browser tab; miss it and it's gone | ✅ Changes are delivered straight to Telegram / Feishu / WeCom |
| Cost of no-change checks | ❌ Every check costs you a stretch of time / an AI turn | ✅ No change means the model isn't woken; all you burn is a curl |
| Notification quality | ❌ "The page seems to have changed" — you still have to go look yourself | ✅ Claw wakes up, re-reads the page, and writes out the old value, new value, and link |
Your Current Predicament
- Watching a product price, an announcement page, or a sign-up entry by refreshing on your own: nine out of ten refreshes show no change, and the one time it really changes, you happen to miss it
- Tried whole-page comparison monitoring tools; rotating ad slots and timestamps trigger constant false alarms, and you muted the notifications within three days
- Wanted web-based AI to help watch, but it can't remember what the page looked like last time — you have to paste the page to it every single time
When to Use This Technique
When you need to:
- Watch one specific page: a product price, stock status, announcement board, release page, or sign-up entry
- Receive a plain-language web update alert the moment a change happens
And you don't want to:
- Manually refresh the page ten times a day, nine of them wasted
- Build a crawler + cron script + push service just for one page
- Get bombarded by false alarms from whole-page string comparison tools
💡 Two ways to "watch" — don't pick the wrong one
- Watchingthe whole web for what's new each day → use the
web_searchapproach from the previous lesson Daily Morning Brief - Watchingone particular page for changes → this lesson's condition watcher; Claw is only woken when the script says fire
Pages that require login can't be fetched with lightweight fetching; refer to the logged-in session approach in Browser Control.
🎒 Preparation Before Starting
- Completed Browser Control: you know which pages
web_fetchcan't fetch and when you need a browser (Step 1 uses this judgment directly) - Familiar with the
--announce --channel --todelivery syntax of Scheduled Tasks Automations (this lesson assembles it directly; scheduling basics won't be re-covered) - Gateway is running, and
openclaw automations listcan list tasks normally - The IM channel where you want to receive notifications is connected (Feishu, WeCom, or Telegram all work; you can still learn without connecting one — notifications will just land in the run history for now)
- The Gateway host can run
curl(the trigger script relies on it to fetch pages) - A cup of water ☕ — in about 12 minutes, your IM will gain a 7×24-hour sentinel watching pages for you
Follow Along
Step 1: Pick the target page and confirm Claw can fetch it
Why: The first gate of web change monitoring isn't configuration — it's confirming the page is "watchable." web_fetch only does a plain HTTP GET and extracts the body; it does not execute JavaScript — for prices and stock rendered by JS, what it fetches back is an empty shell.
Do this: In the chat, ask Claw to fetch the target page once:
Use web_fetch to fetch https://example.com/product/123 and read me the product name and current price on the pageYou should see: Claw's reply includes the product name and price.
Got an empty shell back or can't find the price? Two ways out:
Find the page'sdata source: many JS pages have a JSON API or RSS behind them—watching that is more reliable
Pages that require a login state: the lightweight approach can't handle them; go back to Browser Control for the logged-in session approach
Quick check: Claw can read out the key information on the page (price / title / body)
Step 2: Write the change-detection script (watch-price.js)
Why: The core of a conditional trigger is "only call you when something changed." Change detection is the script's job—fetch the page, extract the field, compare against the last snapshot; if nothing changed, return fire: false, the model keeps sleeping, and one check costs a single curl.
Create watch-price.js (following the pattern of the official PR CI monitoring example: fetch → compare → return):
// watch-price.js —— 盯一个商品页的价格
// 改这两行就能盯你自己的页面
const url = "https://example.com/product/123";
const pricePattern = /¥\s*([0-9][0-9,.]*)/; // 按目标页面的真实结构改
const response = await exec({ command: "curl -sL --max-time 20 " + url });
if (response.status !== "completed" || response.exitCode !== 0) {
// 抓取失败要 throw,不要返回 fire: false
// 安静的监控看起来健康,其实已经瞎了
throw new Error("页面抓取失败:检查网络、URL 或站点反爬");
}
const html = response.aggregated;
const match = html.match(pricePattern);
if (!match) {
throw new Error("页面上找不到价格:页结构变了,或页面是 JS 渲染的空壳");
}
const price = match[1];
const old = trigger.state?.price;
const changed = old !== price;
return {
fire: changed,
...(changed
? { message: "价格变化:" + (old ?? "首次记录") + " → " + price }
: {}),
state: { price: price, url: url },
};Three key conventions (from the official Schedules docs):
- The script must return
{ fire, message?, state? }:firedecides whether to wake the model,messagegets concatenated into the task message, andstatestores the snapshot for the next comparison - The last snapshot lives in
trigger.state, with a 16 KB limit—store only the extracted fields, not the entire page HTML - Each evaluation gets a budget of 30 seconds and at most 5 tool calls; triggered tasks have a built-in minimum interval of 30 seconds
You should see: the script is saved (e.g., as ~/.openclaw/watch-price.js), and url and pricePattern have been replaced with the page you verified in Step 1.
⚠️ Trigger scripts are unattended code execution
Official security note: conditional trigger scripts run unattended by default with the agent's full tool policy (including exec). Only attach scripts you have read and understand; to hard-stop all triggers, set cron.triggers.enabled to false.
- Quick check: the URL in the script has been replaced with your own target page, and running
curl -sL <你的页面>manually on the host shows the price
Step 3: Create the web change monitoring task (--trigger-script + delivery to IM)
Why: One command settles four things at once—how often to check, who judges the change, what to do when awake, and where notifications go—that's all the base configuration web change monitoring needs.
openclaw automations add \
--name "价格监控" \
--every 5m \
--trigger-script ./watch-price.js \
--message "你盯的商品页价格有变化。用 web_fetch 打开页面核对当前价格,写一条中文通知:旧价格、新价格、涨了还是降了、商品链接、一句话值不值得入手。" \
--session isolated \
--announce \
--channel telegram \
--to "-1001234567890"Match each parameter to its role:
| Parameter | Purpose |
|---|---|
--every 5m | Evaluate every 5 minutes; triggered tasks have a built-in minimum interval of 30 seconds, so setting it denser still gets raised to 30 seconds |
--trigger-script ./watch-price.js | The change-detection script; the path is passed as a shell argument (quote it if it contains spaces) |
--message "…" | The task prompt Claw receives upon triggering; the script's returned message gets appended after it |
--session isolated | Each trigger starts a fresh session with no historical baggage |
--announce --channel telegram --to "…" | Notification delivery, written the same way as in the morning brief lesson |
Match delivery targets by channel (details in Daily Morning Brief):
| Where notifications arrive | How to write it |
|---|---|
| Telegram group | --to "-1001234567890" |
| Slack / Discord / Mattermost | --to "channel:<id>" or user:<id> |
| Feishu / WeCom | channel setup see Feishu Setup, WeCom Setup |
| Your own private chat | don't write --to; use --delivery-target owner instead |
You should see: creation succeeded, and the command output shows the parsed delivery route—unparseable destinations fail on the spot, so you don't have to wait for the first trigger to find out.
- Quick check:
openclaw automations show <job-id>shows the schedule as every 5m, the trigger script path is correct, and the delivery route resolves correctly
💡 This is the unique value of OpenClaw
Traditional web change monitoring means either manually refreshing or comparing the entire page as a string, with false positives everywhere. Here you control the detection layer (only comparing the fields you circled in the script), and the notification layer is AI (Claw wakes up, re-reads the page, writes in plain language, and makes a judgment); checks with no change don't wake the model—for the cost of one curl, you get a 7×24-hour sentinel.
Step 4: Use the first trigger as an end-to-end smoke test
Why: On the first evaluation trigger.state is still empty, so the comparison result is necessarily "changed"—which means the first evaluation after you create the task naturally triggers a notification. Treat it as a smoke test: receiving this "first record" means the whole chain—fetch → trigger → notify → deliver—works.
Impatient tip: first set a denser cadence for a trial run, then dial it back to normal once it works (the scheduling parameters add / edit both work):
openclaw automations edit <job-id> --every 30s # 先 30 秒一查
openclaw automations runs <job-id> --limit 5 # 看运行历史
openclaw automations edit <job-id> --every 5m # 通了以后调回来You should see: within one evaluation cycle, the first notification arrives in your IM: "Price change: first record → 1299"; runs shows this run's status as ok.
After that, if the page doesn't change, the monitoring stays quiet—evaluations of fire: falsedon't produce run history, so runs no longer growing doesn't mean the task is broken.
⚠️ A forced run skips the gate
openclaw automations run <job-id> forces a run by default, directly bypassing the trigger script to execute the workload—it triggers a notification even if the page hasn't changed. It's only suitable for testing the "notification + delivery" chain; to test the gate itself, wait for a scheduled evaluation, or use run <job-id> --due when due (respects the gate and won't make the task expire early).
- Quick check: your IM received the first "first record" notification; you can explain why
runsno longer growing is not a failure
Step 5: Tune the notification's flavor (the prompt is the notification's persona)
Why: The default notification is an improvised "woke up, looked, wrote" with a format that drifts every time. The notification's persona is the task prompt—edit swaps it out without rebuilding the task.
openclaw automations edit <job-id> --message "<把下面魔法 Prompt 里的完整版贴进来>"Three tuning points:
- Spell out old and new values: the script's
messagealready contains "old → new"; require in the prompt that it must appear in the notification - Lock down the tone: notifications are for people skimming a push—limit the word count and give it structure
- Nail down the trade-offs: Report price increases too, or only drops? Only worth reporting when it falls below the target price? Write these into the constraints
You should see: after edit succeeds, the message in show has been updated; the next time a real change triggers it, the notification format will be exactly what you defined.
- Quick check: the prompt has a fixed output structure and a nailed-down decision about "what to report"
📋 The Magic Prompt
The "Prompt" on this page is the task prompt—the spot occupied by --message in the step 3 command, or the full version swapped in via edit --message in step 5. When triggered, the message returned by the script (old value → new value) is appended to it and handed to Claw together.
📝 Price Change Notification
Expected result: as soon as the price changes, you receive a notification in IM within 80 characters, with a link and a suggestion—old price, new price, and the direction of the change are clear at a glance.
## Role
You are a price monitoring assistant, responsible for turning price changes on product pages into notifications that can be understood at a glance.
## Task
Based on the old and new prices in the trigger message, use web_fetch to open the product page and verify the current price, then write a Chinese change notification.
## Input Information
### Required Fields
- Product page link: [the URL configured in the script]
- Old price and new price: [already included in the trigger message, e.g. "Price change: first record → 1299"]
### Optional Fields
- Target price: [only remind me when it drops below this price?]
- Reason for watching: [why you're watching this product, e.g. "the historical low is 999"?]
## Output Specification
A Chinese notification of no more than 80 characters: product name + old price → new price (up/down) + product link + one-sentence suggestion
## Constraints
- ✅ Only send if the price matches the page; narrate in Chinese, keep numbers as-is
- ✅ When the price drops below the target, state it explicitly in the suggestion
- ❌ Do not fabricate information not visible on the page (stock, coupons)
- ❌ If verification fails, honestly write "price pending verification"—do not guess📋 Page Update Summary (watching announcement / release pages)
Expected result: as soon as the announcement page or release notes page has new content, you receive a summary of 1-3 items on "what changed this time", instead of the four words "the page has changed". Matching script modification: in watch-price.js, replace "extracting the price" with "extracting the section you care about" (e.g. the version history section), and store that text in state; if the section is too long to fit within 16 KB, store only its hash—Claw will re-fetch the page to see the details when it wakes up anyway.
## Role
You are an update intelligence agent, responsible for watching a page's content changes and writing them into a summary notification.
## Task
The trigger message says the page has changed; use web_fetch to fetch the page, find the new content corresponding to this change, and write a Chinese update summary.
## Input Information
### Required Fields
- Page link: [the URL configured in the script]
### Optional Fields
- Only the part I care about: [e.g. "release notes" or "announcement board"?]
- Change keywords: [e.g. release, open application, price drop?]
## Output Specification
- First line: 📋 Page Update · [page name]
- Summary of 1-3 changes: one sentence per item + the key sentence from the page's original text
- Append the page link at the end; keep the whole text under 120 characters
## Constraints
- ✅ Only report content that actually appears on the page; narrate in Chinese, keep proper nouns in their original form
- ✅ Focus the summary on "what changed this time", not a catalog of the page's content
- ❌ Do not treat old content that has always been on the page as this change
- ❌ Do not fabricate links or datesCheckpoint ✅
web_fetchcan fetch the key information from the target page; JS shell pages have been swapped for a data source or RSSopenclaw automations listshows "price monitoring", with the correct trigger script path and delivery route- You have received the first "first record" notification—the full chain of fetch, trigger, notify, and deliver has been verified
- You can explain the difference between forced
runandrun --due(one bypasses the gate, one respects it) - For watched pages, set
tools.web.fetch.cacheTtlMinutesto 0, so notifications won't be fed a stale page by the 15-minute cache
Pitfall Reminders
❌ Forced run test fired a notification even though the page hadn't changed
Cause: run <job-id> forces a run by default, bypassing the trigger script and executing the payload directly—this is by official design, intended to let you verify the delivery chain at any time.
Correct approach: to test the gate, wait for a scheduled evaluation, or use run <job-id> --due when due. Don't mistake a forced run's "false trigger" for a script bug.
❌ Fetch failure returns fire: false, and the monitor goes "eerily quiet"
Cause: the official guidance explicitly requires throwing on observation failure instead of converting it to fire: false—the failure gets treated as "no change", the monitor goes blind while looking healthy, and the error never reaches the alerting path.
Correct approach: like the script above, throw throw new Error(...) on both fetch failures and missing fields, so failures surface as actionable scheduling errors.
❌ The notification shows Claw still seeing the old page
Cause: web_fetch results are cached for 15 minutes by default (cacheTtlMinutes defaults to 15). If you fetched manually in step 1, or a trigger fired within 15 minutes, when Claw wakes up and calls web_fetch on the same URL, it may get the stale page from the cache.
Correct approach: turn off the cache for monitored pages—tools.web.fetch.cacheTtlMinutes: 0 bypasses the cache for both reads and writes. Note that curl in the script doesn't go through this cache; what's affected is the step where Claw wakes up and views the page with web_fetch.
❌ The page you're watching is JS-rendered, so the script always fetches an empty shell
Cause: neither web_fetch nor curl executes JavaScript; on pages where the price is computed by JS, it simply isn't in the fetched HTML.
Correct approach: watch the page's JSON endpoint or RSS data source; if a logged-in state is truly required, go back to the browser control approach. The reason step 1 verifies first is precisely to avoid crashing here.
Advanced Tips (Optional)
Only fire when the price drops below the target, and stop after one firing. For "one firing is enough" scenarios like flash sales or release alerts: add a threshold check in the script (parse the price into a number and compare), then use the official once: true semantics—after the first successful trigger's payload runs, the task is automatically disabled, so you don't have to remember to turn it off manually.
Don't fire in the middle of the night: active hours. Monitoring tasks support --active-hours-start 08:00 --active-hours-end 22:00 --active-hours-timezone user, plus --idle-only to run only when idle. Checks outside the window are skipped, but changes aren't lost: state remembers what things looked like last time, and once the window opens in the morning, the first evaluation reports the changes that happened overnight.
Start lightweight watching with a single /loop in chat. /loop [间隔] <提示词> creates a loop task directly in the current session (session owner only; /loop status to view, /loop stop to stop). When the interval is omitted, it self-adjusts its pace between 1 minute and 1 hour. Note that /loop has no trigger-script-based change detection—it wakes the model every round, suitable for low-frequency "check whether there's a new announcement"; for real change detection, still use this lesson's --trigger-script.
Safety valve. Conditional trigger scripts, stream monitoring, and script payloads share one master switch: cron.triggers.enabled: false hard-stops everything with one command; set it back to true to resume.
Lesson Summary
✅ You can now:
- Build a "notify me the moment a page changes" web change monitoring task: script detects, Claw writes the notification,
--announcedelivers it into IM - Write a change detection script:
execfetches the page, extracts fields, compares againsttrigger.state, and returns{ fire, message?, state? } - Smoke-test the full chain with the first trigger, and distinguish forced
run(bypasses the gate) from--due(respects the gate) - Use active hours,
once: true, and cache disabling to make the monitoring both cheap and quiet
Key configuration recap:
| Configuration | Recommended value | Description |
|---|---|---|
--every | 5m (lower bound 30s) | Check cadence; the task enforces a built-in minimum interval of 30 seconds |
--trigger-script | ./watch-price.js | Change detection script; the path is referenced as a single shell argument |
trigger.state | Only store the extracted fields | Snapshot limit 16 KB; evaluation budget 30 seconds / 5 tool calls |
--session | isolated | Start a fresh session on every trigger |
--announce --channel --to | Match each channel accordingly | Same as the morning report lesson: Telegram group -100…, Slack/Discord channel:<id>, send to yourself --delivery-target owner |
tools.web.fetch.cacheTtlMinutes | 0 | The monitored page bypasses the 15-minute cache, so notifications don't get fed a stale page |
Next lesson preview
The sentinel in this lesson can only "speak" — it just drops text notifications into the group. In the next lesson Images and voice: add images to content and turn articles into speech, we'll make Claw's output come alive with sound and visuals.
You will learn:
- Adding images to content: how to use OpenClaw's image generation
- Turning articles into speech: TTS makes long-form text into listenable audio
- Other ways to play with OpenClaw's voice capabilities