Automated Gmail Classification and Labeling with GPT-4, Sheets and Slack Alerts

Go to Workflow
0 views
Built by Chris Mielke Chris Mielke
Created on June 16, 2026

Description

This n8n template automates email labeling using AI-enhanced classification and intelligent routing

Gmail users report spending significant time manually sorting email, so this tool helps alleviate that burden.

How it works
Gmail Trigger monitors unread emails every 2 minutes
Once an email arrives, the content is extracted with HTML cleaning
AI Agent (the node is set for Chat GPT-4) is used for classification & entity extraction
A Structured Output Parser parses the email to JSON
A 9-way category routing system categorizes the email (Inquiry, Support, Newsletter, Marketing, Personal, Urgent, Spam, Invoice, Meeting)
Gmail auto-labeling is used for each category
Google Sheets is used for logging (the main log that includes all emails and  an error log which are emails that cannot be classified)
Slack alerts are generated for high-priority/urgent emails
Error handling is done with separate error logging in Google Sheets

How to use
Set up credentials for Google Gmail, LLM (ChatGPT, Gemini, etc.), Google Sheets, and Slack
Modify the categories as needed per user preference

Requirements
Gmail 
Any LLM like ChatGPT or Google Gemini
Google Drive with Google Sheets is optional for logging and error handling
Slack is optional for high-priority messages

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Slack
n8n-nodes-base.slack
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured