Classification et étiquetation automatiques des courriels Gmail basées sur la classification OpenAI GPT-4
Ceci est unAI Summarization, Multimodal AIworkflow d'automatisation du domainecontenant 15 nœuds.Utilise principalement des nœuds comme Gmail, SplitInBatches, ScheduleTrigger, LmChatOpenAi, TextClassifier. Classification et marquage automatiques des e-mails Gmail basés sur la classification OpenAI GPT-4
- •Compte Google et informations d'identification Gmail API
- •Clé API OpenAI
Nœuds utilisés (15)
Catégorie
{
"meta": {
"instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "434e0315-d478-4fc6-9d68-b6d83692d56d",
"name": "Déclencheur Planifié",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-220,
-60
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"name": "Boucle sur les Éléments",
"type": "n8n-nodes-base.splitInBatches",
"position": [
220,
-40
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "e44d7114-2e55-4bc3-82d6-b9fdf10651d8",
"name": "Modèle de Chat OpenAI",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
440,
180
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-5",
"cachedResultName": "gpt-5"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "MGwGMKEkdcjzlYCw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "123cb1eb-0d71-4e61-a4af-f514c54f20e2",
"name": "Ajouter l'Étiquette (Haute Priorité)",
"type": "n8n-nodes-base.gmail",
"position": [
940,
-200
],
"webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
"parameters": {
"labelIds": [
"IMPORTANT"
],
"resource": "thread",
"threadId": "={{ $json.threadId }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "CeBpTZBQSAMKVKJY",
"name": "Gmail account (Billy Email 2)"
}
},
"typeVersion": 2.1
},
{
"id": "e1b53e1d-da8d-483d-8fe3-ddc821b66c0e",
"name": "Ajouter l'Étiquette (Personnel)",
"type": "n8n-nodes-base.gmail",
"position": [
940,
0
],
"webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
"parameters": {
"labelIds": [
"CATEGORY_PERSONAL"
],
"resource": "thread",
"threadId": "={{ $json.threadId }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "CeBpTZBQSAMKVKJY",
"name": "Gmail account (Billy Email 2)"
}
},
"typeVersion": 2.1
},
{
"id": "711c5194-4046-42ac-8e2e-acbe2026ac29",
"name": "Ajouter l'Étiquette (Promotions)",
"type": "n8n-nodes-base.gmail",
"position": [
940,
220
],
"webhookId": "78527ed1-4494-4a9a-994b-a417a3c45ac1",
"parameters": {
"labelIds": [
"CATEGORY_PROMOTIONS"
],
"resource": "thread",
"threadId": "={{ $json.threadId }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "CeBpTZBQSAMKVKJY",
"name": "Gmail account (Billy Email 2)"
}
},
"typeVersion": 2.1
},
{
"id": "ac4c736c-4948-4463-9651-54e1b5e592fa",
"name": "Note Adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
-680,
-140
],
"parameters": {
"color": 4,
"width": 400,
"height": 300,
"content": "## SETUP REQUIRED\n\nWorkflow Configurations:\n- Update the Text Classifier and adjust the labels based on your use case.\n- Add/Remove the Gmail addLabels node to match your use case.\n\nRequired Credentials:\n- Gmail Credential\n- OpenAI API Key"
},
"typeVersion": 1
},
{
"id": "29a5312e-4ddf-41e7-afff-1e8683feca28",
"name": "Note Adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-680,
500
],
"parameters": {
"color": 4,
"width": 680,
"height": 400,
"content": "## 📋 WORKFLOW PROCESS OVERVIEW\n\nStep 1: ⏰ Schedule Trigger executes the workflow every 5 minutes automatically\nStep 2: 📨 Gmail Fetch retrieves up to 10 recent emails from the last 5 minutes using Gmail API\nStep 3: 🔄 Loop Over Items processes each email individually through a batch splitting mechanism\nStep 4: 🤖 Text Classifier (AI Agent) analyzes email subject and body content using OpenAI to categorize emails\nStep 5: 🏷️ Add Labels applies the appropriate Gmail label based on classification: (below is an example only, adjust to your own use case)\n - High Priority emails → \"IMPORTANT\" label\n - Personal emails → \"CATEGORY_PERSONAL\" label \n - Promotional emails → \"CATEGORY_PROMOTIONS\" label\n\n\nStep 6: ↩️ Loop Back continues processing remaining emails until all are classified and labeled"
},
"typeVersion": 1
},
{
"id": "8825d969-1365-4c33-bc00-e995deb40e64",
"name": "Note Adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-680,
200
],
"parameters": {
"color": 4,
"width": 680,
"height": 280,
"content": "## 📧 Smart Gmail Labeling Automation with Text Classifier and GPT-5\n\nWhat This Template Does:\n\n- Runs every 5 minutes to automatically fetch recent emails from your Gmail inbox\n- Retrieves up to 10 emails received within the last 5 minutes\n- Uses OpenAI's Model to intelligently classify each email into predefined categories\n- Automatically applies appropriate Gmail labels based on AI classification results\n- Organizes your inbox by categorizing emails as High Priority, Personal, or Promotional content\n- Processes emails individually through a batch loop to ensure accurate classification"
},
"typeVersion": 1
},
{
"id": "6ab81542-c082-409a-affd-138e766d42a9",
"name": "Note Adhésive4",
"type": "n8n-nodes-base.stickyNote",
"position": [
860,
-380
],
"parameters": {
"color": 4,
"width": 280,
"height": 860,
"content": "## Add Label Nodes\n\nAdd Label Nodes based on your use case. For example, if you have 5 labels, then you can add 5 nodes and adjust the label names on each node.\n"
},
"typeVersion": 1
},
{
"id": "e6ef7d72-00a6-457d-8059-f20dcecc9d9f",
"name": "Note Adhésive5",
"type": "n8n-nodes-base.stickyNote",
"position": [
440,
-180
],
"parameters": {
"color": 4,
"width": 320,
"height": 320,
"content": "## Label Classifier\n\nAdjust the categories based on your use case. Also, add a description to each category for maximum results.\n"
},
"typeVersion": 1
},
{
"id": "ce7c17d4-958e-4d77-8b99-07d71b1005a0",
"name": "Classificateur d'Étiquettes",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
460,
0
],
"parameters": {
"options": {
"fallback": "other"
},
"inputText": "=Email Subject:\n{{ $json.headers.subject }}\n\nEmail Body:\n{{ $json.text }}",
"categories": {
"categories": [
{
"category": "High Priority",
"description": "Emails that require immediate attention or urgent action."
},
{
"category": "Personal",
"description": "Personal refers to activities or matters related to private life, self, or non-work interests."
},
{
"category": "Promotions",
"description": "Promotions refer to marketing messages or activities that advertise products, services, or offers"
}
]
}
},
"typeVersion": 1,
"alwaysOutputData": false
},
{
"id": "1c81d787-784f-48bb-bdd2-2b9b2f9fc975",
"name": "Note Adhésive6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-120,
-220
],
"parameters": {
"color": 4,
"width": 320,
"height": 320,
"content": "## Gmail - Get Emails\n\nGet all messages received within the last 5 minutes. \nYou can adjust the time range and the email limit here.\n"
},
"typeVersion": 1
},
{
"id": "9482f1e2-d564-4f15-938e-d4db4b1a59cb",
"name": "Gmail - Obtenir les E-mails",
"type": "n8n-nodes-base.gmail",
"position": [
-20,
-60
],
"webhookId": "9777ca5f-5226-4fc8-b93b-a3344f890dd3",
"parameters": {
"limit": 10,
"simple": false,
"filters": {
"receivedAfter": "={{ $now.minus({ minutes: 50000 }).toMillis() }}"
},
"options": {},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "CeBpTZBQSAMKVKJY",
"name": "Gmail account (Billy Email 2)"
}
},
"typeVersion": 2.1
}
],
"pinData": {},
"connections": {
"9a3551be-1e97-4b1a-986e-55adb27ea660": {
"main": [
[],
[
{
"node": "ce7c17d4-958e-4d77-8b99-07d71b1005a0",
"type": "main",
"index": 0
}
]
]
},
"ce7c17d4-958e-4d77-8b99-07d71b1005a0": {
"main": [
[
{
"node": "123cb1eb-0d71-4e61-a4af-f514c54f20e2",
"type": "main",
"index": 0
}
],
[
{
"node": "e1b53e1d-da8d-483d-8fe3-ddc821b66c0e",
"type": "main",
"index": 0
}
],
[
{
"node": "711c5194-4046-42ac-8e2e-acbe2026ac29",
"type": "main",
"index": 0
}
],
[
{
"node": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"type": "main",
"index": 0
}
]
]
},
"434e0315-d478-4fc6-9d68-b6d83692d56d": {
"main": [
[
{
"node": "9482f1e2-d564-4f15-938e-d4db4b1a59cb",
"type": "main",
"index": 0
}
]
]
},
"e44d7114-2e55-4bc3-82d6-b9fdf10651d8": {
"ai_languageModel": [
[
{
"node": "ce7c17d4-958e-4d77-8b99-07d71b1005a0",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"9482f1e2-d564-4f15-938e-d4db4b1a59cb": {
"main": [
[
{
"node": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"type": "main",
"index": 0
}
]
]
},
"e1b53e1d-da8d-483d-8fe3-ddc821b66c0e": {
"main": [
[
{
"node": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"type": "main",
"index": 0
}
]
]
},
"711c5194-4046-42ac-8e2e-acbe2026ac29": {
"main": [
[
{
"node": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"type": "main",
"index": 0
}
]
]
},
"123cb1eb-0d71-4e61-a4af-f514c54f20e2": {
"main": [
[
{
"node": "9a3551be-1e97-4b1a-986e-55adb27ea660",
"type": "main",
"index": 0
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Intermédiaire - Résumé IA, IA Multimodale
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Billy Christi
@billyI build scalable automation systems with n8n to help businesses save time and cut costs. 💼 n8n expert available for new projects 📩 billychartanto@gmail.com
Partager ce workflow