Templates / Classify and label new Gmail messages with OpenAI GPT-4o-mini

Classify and label new Gmail messages with OpenAI GPT-4o-mini

Ready for 3.0

by Jon Baynham · 23 views · created 2026-09-11 · Ticket Management, 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 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.

  1. Set Model and Labels (Edit Fields (Set)): sets 3 fields: model, systemPrompt, labelMap
  2. Post to OpenAI API (HTTP Request): calls api.openai.com (POST)
  3. Parse Classification Result (Code): runs custom JavaScript code
  4. Add Labels via Gmail (Gmail): add labels

Services it uses

Gmail

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)

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…

Excerpt from Jon Baynham'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.