← Back to Directory
🍳

Inbox Triage Cron

Every 30 minutes: scan new emails, categorize by urgency, draft responses for urgent items, and flag what needs attention.

🤖 00 ↓  |  👤 00
intermediate10 min setup🔄 6 swappable alternatives

🧂 Ingredients

🔌 APIs

scan_and_categorize_new_emails

🔄 Alternatives:

Outlook Microsoft ecosystem integrationSendgrid Transactional email at scaleMailgun Developer-friendly email API

classify_urgency_and_draft_responses

🔄 Alternatives:

Anthropic Better at analysis and reasoningGemini Free tier, multimodalMistral Open-weight, EU-hosted

📋 Step-by-Step Build Guide

STEP 1

Fetch unread emails since last check

Fetch unread emails since last check

Fetch unread emails from Gmail using the Gmail API.

GET https://gmail.googleapis.com/gmail/v1/users/me/messages?q=is:unread&maxResults=20

For each message, GET the full message to extract: sender, subject, date, snippet.
Classify each email:
- 🔴 Urgent: needs reply today (from known contacts, contains "urgent", "ASAP", time-sensitive)
- 🟡 Action Required: needs a response but not time-critical
- 🔵 FYI: newsletters, notifications, CC'd threads
- ⚪ Low Priority: automated receipts, marketing

Return: total unread count, then the top 5 by urgency with sender, subject, and classification.
STEP 2

Classify each as: urgent, needs-response, FYI, or spam

Classify each as: urgent, needs-response, FYI, or spam

Analyze the input and classify it into the defined categories.

Classification approach:
1. Extract key signals from the content (keywords, sender, urgency markers, topic)
2. Match against category definitions
3. Assign confidence score (high/medium/low)
4. For ambiguous cases, classify as the more important/urgent category (err on the side of caution)

Output for each item: { category, priority, confidence, reasoning }

If an item could belong to multiple categories, pick the primary one and note the secondary.
STEP 3

For urgent emails, draft a response

For urgent emails, draft a response

Generate a draft response based on the context.

Guidelines:
- Match the tone of the original message (formal → formal, casual → casual)
- Keep it concise — aim for 2-4 sentences for routine responses
- Include specific references to the original message
- End with a clear next step or call to action
- Don't make commitments or promises on behalf of the user

Mark the draft clearly: "[DRAFT — Review before sending]"
Include a confidence score: High (routine/clear intent), Medium (judgment call), Low (complex/sensitive).

For Low confidence drafts, explain what needs human judgment.
STEP 4

Label/tag emails by category in inbox

Label/tag emails by category in inbox

Label/tag emails by category in inbox

Steps:
1. Validate all required inputs are available
2. Execute the operation described above
3. Verify the result meets expected output format
4. Handle errors gracefully — retry transient failures, log and alert on persistent ones
5. Return structured output with status and any relevant data

If any required data is missing, request it from the user before proceeding.
STEP 5

Send alert for anything marked urgent

Send alert for anything marked urgent

Send a notification to the user via the configured messaging channel.

For Pushover:
POST https://api.pushover.net/1/messages.json
Body: { token: {APP_TOKEN}, user: {USER_KEY}, message: "{notification_text}", title: "{title}", priority: 0 }

For Twilio SMS:
POST https://api.twilio.com/2010-04-01/Accounts/{SID}/Messages
Body: To={phone}, From={twilio_number}, Body={message_text}

Keep the message concise — under 160 characters for SMS, under 500 for push.
Include the most actionable information first.
Log: timestamp, channel, recipient, message preview, delivery status.
STEP 6

Log triage results to daily summary file

Log triage results to daily summary file

Analyze the input and classify it into the defined categories.

Classification approach:
1. Extract key signals from the content (keywords, sender, urgency markers, topic)
2. Match against category definitions
3. Assign confidence score (high/medium/low)
4. For ambiguous cases, classify as the more important/urgent category (err on the side of caution)

Output for each item: { category, priority, confidence, reasoning }

If an item could belong to multiple categories, pick the primary one and note the secondary.

🤖 Example Agent Prompt

Fetch unread emails from Gmail using the Gmail API.

GET https://gmail.googleapis.com/gmail/v1/users/me/messages?q=is:unread&maxResults=20

For each message, GET the full message to extract: sender, subject, date, snippet.
Classify each email:
- 🔴 Urgent: needs reply today (from known contacts, contains "urgent", "ASAP", time-sensitive)
- 🟡 Action Required: needs a response but not time-critical
- 🔵 FYI: newsletters, notifications, CC'd threads
- ⚪ Low Priority: automated receipts, marketing

Return: total unread count, then the top 5 by urgency with sender, subject, and classification.

Copy this prompt into your agent to get started.

⏰ Automation Ideas

  • */30 * * * *