This workflow follows the Discord → OpenAI Chat 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 →
{
"name": "gmail label and notify",
"nodes": [
{
"parameters": {
"model": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
160,
180
],
"id": "0bc599d4-d4d0-447f-9e0f-1361453de3d5",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"inputText": "={{ $json.Subject }}\n{{ $json.snippet }}",
"categories": {
"categories": [
{
"category": "Personal",
"description": "Prywatne wiadomo\u015bci niezwi\u0105zane z prac\u0105 ani transakcjami. Obejmuj\u0105 komunikacj\u0119 z rodzin\u0105, znajomymi lub prywatne sprawy u\u017cytkownika, takie jak zaproszenia, gratulacje, potwierdzenia spotka\u0144 niezawodowych czy wiadomo\u015bci od lekarza lub urz\u0119d\u00f3w."
},
{
"category": "Recruitment",
"description": "Maile zawieraj\u0105ce oferty zatrudnienia, propozycje rekrutacyjne lub wiadomo\u015bci od rekruter\u00f3w. Mog\u0105 pochodzi\u0107 z platform takich jak LinkedIn, Indeed, Pracuj.pl, czy bezpo\u015brednio od firm i agencji HR. Cz\u0119sto zawieraj\u0105 s\u0142owa kluczowe takie jak \"oferta pracy\", \"stanowisko\", \"szukamy\", \"rekrutacja\", \"do\u0142\u0105cz do zespo\u0142u\", itp."
},
{
"category": "Social",
"description": "Wiadomo\u015bci pochodz\u0105ce z medi\u00f3w spo\u0142eczno\u015bciowych i platform komunikacyjnych, takich jak Facebook, Instagram, Twitter/X, TikTok czy LinkedIn (poza ofertami pracy). Obejmuj\u0105 powiadomienia o wiadomo\u015bciach, komentarzach, oznaczeniach, polubieniach, czy zaproszeniach do znajomych."
},
{
"category": "Rachunki",
"description": "Wiadomo\u015bci zawieraj\u0105ce faktury, potwierdzenia p\u0142atno\u015bci, przypomnienia o rachunkach i informacje o subskrypcjach. Mog\u0105 pochodzi\u0107 od dostawc\u00f3w us\u0142ug takich jak energia, internet, telefon, streaming, banki lub sklepy online. Cz\u0119sto zawieraj\u0105 s\u0142owa typu \u201efaktura\u201d, \u201erachunek\u201d, \u201eop\u0142ata\u201d, \u201edo zap\u0142aty\u201d lub \u201epotwierdzenie p\u0142atno\u015bci\u201d."
},
{
"category": "Spam",
"description": "Niechciane lub masowe wiadomo\u015bci, cz\u0119sto o charakterze reklamowym, podejrzanym albo automatycznym. Mog\u0105 zawiera\u0107 obietnice szybkiego zysku, podejrzane linki, oferty bez zwi\u0105zku z zainteresowaniami u\u017cytkownika, a tak\u017ce wiadomo\u015bci phishingowe. Cz\u0119sto wysy\u0142ane s\u0105 z nieznanych lub nietypowych adres\u00f3w e-mail i mog\u0105 by\u0107 napisane w spos\u00f3b nienaturalny lub zawiera\u0107 b\u0142\u0119dy j\u0119zykowe."
},
{
"category": "Powiadomienia systemowe",
"description": "Wiadomo\u015bci wysy\u0142ane automatycznie przez systemy, aplikacje lub serwisy internetowe, dotycz\u0105ce bezpiecze\u0144stwa konta, zmian ustawie\u0144, logowa\u0144, aktualizacji regulamin\u00f3w lub innych technicznych informacji. Pochodz\u0105 zazwyczaj od platform takich jak Google, Apple, Microsoft, banki, dostawcy us\u0142ug czy systemy chmurowe. Przyk\u0142ady: potwierdzenie aktywacji 2FA, alert o podejrzanym logowaniu, aktualizacja polityki prywatno\u015bci."
}
]
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"typeVersion": 1.1,
"position": [
220,
0
],
"id": "7b25f832-c561-4aab-a009-9cbf7e353881",
"name": "Mail Classifier"
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": [
"Label_8750605238091174941"
]
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
-320
],
"id": "a92203ad-34bc-4a1d-9697-11df8fce632c",
"name": "Personal label",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": [
"Label_6040181302429558490"
]
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
540
],
"id": "3d0144f9-0d76-43b5-8965-6918331f0739",
"name": "Powiadomienia systemowe label",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": [
"Label_1125162703355131933"
]
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
-160
],
"id": "fd6b458c-4a61-4278-b4d3-73430f065507",
"name": "Rekrutacja label",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "markAsRead",
"messageId": "={{ $json.id }}"
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
960,
540
],
"id": "1a6bb220-d446-4e45-bb25-400c3dc8da95",
"name": "Mark a message as read1",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": [
"Label_8862858182055834463"
]
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
220
],
"id": "df7b092e-7f08-41ea-a8fb-d1e1bee38213",
"name": "Social label",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "addLabels",
"messageId": "={{ $json.id }}",
"labelIds": [
"Label_2619847819445000243"
]
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
40
],
"id": "2ca214bc-7d71-4724-acee-f6c66bfb62a5",
"name": "Rachunki label",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "delete",
"messageId": "={{ $json.id }}"
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
740,
380
],
"id": "7e4d126d-5128-40b7-91c5-eac2d9fafe21",
"name": "Delete spam",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"modelId": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "GPT-4O-MINI"
},
"messages": {
"values": [
{
"content": "=Podsumuj poni\u017csz\u0105 wiadomo\u015b\u0107 e-mail z ofert\u0105 pracy, wypisuj\u0105c najwa\u017cniejsze informacje w uporz\u0105dkowany spos\u00f3b. Zwr\u00f3\u0107 szczeg\u00f3ln\u0105 uwag\u0119 na poni\u017csze elementy:\n\nTytu\u0142 emaila\n\nStanowisko\n\nWide\u0142ki p\u0142acowe \u2013 je\u015bli podano\n\nWymagane technologie lub narz\u0119dzia\n\nForma zatrudnienia \u2013 np. UoP, B2B\n\nTryb pracy \u2013 zdalna, hybrydowa, stacjonarna\n\nKr\u00f3tki opis oferty \u2013 dla jakiej firmy, bran\u017ca, typ projekt\u00f3w\n\nLink do oferty pracy \u2013 je\u015bli podano\n\nLink do strony firmy \u2013 je\u015bli podano\n\nMail:\nTytu\u0142: {{ $json.subject }}\nContent as html:\n```html\n{{ $json.textAsHtml }}\n```\n"
}
]
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.8,
"position": [
1180,
-160
],
"id": "bd95797d-8b5e-48fe-9df2-55e7f804ce06",
"name": "Message a model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"authentication": "webhook",
"content": "={{ $json.message.content }}",
"options": {}
},
"type": "n8n-nodes-base.discord",
"typeVersion": 2,
"position": [
1520,
-160
],
"id": "af5ed0ca-307e-4f90-b633-af949fe8a076",
"name": "JobMessage",
"credentials": {
"discordWebhookApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "markAsRead",
"messageId": "={{ $json.id }}"
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
960,
220
],
"id": "562ac813-8fb4-4d92-a20f-01a95dbbbc99",
"name": "Mark a message as read",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "getAll",
"filters": {
"readStatus": "unread"
}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
-20,
0
],
"id": "f77025e7-0eb8-4cea-a816-89936dc8126c",
"name": "Get many messages",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 10
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-280,
0
],
"id": "e36fd428-5267-4f13-859e-72f9bc4b1602",
"name": "Schedule Trigger"
},
{
"parameters": {
"operation": "get",
"messageId": "={{ $json.id }}",
"simple": false,
"options": {}
},
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
960,
-160
],
"id": "14cc2fab-dced-4f03-bc6a-de2929628c68",
"name": "Get a message",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Runs Every 10 Minutes\nFetches all new email messages, then sends their subject lines and content snippets to an AI service for automatic categorization. This helps organize incoming emails based on their topic or intent.\n",
"height": 400,
"width": 860
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-320,
-100
],
"id": "398d2e95-d84b-4b2a-b1e3-5c8ff7d4a7c8",
"name": "Sticky Note"
}
],
"connections": {
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Mail Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Mail Classifier": {
"main": [
[
{
"node": "Personal label",
"type": "main",
"index": 0
}
],
[
{
"node": "Rekrutacja label",
"type": "main",
"index": 0
}
],
[
{
"node": "Social label",
"type": "main",
"index": 0
}
],
[
{
"node": "Rachunki label",
"type": "main",
"index": 0
}
],
[
{
"node": "Delete spam",
"type": "main",
"index": 0
}
],
[
{
"node": "Powiadomienia systemowe label",
"type": "main",
"index": 0
}
]
]
},
"Personal label": {
"main": [
[]
]
},
"Powiadomienia systemowe label": {
"main": [
[
{
"node": "Mark a message as read1",
"type": "main",
"index": 0
}
]
]
},
"Rekrutacja label": {
"main": [
[
{
"node": "Get a message",
"type": "main",
"index": 0
}
]
]
},
"Message a model": {
"main": [
[
{
"node": "JobMessage",
"type": "main",
"index": 0
}
]
]
},
"JobMessage": {
"main": [
[]
]
},
"Social label": {
"main": [
[
{
"node": "Mark a message as read",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "Get many messages",
"type": "main",
"index": 0
}
]
]
},
"Get many messages": {
"main": [
[
{
"node": "Mail Classifier",
"type": "main",
"index": 0
}
]
]
},
"Get a message": {
"main": [
[
{
"node": "Message a model",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "35d8afe2-b492-47a4-aea6-1c173acc0396",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "QTByQ7cOTbJFRJtL",
"tags": [
{
"name": "gmail",
"id": "OjF86izcAsaMBeNj",
"createdAt": "2025-06-26T04:39:28.523Z",
"updatedAt": "2025-06-26T04:39:28.523Z"
},
{
"name": "discord",
"id": "nG3fQDuzzdRbqfkv",
"createdAt": "2025-06-26T04:39:33.657Z",
"updatedAt": "2025-06-26T04:39:33.657Z"
},
{
"name": "openai",
"id": "FAjSxJz0hKSLQbVc",
"createdAt": "2025-06-26T04:39:38.333Z",
"updatedAt": "2025-06-26T04:39:38.333Z"
}
]
}
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.
discordWebhookApigmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
gmail label and notify. Uses lmChatOpenAi, textClassifier, gmail, openAi. Scheduled trigger; 16 nodes.
Source: https://github.com/PilarczykM/AI-Notes/blob/5cae399d44045f90d0e0c7cf9b8ccf5e77d2609b/n8n/gmail_label_and_notify/gmail_label_and_notify.json — 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.
This n8n template demonstrates how to automate email classification, labeling, draft generation, and logging using Gmail, OpenAI, and Google Sheets. Use cases include customer support management, sale
This n8n template uses AI to automatically classify incoming Gmail messages into five categories and route them to the right people or departments. It can also reply automatically and send WhatsApp al
Detects new unread Gmail messages Extracts sender name for personalized replies Classifies the email into one of four categories Applies the correct Gmail label and either sends an auto-reply, creates
Email Automation AI-Powered Operations Internal Productivity Tools
This section automates Gmail message handling through AI-powered classification and response. Using the LangChain Text Classifier, incoming emails are analyzed and sorted into four categories — High P