Label Gmail with a local Ollama model
Local Ollama model sorts unread Gmail. This n8n template checks Gmail for new unread mail, sends each message to a locally running Ollama model, and receives a structured classification. The six categories are Urgent, Action Required, Follow-up, Newsletter, Automated and Spam or Promotional. A router applies the matching Gmail label, and drafts a reply for Urgent and Action Required messages. An optional Google Sheets step logs one row per email. Self-hosted n8n is recommended so the workflow can reach Ollama.
Steps
- Trigger: Gmail trigger watches for new unread emailsGmail
Configurable interval, default every 30 minutes. - Extract email data parses the fields
Sender, subject, body, attachments, metadata. - AI Classifier (Ollama) classifies the emailOllama
Category, priority, confidence, summary, sentiment, reply draft. - Extract classification parses the AI response
- Smart Router sends each email down a path
One of six paths, by classification. - Gmail Label nodes apply the correct labelGmail
- Reply Draft nodes create Gmail draftsGmail
For Urgent and Action Required emails. - Output: Log Entry tracks each email in Google SheetsGoogle Sheets
Category, priority, confidence, summary, timestamp.
Limits
- Labels must be created and their IDs fetched by hand during setup.
What it does well
- Runs locally with Ollama, with zero paid API costs, per the page.
Before you import
You need: Google account for Gmail, Ollama running locally, Google Sheets account (optional).
Similar templates
Gmail sorting and Slack alerts
Also for customer support, 5 steps.
Gmail support and sales reply drafts
Also for customer support, 9 steps.
Gmail labels with Telegram feedback
Also for customer support, 5 steps.
Gmail and Google Sheets: 22 templates compared
Same two apps, different steps.
Sort incoming requests
Other templates that do this task.