JUHE API Marketplace

How to Build an Inbox De-clutter Agent with OpenClaw

8 min read
By Emma Collins

AI Email Digest Automation: Turning Newsletter Overload into a 5-Minute Morning Read

Your inbox receives newsletters from Hacker News digests, a few Substack writers you subscribed to six months ago, two product-update emails from tools you use, and a weekly AI research roundup. None of them are urgent. All of them are worth a quick skim — in theory. In practice they accumulate unread for days, you scan them in bulk on a Sunday, and half of them are already stale.

The fix is an OpenClaw agent that checks your inbox once a day, identifies newsletter emails by sender domain or subject-line pattern, summarizes each one to a 3-sentence brief, and sends you a single digest at 7 AM. Fifteen newsletters become one five-minute read. No more tab-switching. No more unread count anxiety.

This is the simplest entry point in the OpenClaw use cases Productivity category — a working agent in under an hour, with no external infrastructure beyond your existing email account.


By the end of this tutorial you'll have a working inbox de-clutter agent ingesting newsletters via IMAP, summarizing each one via WisGate, and delivering a single digest every morning. The whole setup takes under an hour. Validate summary quality against a real newsletter at wisgate.ai/studio/image before the first scheduled run — get your key at wisgate.ai/hall/tokens.


What the Inbox De-clutter Agent Does

Three steps per scheduled run:

StepActionOutput
1 — IngestConnect to inbox via IMAP; fetch unread emails from the last 24 hoursRaw email list
2 — FilterIdentify newsletter emails by sender domain list or subject-line keyword matchNewsletter subset only
3 — Summarize & deliverPass each newsletter to Claude Haiku via WisGate; assemble digest; send to inboxSingle digest email

Components needed: OpenClaw configured with WisGate (setup below), IMAP credentials for your inbox, and the system prompt and cron schedule in Sections 3 and 4.


OpenClaw + WisGate Configuration

Step 1 — Open the configuration file

curl
nano ~/.openclaw/openclaw.json

Step 2 — Add the WisGate provider

Paste the following into your models section. This registers Claude Haiku (claude-haiku-4-5-20251001) — the recommended model for high-volume newsletter summarization:

json
"models": {
  "mode": "merge",
  "providers": {
    "moonshot": {
      "baseUrl": "https://api.wisgate.ai/v1",
      "apiKey": "WISGATE-API-KEY",
      "api": "openai-completions",
      "models": [
        {
          "id": "claude-haiku-4-5-20251001",
          "name": "Claude Haiku 4.5",
          "reasoning": false,
          "input": ["text"],
          "cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
          "contextWindow": 256000,
          "maxTokens": 8192
        }
      ]
    }
  }
}

Replace WISGATE-API-KEY with your key from wisgate.ai/hall/tokens. Confirm claude-haiku-4-5-20251001 pricing at wisgate.ai/models.

Step 3 — Save and restart

  • Ctrl + OEnterCtrl + X to save and exit
  • Ctrl + C to stop, then run openclaw tui

Step 4 — Validate the summarization call before scheduling

curl
curl -s -X POST "https://api.wisgate.ai/v1/chat/completions" \
  -H "Authorization: Bearer $WISDOM_GATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5-20251001",
    "messages": [
      {"role": "system", "content": "[PASTE SUMMARIZATION SYSTEM PROMPT HERE]"},
      {"role": "user",   "content": "[PASTE NEWSLETTER EMAIL BODY HERE]"}
    ],
    "max_tokens": 300
  }' | jq -r '.choices[0].message.content'

Or paste the system prompt and a real newsletter into wisgate.ai/studio/image with claude-haiku-4-5-20251001 selected to verify summary quality before the first scheduled run.

Note: OpenClaw was previously known as ClawdBot and MoltBot. These steps apply to all versions.


OpenClaw API Email Automation: IMAP Connection and Newsletter Filter

The IMAP connection is the only external infrastructure this agent requires. Configure it before writing the system prompt.

IMAP connection parameters (imap-config.yaml):

yaml
host: imap.gmail.com          # Replace with your provider's IMAP host
port: 993
ssl: true
username: your@email.com
password: "${EMAIL_APP_PASSWORD}"   # Use an app-specific password
mailbox: INBOX
fetch_since_hours: 24               # Look back 24 hours on each run
mark_as_read: false                 # Preserve your own read state

Newsletter detection — two filter options (choose one or combine):

Option A — Sender domain list:

yaml
newsletter_senders:
  - substack.com
  - beehiiv.com
  - mailchimp.com
  - convertkit.com
  - "@newsletters.yourfavoriteblog.com"

Option B — Subject-line keyword match:

yaml
newsletter_keywords:
  - "weekly digest"
  - "issue #"
  - "newsletter"
  - "roundup"
  - "this week in"

Start with Option A if most newsletters come from known platforms. Add Option B to catch writers using custom sending domains. Emails that do not match either filter are ignored — they never reach the summarization step. For related channel-routing patterns, see the Multi-Channel Customer Service tutorial.

LLM Newsletter Summarization: The Summarization System Prompt

Paste this template directly into your OpenClaw conversation context:

You are a newsletter digest assistant.

For each newsletter email provided, return a structured brief:

- Source: [sender name or publication]
- Topic: [1 sentence — what this issue is about]
- Key points: [exactly 3 bullet points — the most useful, specific information]
- Worth reading in full: [Yes / Skim / No] with a one-line reason

Rules:
- Bullet points must contain specific information — not vague summaries
- Do not include promotional content, event announcements, or calls to action
- If the email is purely promotional with no informational content, return:
  Source: [name] | Skip: promotional only
- Maximum output per newsletter: 120 words
- Return plain text only — no markdown headers, no bold, no bullet symbols
  (the digest will be formatted as a plain email)

Why Haiku for this task: newsletter summarization is structured, repetitive, and high-volume. Each call has a clearly defined output schema, low-ambiguity input, and a capped output length. These are exactly the conditions where Haiku performs reliably — Sonnet or Opus would not produce meaningfully better summaries on this task type, and the per-call cost difference compounds at daily digest volumes.

Token budget: each newsletter averages ~800 input tokens. The 120-word output cap limits each summary to ~180 output tokens. At 10 newsletters per day, one digest run consumes approximately 9,800 input tokens and 1,800 output tokens total. Confirm claude-haiku-4-5-20251001 pricing at wisgate.ai/models and calculate your daily cost from there.


Cron Schedule and Digest Assembly

Cron entry — runs daily at 06:45, digest arrives by 07:00:

45 6 * * * openclaw run --agent inbox-declutter

Digest email format:

Subject: Your Morning Digest — [DATE] — [N] newsletters

=== MORNING DIGEST ===

[SUMMARY 1]
---
[SUMMARY 2]
---
[SUMMARY 3]
---
[SKIP list: Publication A (promotional), Publication B (promotional)]

Generated by OpenClaw via WisGate · [N] newsletters processed

Delivery options: send to your own inbox via SMTP using the same credentials as the IMAP ingestion, or write to ~/digests/digest_[DATE].txt for terminal reading. Start with local file output for the first week to validate digest quality before enabling SMTP delivery.


OpenClaw Use Cases: Cost Per Daily Digest

Per-digest token estimate (10 newsletters/day):

ItemTokens
System prompt (per call)~250
Newsletter input avg (per call)~800
Summary output (per call, capped)~180
Total per newsletter~1,230
Total per 10-newsletter digest~12,300

Annual cost at 365 digests/year — confirm claude-haiku-4-5-20251001 pricing from wisgate.ai/models:

VolumeHaiku (WisGate)Haiku (Direct API)Annual saving
10 newsletters/day × 365 daysConfirm + calculateConfirm + calculateCalculate delta
20 newsletters/day × 365 daysConfirm + calculateConfirm + calculateCalculate delta

Insert confirmed figures before publishing. At typical newsletter volumes, the annual cost of this agent is less than one month of a paid email management tool subscription — the comparison is worth stating explicitly once the numbers are confirmed.


OpenClaw Use Cases: Your Simplest First Agent, Running by Tomorrow Morning

The IMAP config is defined. The sender filter takes five minutes to populate. The system prompt is ready to copy. The cron schedule is one line. The Step 4 API call validates summary quality before any scheduled run fires.

This is the OpenClaw use case to start with — not because it is trivial, but because it is fast to ship and immediately useful. Once it is running, every other agent in the Productivity category builds on the same WisGate configuration foundation already in place.


The IMAP connection is the only infrastructure requirement — everything else is configuration. Generate your WisGate key at wisgate.ai/hall/tokens, paste the system prompt, set the cron entry, and validate one summary at wisgate.ai/studio/image. The first digest can be running before tomorrow's workday starts.

How to Build an Inbox De-clutter Agent with OpenClaw | JuheAPI