Classify and label new Gmail messages with OpenAI GPT-4o-mini
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 workflow has 5 nodes and runs on Gmail events. Along the way it connects Gmail. It also calls api.openai.com over HTTP.
How it runs
Trigger: On Gmail events.
- Set Model and Labels (Edit Fields (Set)): sets 3 fields: model, systemPrompt, labelMap
- Post to OpenAI API (HTTP Request): calls api.openai.com (POST)
- Parse Classification Result (Code): runs custom JavaScript code
- Add Labels via Gmail (Gmail): add labels
Services it uses
HTTP calls to: api.openai.com
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 New Email Received).
Nodes used (5)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - Edit Fields (Set)
n8n-nodes-base.set - HTTP Request
n8n-nodes-base.httpRequest - Code
n8n-nodes-base.code - Gmail
n8n-nodes-base.gmail
From the author
Quick overview This workflow triggers on new Gmail messages, sends key email details to OpenAI for classification, parses the JSON result, and applies a matching Gmail label to each email based on the predicted category. How it works 1. Triggers every minute…