Sort Gmail leads, meetings, and trash with OpenAI classification
Ready for 3.0What this workflow does
This AI workflow has 16 nodes and runs on Gmail events. Along the way it connects Gmail and OpenAI.
How it runs
Trigger: On Gmail events.
- Fetch Full Email Message (Gmail): get
- Execute Pre-Classify Rules (Code): runs custom JavaScript code
- Route by Pre-Classification (Switch): routes items into 5 branches
- Label as Team (Gmail): add labels
- Label as Meetings (Gmail): add labels
- OpenAI: uses OpenAI
- Calculate Deletion Time (Code): runs custom JavaScript code
- Parse Classification Result (Code): runs custom JavaScript code
- Label Pending Deletion (Gmail): add labels
- Route by LLM Classification (Switch): routes items into 3 branches
…plus 4 more steps. See the full node list below.
Services it uses
Other OpenAI + Gmail templates (1,623)
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 Email Received1).
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (7)
- Gmail Trigger
n8n-nodes-base.gmailTrigger - Gmail
n8n-nodes-base.gmail - Code
n8n-nodes-base.code - Switch
n8n-nodes-base.switch - No Operation, do nothing
n8n-nodes-base.noOp - OpenAI
@n8n/n8n-nodes-langchain.openAi - Wait
n8n-nodes-base.wait
From the author
Quick Overview This workflow monitors Gmail for new messages, applies rule-based pre-classification, and uses OpenAI to categorize ambiguous emails as lead, review, or trash, then applies Gmail labels and schedules automatic deletion for trash threads. How it…