Classify Gmail emails with OpenAI and Telegram feedback
Needs changesWhat this workflow does
This AI workflow has 30 nodes and runs when another workflow calls it (plus 2 other triggers). Along the way it connects OpenAI Chat Model, Telegram, Data table and Gmail.
How it runs
Trigger: When another workflow calls it (plus 2 other triggers).
- Gmail: get many
- Get labels (Gmail): work with label
- Get all labels (Gmail): work with label
- Filter: keeps only the items that match a condition
- get AI labels (Filter): keeps only the items that match a condition
- Add label map (Code): runs custom JavaScript code
- Get all pending rules (Data table): get
- set confidence threshold (Code): runs custom JavaScript code
- Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
- AI Check Email (AI Agent): runs an AI agent, with model: OpenAI Chat Model; 1 tool (Previous Rules and actions tool); output parser: Unwanted Email Output Parser
…plus 13 more steps. See the full node list below.
Services it uses
Other OpenAI + Gmail templates (1,623) · Other Telegram + OpenAI templates (807) · Other Gmail + Telegram templates (361)
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 AI Check Email (v1.8): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
- Also check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll).
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
Published 2026 — 6% of 2026 templates need changes for 3.0. See how template age affects 3.0 readiness →
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) AI Check Email (v1.8) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (15)
- AI Agent
@n8n/n8n-nodes-langchain.agent - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Telegram
n8n-nodes-base.telegram - Data Table Tool
n8n-nodes-base.dataTableTool - Manual Trigger
n8n-nodes-base.manualTrigger - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Filter
n8n-nodes-base.filter - Gmail
n8n-nodes-base.gmail - Data table
n8n-nodes-base.dataTable - Gmail Trigger
n8n-nodes-base.gmailTrigger - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Switch
n8n-nodes-base.switch
From the author
An AI-powered Gmail assistant built with n8n that automatically labels emails, learns from your decisions, and safely improves over time using human-in-the-loop training. This workflow combines: - Gmail - OpenAI - Telegram - n8n Data Tables to create a…