This workflow corresponds to n8n.io template #7553 — we link there as the canonical source.
This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"id": "9cd65245-e711-4f03-b678-9594d0f35b2f",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-1136,
16
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "cb59304f-46f2-4f7b-821e-9681137da80b",
"name": "Classification Agent",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
-832,
-32
],
"parameters": {
"options": {
"multiClass": true,
"systemPromptTemplate": "Please classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json."
},
"inputText": "=Email: {{ $json.from.value[0].address }}\nName: {{ $json.from.value[0].name }}\nSubject: {{ $json.subject }}\nBody: {{ $json.text}}",
"categories": {
"categories": [
{
"category": "High Priority",
"description": "Emails requiring immediate attention or action, typically from key stakeholders, clients, or decision-makers. These emails often contain time-sensitive requests, deadlines, or escalated issues. Keywords: urgent, ASAP, immediate, deadline, action required, high priority"
},
{
"category": "Work Related",
"description": "Anything related to my Work. Keyword: Work {Add more relevant work details here}"
},
{
"category": "Promotion",
"description": "Anything related to updating on promotions. Keywords: newsletter, promotion, offer, sale, campaign, marketing, launch"
},
{
"category": "Other",
"description": "If you don't know what category is this email."
}
]
}
},
"typeVersion": 1
},
{
"id": "95600e56-c8b2-402c-b769-fe7724bbf5a6",
"name": "AI Agent1",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-448,
176
],
"parameters": {
"text": "=You are a notification assistant. When an email is received, generate a short, casual, and direct notification about it.\nCATEGORY: {{ $json.labelIds[0] }}\nFrom: {{ $json.from.value[0].address || $json.from.value[0].name}} \n\nSubject: {{ $json.subject }}\nBody: {{ $json.text }}\n\n",
"options": {},
"promptType": "define"
},
"typeVersion": 2.2
},
{
"id": "3c04b2db-d9a4-401c-8e38-a7d3b92665fe",
"name": "Send a text message",
"type": "n8n-nodes-base.telegram",
"position": [
-64,
176
],
"parameters": {
"text": "={{ $json.output }}",
"chatId": "{input your telegram id here}",
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "d2834e35-4d72-47bb-95fb-8cb082993833",
"name": "High Priority",
"type": "n8n-nodes-base.gmail",
"position": [
-416,
-96
],
"parameters": {
"labelIds": [
"YELLOW_STAR",
"IMPORTANT"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "157490fb-6cfc-4ec9-a8d6-dc8a20358e47",
"name": "Work Related",
"type": "n8n-nodes-base.gmail",
"position": [
-240,
-96
],
"parameters": {
"labelIds": [
"Label_1704671+1234567890"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "eed9519c-a572-4e60-bafb-80a53c054e07",
"name": "Promotions",
"type": "n8n-nodes-base.gmail",
"position": [
-80,
-96
],
"parameters": {
"labelIds": [
"Label_2537748930215029681"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "9691763a-2a82-41ce-9a3a-2589c5779085",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
-288
],
"parameters": {
"width": 816,
"height": 352,
"content": "## Gmail Label\nThis node is responsible for actually labeling your email.\nYou may add 2 labels in one classification but for this template, I did a 1 Classification, 1 Label\n\n## NOTE:\nMake sure the label name you'll add in your label node is already existing in your gmail account otherwise it won't work."
},
"typeVersion": 1
},
{
"id": "726fc541-0729-4017-ae3f-75bc6e14c3da",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
64
],
"parameters": {
"color": 5,
"width": 816,
"height": 320,
"content": "## Telegram Message\n- Create a bot on @botfather telegram and use that as a credential.\n- Set the chat ID as your chatID so it would message you."
},
"typeVersion": 1
},
{
"id": "f52fa480-449f-44a2-afcb-922fbd0ce2d2",
"name": "4o-mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-448,
272
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "207cff11-d136-4c15-a1ab-df29f17abe64",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
-144
],
"parameters": {
"color": 3,
"width": 432,
"height": 448,
"content": "## AI Classification\nYou may Customize the Categories based on the Emails you want to be labeled."
},
"typeVersion": 1
},
{
"id": "30139756-7d33-4d69-be06-9f509df104e5",
"name": "4o- mini",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-832,
160
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "5b87419b-7ee3-4942-939b-5cd16550a997",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1232,
-112
],
"parameters": {
"width": 304,
"height": 336,
"content": "# Mail Listener\nThis node listens for new emails every minute, you may change the polling time"
},
"typeVersion": 1
}
],
"connections": {
"4o-mini": {
"ai_languageModel": [
[
{
"node": "AI Agent1",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"4o- mini": {
"ai_languageModel": [
[
{
"node": "Classification Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"AI Agent1": {
"main": [
[
{
"node": "Send a text message",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Classification Agent",
"type": "main",
"index": 0
}
]
]
},
"Classification Agent": {
"main": [
[
{
"node": "High Priority",
"type": "main",
"index": 0
},
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
],
[
{
"node": "Work Related",
"type": "main",
"index": 0
},
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
],
[
{
"node": "Promotions",
"type": "main",
"index": 0
},
{
"node": "AI Agent1",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Since Gmail inboxes can quickly become cluttered, this workflow provides an automated AI-based email classification system. It listens for new emails, categorizes them using an AI classifier, applies Gmail labels, and sends you a Telegram notification with a quick summary.
Source: https://n8n.io/workflows/7553/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
E-mail Assistant Agent. Uses gmailTrigger, textClassifier, gmail, lmChatOpenAi. Event-driven trigger; 29 nodes.
This workflow automatically transforms your messy inbox into a neatly organized space while ensuring you never miss a critical message. It connects to your Gmail account and triggers for every new ema
Managing customer support across multiple platforms like email and chat can be a huge time sink. Answering the same questions about order status repeatedly takes your focus away from growing your busi
This workflow is perfect for: Small to medium businesses looking to automate customer support E-commerce stores handling order inquiries and customer questions SaaS companies providing technical suppo
Multi-Channel Email Intelligence Agent. Uses lmChatOpenAi, outputParserStructured, gmailTrigger, agent. Event-driven trigger; 18 nodes.