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.

Nodes used (7)

AI AgentStructured Output ParserOpenAI Chat ModelGmail

What it does

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 your emails and flags only what needs action. What does it solve? This workflow reads your unread Gmail emails and uses AI to decide what’s important — and what’s not. It labels emails that need your attention, identifies receipts, and trashes everything else. No more manual reading. Just an inbox that uses AI to take care of itself. How it works 1. Every hour, the workflow runs automatically. 2. It searches for unread emails in your Gmail inbox. 3. For each email: - It extracts the content and sends it to OpenAI. 4. The AI returns one of four labels: Action, Receipt, Informational or Spam. 5. Based on the label: - Emails are marked with the appropriate label. - Or moved to trash it is spam. 6. It marks the email as read once processed. How to set up? 1. Connect these services in your n8n credentials: - Gmail (OAuth2) - OpenAI (API key) 2. Create the Gmail labels: - In your Gmail account, create these labels exactly as written: Action, Receipt, and Informational - The workflow will apply these labels based on AI classification. How to customize this workflow to your needs - Change the AI prompt to detect more types of emails like Meeting or Newsletter. - Add more branches to the Switch node to apply custom logic. - Change the schedule to fit your workflow. By default, it runs every hour, but you can update this in the Schedule Trigger node.

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.