Intelligent email organization with AI-powered content classification for Gmail
Needs changesWhat this workflow does
This AI workflow has 17 nodes and runs on a schedule (every 2 minutes). Along the way it connects Gmail and OpenAI Chat Model.
How it runs
Trigger: On a schedule (every 2 minutes).
- Gmail: get many
- Filter Emails Without Excluded Labels (Code): runs custom JavaScript code
- Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
- Gmail: get
- If: checks a condition and branches into true / false
- Merge: merges the data from its input branches
- Extract Email Data (Edit Fields (Set)): sets 4 fields: id, from, headers.subject…
- Categorize Email with AI (AI Agent): runs an AI agent, with model: OpenAI Chat Model
- Store AI Category (Edit Fields (Set)): sets 1 field: output
- Check if Label Exists (Compare Datasets): uses Compare Datasets
…plus 4 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in Categorize Email with AI (v1.7): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) Categorize Email with AI (v1.7) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (11)
- Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - No Operation, do nothing
n8n-nodes-base.noOp - If
n8n-nodes-base.if - Merge
n8n-nodes-base.merge - Gmail
n8n-nodes-base.gmail - Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - AI Agent
@n8n/n8n-nodes-langchain.agent - Compare Datasets
n8n-nodes-base.compareDatasets - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Code
n8n-nodes-base.code
From the author
This workflow leverages AI to intelligently analyze incoming Gmail messages and automatically apply relevant labels based on the email content. The default configuration includes the following labels: Newsletter: Subscription updates or promotional content.…