Templates / Automatic Gmail categorization and labeling with AI

Automatic Gmail categorization and labeling with AI

Ready for 3.0

by Matt Chong | n8n Creator ✓ · 7,813 views · created 2025-07-09 · Personal Productivity, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What this workflow does

This AI workflow has 13 nodes and runs on a schedule (every hour). Along the way it connects OpenAI Chat Model and Gmail.

How it runs

Trigger: On a schedule (every hour).

  1. Get All Unread Messages (Gmail): get many
  2. Edit Fields (Edit Fields (Set)): sets 4 fields: id, text, from…
  3. AI Agent: runs an AI agent, with model: OpenAI Chat Model, OpenAI Fall Back Model; output parser: Structured Output Parser
  4. Switch: routes items into 3 branches
  5. Add label "Action" to email (Gmail): add labels
  6. Add label "Informational" to email (Gmail): add labels
  7. Add label "Receipt" to email (Gmail): add labels
  8. Delete email (Gmail): delete (thread)
  9. Mark email as read (Gmail): mark as read

Services it uses

OpenAI Chat ModelGmail

Before you upgrade to n8n 3.0

Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.

Nodes used (7)

From the author

This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Who is this for? If your inbox is full of unread emails, this workflow is for you. Instead of reading through them one by one, let AI do the sorting. It reads…

Excerpt from Matt Chong | n8n Creator's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.