Label incoming Gmail emails with GPT-5 and Gmail labels
Ready for 3.0Ready 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 6 nodes and runs on Gmail events. Along the way it connects Gmail and OpenAI Chat Model.
How it runs
Trigger: On Gmail events.
- Set Label Taxonomy (Edit Fields (Set)): sets 7 fields: CategoryList, Sales_LabelId, Support_LabelId…
- AI Email Classifier (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI GPT-5 Mini Model
- Map Category to Gmail Label (Code): runs custom JavaScript code
- Apply Label in Gmail (Gmail): add labels
Services it uses
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.
- Still check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll) (When Email Received in Gmail).
Nodes used (6)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - Edit Fields (Set)
n8n-nodes-base.set - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - Code
n8n-nodes-base.code - Gmail
n8n-nodes-base.gmail
From the author
Quick overview This workflow watches for new Gmail messages, uses OpenAI to classify each email into a category, maps that category to a Gmail label ID, and then applies the matching label to the message automatically. How it works 1. Triggers every minute…