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.

n8nRead on 2026-11-168 steps

Steps

  1. Trigger: Gmail trigger watches for new unread emailsGmail
    Configurable interval, default every 30 minutes.
  2. Extract email data parses the fields
    Sender, subject, body, attachments, metadata.
  3. AI Classifier (Ollama) classifies the emailOllama
    Category, priority, confidence, summary, sentiment, reply draft.
  4. Extract classification parses the AI response
  5. Smart Router sends each email down a path
    One of six paths, by classification.
  6. Gmail Label nodes apply the correct labelGmail
  7. Reply Draft nodes create Gmail draftsGmail
    For Urgent and Action Required emails.
  8. 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