AI Gmail Auto-Labelling
An email categorisation system that reads incoming messages with AI and applies accurate custom labels — replacing rigid native filters and cutting API costs in the process.
What needed solving
A high-volume inbox was receiving mail from many different sources — clients, suppliers, newsletters, support requests — and Gmail’s rule-based filters kept mislabelling or missing them entirely.
Manual sorting was consuming time every day.
A previous automation attempt had made things worse: it fired on every incoming email, running up API costs without meaningfully improving accuracy.
How the system works
Switch from event trigger to schedule
Rather than firing on every incoming email, the workflow runs on a schedule and batches unprocessed messages. This change alone cut API costs substantially.
Classify with AI
Each message’s subject line and body are sent to the OpenAI API with a classification prompt that assigns it to the correct category based on meaning rather than keyword matching.
Apply the label
Based on the classification, n8n calls the Gmail API to apply the correct custom label. The inbox stays organised without anyone sorting it.
Tools used
What the system delivers
The inbox sorts itself with noticeably better accuracy than native filters, because the AI understands context rather than matching strings.
API costs dropped after the move from event-triggered to scheduled batch processing — better architecture, lower spend.
Hours a week returned. The client stopped sorting mail and started reading only what was already labelled and relevant.
Have a process like this?
Tell me what your team keeps doing by hand and I’ll tell you what it would take to automate.