Back to Case Studies
Local AI Email Automation

Gmail AI
Local Classification
+ Reply Drafts

Automatically watches your inbox, classifies content with local AI via Ollama, and applies labels — all with zero API costs.

6
Categories
$0
API Cost
Auto
Labeling
Ollama
Local AI

Who Is This For?

Professionals drowning in email who need automated triage.

Founders who want to prioritize urgent messages automatically.

Freelancers managing multiple client threads simultaneously.

Privacy Advocates wanting local AI without data leaving their machine.

What You'll Need

Gmail Account with OAuth credentials (read, modify, compose).

Ollama running locally with a pulled model (Mistral, Llama3, etc.).

n8n Instance (Self-hosted recommended for Ollama connectivity).

Google Sheets (Optional) for logging and analytics.

Workflow Breakdown

From inbox trigger to labeled thread and reply draft.

Workflow diagram for Gmail AI Triage
1

Gmail Trigger & Extract

Watches inbox every 30 mins. Trigger detects new unread emails. The Extract node parses sender, subject, body, and metadata into clean fields for processing.

Gmail Trigger Parse Data Metadata
Gmail Trigger
Watch Unread Emails
Extract Data
Subject, Body, Sender
2

AI Classification

Ollama processes content locally. The AI analyzes the email and returns a structured classification: Category (Urgent, Newsletter, etc.), Priority, Confidence Score, Summary, and a Smart Reply Draft.

Ollama LLM JSON Output Zero API Cost
AI Classifier
Mistral / Llama3 (Local)
🔴
Urgent
📋
Action
📰
Newsletter
3

Smart Router & Actions

A Switch node routes emails to one of 6 paths. Gmail Label nodes apply the correct tag. Reply Draft nodes generate responses for urgent items. All data is logged to Google Sheets.

Router Labeling Drafts
Draft Reply
Ready for Review in Gmail

Tools Powering This

n8n
Orchestration
Ollama
Local AI
Gmail
Inbox
Google Sheets
Logging

Setup Steps

1

Gmail OAuth

Connect your Google account. Grant read, modify, and compose permissions to allow labeling and drafting.

2

Create Labels

In Gmail, create 6 labels: 🔴 Urgent, 📋 Action Required, 💬 Follow-up, 📰 Newsletter, 🤖 Automated, 🚫 Spam-Promo.

3

Get Label IDs

Use the Gmail API or n8n's "Get Many Labels" operation to find the unique ID for each label. Update the workflow nodes.

4

Ollama Setup

Ensure Ollama is running locally (localhost:11434) and pull your model (e.g., ollama pull mistral).

5

Sheets Config (Optional)

Connect Google Sheets for logging. Create columns: Date, From, Subject, Category, Priority, Summary, Has Reply Draft, etc.

6

Test

Send yourself test emails (urgent request, newsletter, promo). Run the workflow manually to verify classification and labeling.

Get This
Workflow Template

Automate your inbox triage with local AI. No API keys, no monthly fees.