Email Automation Productivity n8n · OpenAI · Gmail

AI-Powered Gmail
Auto-Labelling Workflow

Built a smart email categorisation system using n8n and OpenAI that reads incoming Gmail messages and applies accurate custom labels automatically — replacing manual sorting and cutting unnecessary API costs.

Auto
Labels applied by AI
↓ Cost
Reduced API spend
Hours
Saved weekly on email sorting

Gmail's native filters weren't smart enough

The client had a high-volume inbox with emails from many different sources — clients, suppliers, newsletters, support requests. Gmail's rule-based filters were too rigid and kept mislabelling or missing emails. Manual sorting was eating time every single day.

They also had a previous automation that used Gmail triggers — but it was firing on every email, running up API costs unnecessarily.

Architecture & workflow

// gmail_ai_labeller.workflow
Scheduled
Trigger
📧
Fetch
Emails
🧠
OpenAI
Classify
n8n
Router
🏷️
Apply
Label
Done
01

Switched from trigger to schedule

Instead of firing on every single incoming email (expensive), the workflow runs on a schedule — batching unprocessed emails. This alone cut API costs significantly.

02

AI classification with OpenAI

Each email's subject line and body are sent to OpenAI with a custom prompt that classifies it into the right category — client, supplier, newsletter, urgent, support, and more.

03

n8n routes and applies labels

Based on the AI classification, n8n calls the Gmail API to apply the correct custom label. The inbox stays organised automatically with no manual intervention.

Tech stack

n8n
🧠 OpenAI API
📧 Gmail API
🔗 Webhooks

What changed after deployment

Inbox sorted automatically with far greater accuracy than Gmail's native filters — AI understands context, not just keywords.

Reduced API costs by switching from event-triggered to scheduled batch processing — smarter architecture, lower spend.

Hours saved weekly — the client stopped manually sorting email and started only reading what mattered, already labelled and ready.

Inbox out of control?

I build smart email automation that keeps you organised without lifting a finger.

Get in Touch See More Projects