Audience: Anyone who wants reliable inbox alerts without paying per-check LLM costs
The workflow
openclaw/bridge/wrappers/email_monitor.ainl does one focused thing: check Gmail for unread messages, and if any exist, fire a Telegram notification via the queue adapter.
# email_monitor.ainl
S core cron "*/15 * * * *"
L0:
R email G ->data
X msgs (or (get data "messages") [])
X count (core.len msgs)
If (gt count 0) ->L_notify ->L_exit
L_notify:
X count_str (core.stringify count)
X msg (core.concat "📧 You have " count_str " unread email(s).")
R queue Put [ "notify", msg ] ->sent
Ret "notified"
L_exit:
Ret "ok"
That's the entire file. Compile it once, schedule it, and it runs deterministically every 15 minutes.
Why this beats a script
| | Python cron script | AINL monitor |
|---|---|---|
| Fails silently on import error | Yes | No — compiler catches it |
| Auditable execution trace | No | Yes — JSONL trajectory |
| Extend without touching internals | Hard | include a new module |
| Token cost per run | Varies (if LLM used) | Zero |
What you need
- AINL installed (
pip install ainativelang) - Email adapter configured (Gmail OAuth or IMAP)
- Queue adapter routing to Telegram (
telegram:prefix inZEROCLAW_NOTIFY_TARGETor OpenClaw equivalent) - OpenClaw or ZeroClaw for scheduling — OpenClaw setup · ZeroClaw setup
ainl check openclaw/bridge/wrappers/email_monitor.ainl --strict
ainl run openclaw/bridge/wrappers/email_monitor.ainl
