Intelligent Gmail label management with AI & Discord notifications
Ready for 3.0What this workflow does
This AI workflow has 22 nodes and runs on Gmail events. Along the way it connects Gmail, Discord and OpenAI Chat Model.
How it runs
Trigger: On Gmail events.
- Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
- Get many labels (Gmail): work with label
- Merge: merges the data from its input branches
- Filter: keeps only the items that match a condition
- Merge: merges the data from its input branches
- Basic LLM Chain: sends a prompt to an LLM, with model: OpenAI Chat; output parser: Structured Output Parser
- Aggregate: combines items into one
- Code: runs custom JavaScript code
- Add old_labels [] (Edit Fields (Set)): sets 3 fields: output, output.old_labels, output.added_label_names
- Split Out: splits a list into separate items
…plus 9 more steps. See the full node list below.
Services it uses
Other OpenAI + Gmail templates (1,623) · Other OpenAI + Discord templates (89) · Other Gmail + Discord templates (56)
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) (Gmail Trigger).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (13)
- Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - Gmail Trigger
n8n-nodes-base.gmailTrigger - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Gmail
n8n-nodes-base.gmail - Code
n8n-nodes-base.code - Merge
n8n-nodes-base.merge - Split Out
n8n-nodes-base.splitOut - Discord
n8n-nodes-base.discord - Filter
n8n-nodes-base.filter - Aggregate
n8n-nodes-base.aggregate - Edit Fields (Set)
n8n-nodes-base.set - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
From the author
How it works - This workflow will trigger upon new mail in your gmail inbox and will automatically apply existing labels OR identify, create, then apply up to 5 new labels. - This is currently set up to run using a OpenAI endpoint which I have set up…