Build an Email Triage Agent in 30 Minutes

Your first OpenClaw AI agent: automatically categorize emails, flag urgent messages, and draft replies while you sleep

⏱️ 30 minutes
💰 Free (after OpenClaw setup)
🎯 Saves 2-3 hours/week
What you'll build: An AI agent that runs every morning at 8am, reads your unread emails, categorizes them (Urgent/Important/Routine/Spam), flags messages that need your attention, drafts replies to routine questions, and sends you a summary via Telegram. All automatically. No coding required.

Before You Start

Prerequisites:

💡 New to OpenClaw? Read the installation tutorial first. This guide assumes OpenClaw is already running on your machine. Setup takes 15 minutes if you're starting fresh.

What This Agent Does

Your Email Triage Agent will:

✅ Real Results: After setting this up, users report saving 2-3 hours per week by processing 80% of emails automatically and only focusing on the 20% that truly need human attention.

Step-by-Step Guide

1

Create Your Agent Configuration

OpenClaw agents are defined in .openclaw/AGENTS.md. This file tells OpenClaw what agents you have and what they do.

Open your agent configuration:

cd ~/.openclaw
nano AGENTS.md

Add this agent definition:

# Email Triage Agent

**Role:** Inbox manager and email categorization specialist

**Responsibilities:**
- Read all unread emails from Gmail inbox
- Categorize each email as Urgent / Important / Routine / Spam
- Flag urgent messages requiring immediate human attention
- Draft replies to routine emails (save as drafts, don't send)
- Send daily summary via Telegram with breakdown and urgent items

**Skills:**
- gmail_read_messages: Read unread emails
- gmail_create_draft: Create draft replies
- telegram_send_message: Send summary to user

**Triage Rules:**
- URGENT: From boss, customers with "urgent"/"asap", payment/billing issues, server/system alerts
- IMPORTANT: Project updates, meeting invites, client requests, team questions
- ROUTINE: Newsletters, automated notifications, "thanks" replies, low-priority questions
- SPAM: Marketing, cold outreach, suspicious links

**Schedule:** Every day at 8:00 AM (managed via cron)

**Model:** Claude Sonnet (fast + cheap for email processing)

Save and exit: Press Ctrl+O, then Enter, then Ctrl+X

2

Connect Your Gmail Account

OpenClaw needs permission to read your emails and create drafts. This uses OAuth (no passwords stored).

Run the Gmail authentication flow:

openclaw auth gmail

This will:

  1. Open your browser to Google's authentication page
  2. Ask you to select your Gmail account
  3. Show permissions (read messages, create drafts)
  4. Save an OAuth refresh token to ~/.openclaw/credentials/gmail.json
⚠️ Security Note: OpenClaw uses read-only access by default. It can read emails and create drafts, but it cannot send emails or delete messages without explicit permission flags. Your credentials stay local on your machine.

Verify connection:

openclaw test-skill gmail_read_messages --limit 5

You should see your 5 most recent unread emails printed to the terminal.

3

Create the Triage Prompt

Create a reusable prompt that tells Claude how to categorize emails.

Create the prompt file:

mkdir -p ~/.openclaw/prompts
nano ~/.openclaw/prompts/email-triage.txt

Paste this prompt:

You are an email triage specialist. Categorize this email into one of four categories:

**URGENT** - Requires immediate attention (within 1-2 hours)
Examples: Boss/CEO messages, customer complaints, payment failures, system outages, "ASAP" or "urgent" in subject

**IMPORTANT** - Requires attention today
Examples: Project updates, meeting invites, client questions, team collaboration

**ROUTINE** - Can wait 1-3 days
Examples: Newsletters, automated reports, "thanks" replies, low-priority questions

**SPAM** - Marketing, cold outreach, suspicious
Examples: Unsolicited sales emails, promotional content, phishing attempts

For each email, respond with:
1. Category (URGENT/IMPORTANT/ROUTINE/SPAM)
2. One-sentence reason
3. Suggested action (Reply/Archive/Flag/Delete)
4. If category is URGENT or IMPORTANT and email asks a question: draft a short reply

Be strict with URGENT. Only 5-10% of emails should be urgent.

Save and exit.

4

Create the Agent Script

This script runs the agent: reads emails, triages them, sends summary.

Create the script:

nano ~/.openclaw/scripts/email-triage.sh

Paste this script:

#!/bin/bash
# Email Triage Agent - Runs daily to categorize inbox

# Read the triage prompt
PROMPT=$(cat ~/.openclaw/prompts/email-triage.txt)

# Get unread emails (last 24 hours)
EMAILS=$(openclaw run-skill gmail_read_messages --unread-only --limit 50)

# Run Claude to triage each email
RESULTS=$(echo "$EMAILS" | openclaw chat --agent email-triage --system "$PROMPT")

# Count categories
URGENT=$(echo "$RESULTS" | grep -c "^URGENT")
IMPORTANT=$(echo "$RESULTS" | grep -c "^IMPORTANT")
ROUTINE=$(echo "$RESULTS" | grep -c "^ROUTINE")
SPAM=$(echo "$RESULTS" | grep -c "^SPAM")

# Build summary
SUMMARY="📬 Email Triage Summary ($(date '+%Y-%m-%d %H:%M'))

🔴 URGENT: $URGENT
🟡 IMPORTANT: $IMPORTANT
🟢 ROUTINE: $ROUTINE
⚫ SPAM: $SPAM

$RESULTS"

# Send summary via Telegram
openclaw run-skill telegram_send_message --text "$SUMMARY"

echo "Email triage complete. Summary sent to Telegram."

Make it executable:

chmod +x ~/.openclaw/scripts/email-triage.sh
5

Test the Agent

Before scheduling, test that it works end-to-end.

Run the script manually:

~/.openclaw/scripts/email-triage.sh
✅ Expected Output:

You should see:

  1. Terminal output showing emails being processed
  2. Claude's categorization for each email
  3. A Telegram message with the summary and counts
💡 Debugging Tips:
  • No emails found? Make sure you have unread emails in your inbox. Send yourself a test email.
  • Telegram not working? Run openclaw auth telegram first to connect your Telegram bot.
  • Claude errors? Check your Anthropic API key: openclaw doctor
6

Schedule Daily Runs

Set up a cron job to run this agent every morning at 8am.

Open your crontab:

crontab -e

Add this line:

# Run email triage agent every day at 8:00 AM
0 8 * * * ~/.openclaw/scripts/email-triage.sh >> ~/.openclaw/logs/email-triage.log 2>&1

Save and exit.

Your agent will now run automatically every morning. Logs are saved to ~/.openclaw/logs/email-triage.log.

🎉 You're done! Your Email Triage Agent is now running autonomously. Every morning at 8am, you'll wake up to a Telegram summary showing exactly which emails need your attention and which can wait.

What You Just Built

📊 Example Output (Telegram Summary)
📬 Email Triage Summary (2026-03-15 08:00)

🔴 URGENT: 3
🟡 IMPORTANT: 7
🟢 ROUTINE: 18
⚫ SPAM: 12

=== URGENT ===

1. [Customer Support] Site is down - users can't log in
   → ACTION: Reply immediately, escalate to dev team

2. [CEO] Need Q1 numbers for board meeting today
   → ACTION: Reply with dashboard link

3. [Stripe] Payment failed for invoice #2847
   → ACTION: Update payment method

=== IMPORTANT ===

4. [Project Manager] Design review meeting moved to 2pm
   → DRAFT REPLY: "Thanks for the update. I'll be there."

5. [Client] Can you send the final proposal by Friday?
   → DRAFT REPLY: "Yes, I'll have it to you by Thursday EOD."

[... 5 more IMPORTANT emails ...]

=== ROUTINE & SPAM ===
18 routine emails (newsletters, automated reports)
12 spam emails (cold outreach, promotional)
→ Archived automatically

Customization Ideas

🎯 Make It Smarter

⚡ Add More Actions

🔄 Multi-Inbox Support

Time & Cost Breakdown

Metric Value
Setup time 30 minutes (one-time)
Daily runtime 30-60 seconds (fully automated)
Claude API cost £0.10-0.30/day (50 emails × Sonnet)
Monthly cost £3-9 (vs £30-70 for Zapier/Make)
Time saved per week 2-3 hours (inbox triage + reply drafting)
Annual value £5,200-7,800 (at £50/hour rate)
ROI 48,000% (pays for itself in 3 days)

Next Steps

You've just built your first autonomous AI agent. Here's what to do next:

  1. Let it run for 7 days - Monitor the Telegram summaries and adjust triage rules if needed.
  2. Build agent #2 - Try the Meeting Notes Agent (covered in Module 1: Security First).
  3. Learn multi-agent orchestration - The full course teaches you how to run 5-10 agents working together (Module 7).
  4. Join the community - Share your setup in the OpenClaw Discord and see what others are building.
💡 Pro Tip: This Email Triage Agent is covered in depth in Module 3: First 3 Projects of the course. You'll learn advanced techniques like sentiment analysis, automatic follow-up scheduling, and integrating with CRM systems. See full course outline →

Troubleshooting

Agent isn't running at 8am

Gmail authentication fails

Telegram messages not sending

Claude categorizing everything as URGENT

Frequently Asked Questions

Is this safe? Can the AI send emails without my permission?

No. By default, OpenClaw uses read-only Gmail access. It can read emails and create drafts, but it cannot send emails unless you explicitly add the --send flag to gmail_create_draft. The script above only creates drafts - you review and send them manually.

What if Claude makes a mistake and marks something urgent as spam?

You'll still see all categorizations in the Telegram summary. Even if something is marked as spam, you can review it. After 7 days of testing and refining your prompt, the accuracy is typically 95%+. You can also add a "confidence score" to the prompt output.

Can I run this on multiple email accounts?

Yes. Create separate agent configurations in AGENTS.md for each account (e.g., email-triage-work and email-triage-personal), authenticate each account separately, and schedule separate cron jobs.

How much does this cost to run?

If you process 50 emails/day with Claude Sonnet: £3-9/month in API costs. Compare to Zapier (£30+/month) or Make.com (£29+/month). OpenClaw is 60-90% cheaper because you only pay for what you use.

What if I want it to auto-reply to some emails?

Modify the script to add --send flag to gmail_create_draft for emails that match certain criteria (e.g., subject contains "meeting confirmed" or sender is a specific person). Start with drafts-only for 14 days to build confidence.

Master OpenClaw in 10 Hours

This Email Triage Agent is just the beginning. The full OpenClaw Course teaches you to build 5-10 agents working together, handle security properly, optimize token costs, and scale to £500k+ businesses.

£97 • 10 modules • 8-10 hours • 30-day money-back guarantee