Etiquetador de correos automático
Este es unAI Summarization, Multimodal AIflujo de automatización del dominio deautomatización que contiene 27 nodos.Utiliza principalmente nodos como Set, Code, Gmail, Merge, Filter. Gestión inteligente de etiquetas de Gmail con notificaciones de Discord, impulsada por IA
- •Cuenta de Google y credenciales de API de Gmail
- •Bot Token de Discord o Webhook
- •Clave de API de OpenAI
Nodos utilizados (27)
Categoría
{
"id": "p88sqsRiRSpYb4Da",
"meta": {
"instanceId": "c341ffddc74ebf27df927741c2e7cfe51645fd6ab7947c701ecbb8accd585228",
"templateCredsSetupCompleted": true
},
"name": "Auto email labeler",
"tags": [
{
"id": "KXa95L999LpnSKKK",
"name": "Gmail",
"createdAt": "2025-08-30T14:29:58.156Z",
"updatedAt": "2025-08-30T14:29:58.156Z"
}
],
"nodes": [
{
"id": "9bf78ec9-a9a9-4db5-8cb0-4eb6cb6cf3b5",
"name": "Cadena Básica de LLM",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
608,
32
],
"parameters": {
"text": "=Provide a summary of the email in JSON format. You will provide a (1) Id, (2) summary, (3) extract the relevant entity such as person, organization, (4) provide a list of up to 5 labels from the list provided in the \"Labels List\" below to categorize the email. Or if none are appropriate, please come up with new labels (up to 5).\n\nHere is the email content:\nFrom: {{ $json.From }}\nSubject: {{ $json.Subject }}\nContent: {{ $json.snippet }}\nLabel List: {{ $json.existing_labels.map(label => label.name) }}\n\nHere is an example output:\n{\n \"summary\": \"This is an email advertising a new designer collection of goods from Haider Ackermann on Mr. Porter. It is Haider Ackermann's debut collection.\",\n \"people\": \"Mr. Porter\",\n \"labels\":\n [\n \"Advertisement\",\n \"Designer Label\",\n \"Clothes\",\n \"Online Shopping\"\n ]\n}\n\nYour Output:\n",
"batching": {},
"promptType": "define",
"hasOutputParser": true
},
"retryOnFail": true,
"typeVersion": 1.7,
"waitBetweenTries": 100
},
{
"id": "0216c4d9-041b-41d0-ae1d-6965399bfc61",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-432,
304
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "CKyTztL6Pu4sMVhC",
"name": "Gmail account"
}
},
"typeVersion": 1.3
},
{
"id": "d8d3a318-0477-4e5d-8e1d-2d7ab073f217",
"name": "Analizador de Salida Estructurada",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
736,
320
],
"parameters": {
"autoFix": true,
"jsonSchemaExample": "{\n \"messageId\": \"\",\n \"summary\": \"This email higlights the convenience of using an Alexa-enabled smart thermostat for temperature control and mentions Alexa's ability to assist with shopping lists, specifically laundry detergent. It also references a 'Weekly Spotlight' feature related to product sorting.\",\n \"people\": \"Alexa\",\n \"labels\":\n [\n \"Smart Home\",\n \"Voice Assistant\",\n \"Thermostat\",\n \"Shopping\",\n \"Productivity\"\n ]\n}"
},
"typeVersion": 1.3
},
{
"id": "99594eaa-8459-4cb9-905e-399549cb8b72",
"name": "Crear una etiqueta",
"type": "n8n-nodes-base.gmail",
"onError": "continueRegularOutput",
"position": [
1472,
400
],
"webhookId": "365633e2-f709-4412-9176-bf921b3f717d",
"parameters": {
"name": "={{ $json[\"output.labels\"] }}",
"options": {},
"resource": "label",
"operation": "create"
},
"credentials": {
"gmailOAuth2": {
"id": "CKyTztL6Pu4sMVhC",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "c2beef7d-1352-40ac-868c-be730a463d69",
"name": "Código",
"type": "n8n-nodes-base.code",
"position": [
1216,
320
],
"parameters": {
"jsCode": "var item = $input.first();\nvar new_labels = new Set(item.json.output.labels) // new labels defined by LLM\nvar old_labels = new Set(item.json.existing_labels.map(label => label.name)) // message labels\nvar label_array = item.json.existing_labels // users label dictionary\nvar labels_to_create = new Set();\nvar existing_labels = new Set();\n\n// identify new labels to create\nnew_labels.forEach(label => {\n if (old_labels.has(label)) {\n console.log(\"dupe found: \" + label)\n existing_labels.add(label)\n } else {\n console.log(\"unique found: \" + label)\n labels_to_create.add(label)\n }\n});\n\n// each new label to create ends up in output.labels array\nitem.json.output.labels = []\nlabels_to_create.forEach(label => item.json.output.labels.push(label))\n\n// existing labels end up in output.old_labels array\n// for each old label, look up the label id\nitem.json.output.old_labels = []\nexisting_labels.forEach(label => {\n var label_obj = label_array.find(l => l.name == label)\n if (label_obj) {\n console.log(\"replacing \" + label + \" with id \" + label_obj.id)\n item.json.output.old_labels.push(label_obj.id)\n item.json.output.added_label_names.push(label_obj.name)\n }\n})\n\nitem.json.output.messageId = item.json.id;\n\nreturn $input.all();"
},
"typeVersion": 2
},
{
"id": "c8153181-5a9a-4ec7-a61b-f559d34e0d3f",
"name": "Combinar2",
"type": "n8n-nodes-base.merge",
"position": [
1040,
48
],
"parameters": {
"mode": "combineBySql",
"query": "SELECT * FROM input1 LEFT JOIN input2",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "3ab1de7a-2dc1-4199-98f5-1e0e0cd8fcc3",
"name": "Separar",
"type": "n8n-nodes-base.splitOut",
"position": [
1344,
400
],
"parameters": {
"options": {},
"fieldToSplitOut": "output.labels"
},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "758ce7fa-b66a-4018-b576-e754cff5e5f9",
"name": "Combinar3",
"type": "n8n-nodes-base.merge",
"position": [
1888,
128
],
"parameters": {
"mode": "combineBySql",
"query": "SELECT * FROM input1 LEFT JOIN input2",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "7be3f984-3cf7-4868-8148-8e3a012028e3",
"name": "Añadir etiqueta al mensaje",
"type": "n8n-nodes-base.gmail",
"position": [
2208,
16
],
"webhookId": "8a2d4934-7637-40d0-84a3-987d7fe688e3",
"parameters": {
"labelIds": "={{ $json.labels_to_add }}",
"messageId": "={{ $json.output.messageId }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "CKyTztL6Pu4sMVhC",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "97c77c1d-0857-46cf-ba2a-4e38b0b48e4f",
"name": "Enviar un mensaje",
"type": "n8n-nodes-base.discord",
"position": [
2848,
304
],
"webhookId": "88a8856f-4974-45a6-b941-e5ddb5da4302",
"parameters": {
"content": "={{ $json.text.split(\"MESSAGE STARTS HERE\").last() }}",
"guildId": {
"__rl": true,
"mode": "list",
"value": "1411315313664069778",
"cachedResultUrl": "https://discord.com/channels/1411315313664069778",
"cachedResultName": "terribletap's server"
},
"options": {},
"resource": "message",
"channelId": {
"__rl": true,
"mode": "list",
"value": "1411315314624430103",
"cachedResultUrl": "https://discord.com/channels/1411315313664069778/1411315314624430103",
"cachedResultName": "general"
}
},
"credentials": {
"discordBotApi": {
"id": "EllllgZJlaKOTtPf",
"name": "Discord Bot account"
}
},
"typeVersion": 2
},
{
"id": "4e637594-2570-471e-89a3-129c990c70f7",
"name": "Obtener múltiples etiquetas",
"type": "n8n-nodes-base.gmail",
"position": [
-80,
400
],
"webhookId": "59d1eb15-6c4c-4963-9eee-5bca6e0a3364",
"parameters": {
"resource": "label",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "CKyTztL6Pu4sMVhC",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "0652a435-b021-46bb-911e-8d66ad4ab262",
"name": "Filtrar",
"type": "n8n-nodes-base.filter",
"position": [
80,
400
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "652bbdfc-8258-4acf-b8cc-38f88a69d87c",
"operator": {
"type": "string",
"operation": "startsWith"
},
"leftValue": "={{ $json.id }}",
"rightValue": "Label"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "fb63935c-5a27-4e9e-96b8-5d73301890bf",
"name": "Agregar1",
"type": "n8n-nodes-base.aggregate",
"position": [
224,
400
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "existing_labels"
},
"typeVersion": 1
},
{
"id": "1173c4fc-0037-4c9f-81cc-0e52cd4caa2a",
"name": "Agregar2",
"type": "n8n-nodes-base.aggregate",
"position": [
1600,
400
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "created_labels"
},
"typeVersion": 1
},
{
"id": "19f5848c-d7e6-45c1-8ed9-c5a6aa6c9f5e",
"name": "Editar Campos3",
"type": "n8n-nodes-base.set",
"position": [
2064,
16
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "30b6e814-f461-4957-bee3-433acf9df86e",
"name": "output.messageId",
"type": "string",
"value": "={{ $json.output.messageId }}"
},
{
"id": "cc6b96ee-7eed-463f-b324-511395366671",
"name": "labels_to_add",
"type": "array",
"value": "={{ $json.output.old_labels.concat($json.created_labels.map(item => item.id))}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "a537fe85-ff6b-44f6-8676-ec118a451f57",
"name": "Iterar sobre elementos",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-288,
304
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "23a89c87-5b44-4a1d-8750-2b817984e33a",
"name": "OpenAI Chat 10001",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
608,
736
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "/home/rocketegg/.cache/huggingface/hub/models--unsloth--gpt-oss-20b-GGUF/snapshots/c6cedd4259adbfe7e4d4d983a0400bf4cc38e7db/gpt-oss-20b-F16.gguf",
"cachedResultName": "/home/rocketegg/.cache/huggingface/hub/models--unsloth--gpt-oss-20b-GGUF/snapshots/c6cedd4259adbfe7e4d4d983a0400bf4cc38e7db/gpt-oss-20b-F16.gguf"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "LKEGGdxiA0Bf5HVT",
"name": "OpenAi localhost 10001"
}
},
"typeVersion": 1.2
},
{
"id": "3a3c249c-b2a5-4b26-8565-345a78bbe347",
"name": "OpenAI Chat 10000",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-688,
-688
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "/home/rocketegg/.cache/huggingface/hub/models--unsloth--GLM-4.5-Air-GGUF/snapshots/a5133889a6e29d42a1e71784b2ae8514fb28156f/Q4_K_S/GLM-4.5-Air-Q4_K_S-00001-of-00002.gguf",
"cachedResultName": "/home/rocketegg/.cache/huggingface/hub/models--unsloth--GLM-4.5-Air-GGUF/snapshots/a5133889a6e29d42a1e71784b2ae8514fb28156f/Q4_K_S/GLM-4.5-Air-Q4_K_S-00001-of-00002.gguf"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "hXmYMFnRaBrbl3No",
"name": "OpenAi localhost 10000"
}
},
"typeVersion": 1.2
},
{
"id": "7514e196-94bf-462e-95c4-8698978e8b9e",
"name": "Cadena Básica de LLM1",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"position": [
2592,
304
],
"parameters": {
"text": "=INSTRUCTIONS: Rewrite the message below with fun emojis per the instructions below. PREPEND the message with \"MESSAGE STARTS HERE\".\n\nI'm sending a fun discord message so I need the following summary in markdown with emojis appropriate for the content (e.g. financial emails with financial emojis, advertisements with advertisement emojis, and depending on what they are selling, the appropriate emoji, etc).\n\n---\nCONTENT OF THE MESSAGE:\n\nHello! I finished labeling an email.\n\n**From:** {{ $json.From }}\n**Subject:** {{ $json.Subject }}\n**Summary:** {{ $json.output.summary }}\n**Entity:** {{ $json.output.people }}\n**Date:** {{ new Date(parseInt($json.internalDate)) }}\n**Id:** {{ $json.id }}\n\n**Labels Added:**\n{{ $json.created_labels.map(l => `- ${l.name}`).join('\\n> ') }}\n\n**Appended Labels:**\n{{ $json.output.added_label_names.map(name => `- ${name}`).join('\\n> ') }}\n\n--- OUTPUT:\nMESSAGE STARTS HERE:\n\n",
"batching": {},
"promptType": "define"
},
"retryOnFail": true,
"typeVersion": 1.7
},
{
"id": "dd821c19-35ed-4295-89d5-d3202ea7258a",
"name": "Combinar",
"type": "n8n-nodes-base.merge",
"position": [
2464,
304
],
"parameters": {
"mode": "combineBySql",
"query": "SELECT * FROM input1 LEFT JOIN input2 ",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "e05d0e9c-161e-4082-a09b-cada4ffcca4c",
"name": "Nota Adhesiva1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1808,
-48
],
"parameters": {
"width": 608,
"height": 288,
"content": "### Label the message with new and existing labels\n"
},
"typeVersion": 1
},
{
"id": "4091dfff-76e6-44a9-bdf4-f333d1b721e6",
"name": "Nota Adhesiva2",
"type": "n8n-nodes-base.stickyNote",
"position": [
2432,
240
],
"parameters": {
"color": 4,
"width": 608,
"height": 288,
"content": "### Rewrite and send message notification to discord\n"
},
"typeVersion": 1
},
{
"id": "25e5a3f4-b5bc-465a-9701-4fc4ee59c02d",
"name": "Nota Adhesiva3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1184,
240
],
"parameters": {
"color": 5,
"width": 608,
"height": 288,
"content": "### Create additional gmail labels if needed."
},
"typeVersion": 1
},
{
"id": "f7cb8412-72b5-4e34-8118-8c7b6a99d64a",
"name": "Nota Adhesiva",
"type": "n8n-nodes-base.stickyNote",
"position": [
-128,
240
],
"parameters": {
"color": 3,
"width": 608,
"height": 288,
"content": "### Find existing Gmail labels as options for LLM to choose from."
},
"typeVersion": 1
},
{
"id": "48d5b5a3-19b9-4b6f-8072-5cd4c51e9441",
"name": "Combinar etiquetas en lista (para selección de LLM)",
"type": "n8n-nodes-base.merge",
"position": [
368,
288
],
"parameters": {
"mode": "combineBySql",
"query": "SELECT * FROM input1 LEFT JOIN input2 ",
"options": {}
},
"typeVersion": 3.2
},
{
"id": "20de5d24-adc4-464c-94c5-8da4729e3682",
"name": "Nota Adhesiva4",
"type": "n8n-nodes-base.stickyNote",
"position": [
544,
-48
],
"parameters": {
"color": 6,
"width": 608,
"height": 288,
"content": "### LLM chooses labels or defines new ones\n"
},
"typeVersion": 1
},
{
"id": "4c12d9c2-2f47-4c1b-92b1-7164c038efe8",
"name": "Añadir old_labels []",
"type": "n8n-nodes-base.set",
"position": [
896,
32
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b4b52de9-a671-4d06-baaa-241f3ec4dea8",
"name": "output",
"type": "object",
"value": "={{ $json.output }}"
},
{
"id": "a27b466e-acad-4e8a-b69f-846d3220595f",
"name": "output.old_labels",
"type": "array",
"value": "[]"
},
{
"id": "25481eb7-7e0e-400b-b80a-f0b460e85c42",
"name": "output.added_label_names",
"type": "array",
"value": "[]"
}
]
},
"duplicateItem": true
},
"typeVersion": 3.4
}
],
"active": true,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1",
"saveExecutionProgress": true
},
"versionId": "df9e9f97-93f7-4e3e-9092-e85ffda7dcd6",
"connections": {
"c2beef7d-1352-40ac-868c-be730a463d69": {
"main": [
[
{
"node": "3ab1de7a-2dc1-4199-98f5-1e0e0cd8fcc3",
"type": "main",
"index": 0
},
{
"node": "758ce7fa-b66a-4018-b576-e754cff5e5f9",
"type": "main",
"index": 0
}
]
]
},
"dd821c19-35ed-4295-89d5-d3202ea7258a": {
"main": [
[
{
"node": "7514e196-94bf-462e-95c4-8698978e8b9e",
"type": "main",
"index": 0
}
]
]
},
"0652a435-b021-46bb-911e-8d66ad4ab262": {
"main": [
[
{
"node": "fb63935c-5a27-4e9e-96b8-5d73301890bf",
"type": "main",
"index": 0
}
]
]
},
"c8153181-5a9a-4ec7-a61b-f559d34e0d3f": {
"main": [
[
{
"node": "c2beef7d-1352-40ac-868c-be730a463d69",
"type": "main",
"index": 0
}
]
]
},
"758ce7fa-b66a-4018-b576-e754cff5e5f9": {
"main": [
[
{
"node": "19f5848c-d7e6-45c1-8ed9-c5a6aa6c9f5e",
"type": "main",
"index": 0
},
{
"node": "dd821c19-35ed-4295-89d5-d3202ea7258a",
"type": "main",
"index": 1
}
]
]
},
"3ab1de7a-2dc1-4199-98f5-1e0e0cd8fcc3": {
"main": [
[
{
"node": "99594eaa-8459-4cb9-905e-399549cb8b72",
"type": "main",
"index": 0
}
]
]
},
"fb63935c-5a27-4e9e-96b8-5d73301890bf": {
"main": [
[
{
"node": "48d5b5a3-19b9-4b6f-8072-5cd4c51e9441",
"type": "main",
"index": 1
}
]
]
},
"1173c4fc-0037-4c9f-81cc-0e52cd4caa2a": {
"main": [
[
{
"node": "758ce7fa-b66a-4018-b576-e754cff5e5f9",
"type": "main",
"index": 1
}
]
]
},
"19f5848c-d7e6-45c1-8ed9-c5a6aa6c9f5e": {
"main": [
[
{
"node": "7be3f984-3cf7-4868-8148-8e3a012028e3",
"type": "main",
"index": 0
}
]
]
},
"0216c4d9-041b-41d0-ae1d-6965399bfc61": {
"main": [
[
{
"node": "a537fe85-ff6b-44f6-8676-ec118a451f57",
"type": "main",
"index": 0
}
]
]
},
"99594eaa-8459-4cb9-905e-399549cb8b72": {
"main": [
[
{
"node": "1173c4fc-0037-4c9f-81cc-0e52cd4caa2a",
"type": "main",
"index": 0
}
]
]
},
"97c77c1d-0857-46cf-ba2a-4e38b0b48e4f": {
"main": [
[]
]
},
"9bf78ec9-a9a9-4db5-8cb0-4eb6cb6cf3b5": {
"main": [
[
{
"node": "4c12d9c2-2f47-4c1b-92b1-7164c038efe8",
"type": "main",
"index": 0
}
]
]
},
"4e637594-2570-471e-89a3-129c990c70f7": {
"main": [
[
{
"node": "0652a435-b021-46bb-911e-8d66ad4ab262",
"type": "main",
"index": 0
}
]
]
},
"a537fe85-ff6b-44f6-8676-ec118a451f57": {
"main": [
[],
[
{
"node": "4e637594-2570-471e-89a3-129c990c70f7",
"type": "main",
"index": 0
},
{
"node": "48d5b5a3-19b9-4b6f-8072-5cd4c51e9441",
"type": "main",
"index": 0
}
]
]
},
"7514e196-94bf-462e-95c4-8698978e8b9e": {
"main": [
[
{
"node": "97c77c1d-0857-46cf-ba2a-4e38b0b48e4f",
"type": "main",
"index": 0
}
]
]
},
"4c12d9c2-2f47-4c1b-92b1-7164c038efe8": {
"main": [
[
{
"node": "c8153181-5a9a-4ec7-a61b-f559d34e0d3f",
"type": "main",
"index": 0
}
]
]
},
"3a3c249c-b2a5-4b26-8565-345a78bbe347": {
"ai_languageModel": [
[]
]
},
"23a89c87-5b44-4a1d-8750-2b817984e33a": {
"ai_languageModel": [
[
{
"node": "9bf78ec9-a9a9-4db5-8cb0-4eb6cb6cf3b5",
"type": "ai_languageModel",
"index": 0
},
{
"node": "d8d3a318-0477-4e5d-8e1d-2d7ab073f217",
"type": "ai_languageModel",
"index": 0
},
{
"node": "7514e196-94bf-462e-95c4-8698978e8b9e",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"7be3f984-3cf7-4868-8148-8e3a012028e3": {
"main": [
[
{
"node": "dd821c19-35ed-4295-89d5-d3202ea7258a",
"type": "main",
"index": 0
}
]
]
},
"d8d3a318-0477-4e5d-8e1d-2d7ab073f217": {
"ai_outputParser": [
[
{
"node": "9bf78ec9-a9a9-4db5-8cb0-4eb6cb6cf3b5",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"48d5b5a3-19b9-4b6f-8072-5cd4c51e9441": {
"main": [
[
{
"node": "c8153181-5a9a-4ec7-a61b-f559d34e0d3f",
"type": "main",
"index": 1
},
{
"node": "9bf78ec9-a9a9-4db5-8cb0-4eb6cb6cf3b5",
"type": "main",
"index": 0
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Avanzado - Resumen de IA, IA Multimodal
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
Albert Ho
@codeandcodesCompartir este flujo de trabajo