← All work
Client Project

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.

The Problem

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.

The Build

How the system works

  1. 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.

  2. 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.

  3. 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.

Stack

Tools used

n8n OpenAI API Gmail API Scheduled batching
Outcome

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.