What we're building
Every new email gets classified as urgent, needs reply, FYI or spam. Urgent ones are posted to a Slack channel with a one-line summary, and everything is logged to a Google Sheet.
The workflow, node by node
- 1Gmail Trigger: poll for new messages in your inbox.
- 2AI step (Basic LLM Chain or AI Agent node): send the subject, sender and body with a classification prompt.
- 3Structured output: ask for JSON with category, summary and deadline fields.
- 4Switch node: route on the category field.
- 5Slack node: post urgent emails to #inbox-urgent.
- 6Google Sheets node: append every email's category and summary as a row.
The classification prompt
Keep the categories few and clearly defined. Vague labels give vague routing.
Classify this email for a small agency owner.
Categories:
- urgent: a client problem, payment issue or deadline within 48 hours
- reply: needs a personal response but not urgent
- fyi: newsletters, receipts, notifications
- spam: cold sales or irrelevant
Return only JSON:
{"category": "...", "summary": "max 20 words", "deadline": "YYYY-MM-DD or null"}
<email>
From: {{ $json.from }}
Subject: {{ $json.subject }}
{{ $json.text }}
</email>Tip: Pin the Gmail Trigger's output while building, so you can rerun the rest of the workflow on the same test email.
Before you switch it on
Run it on 20 real emails and check the labels in the sheet. Tighten the category definitions where it gets confused. Then add an error workflow that messages you if any step fails. Silent failure is the classic automation trap.