Clasificación y etiquetado automáticos de correos de Gmail basado en la clasificación con OpenAI GPT-4

Intermedio

Este es unAI Summarization, Multimodal AIflujo de automatización del dominio deautomatización que contiene 15 nodos.Utiliza principalmente nodos como Gmail, SplitInBatches, ScheduleTrigger, LmChatOpenAi, TextClassifier. Clasificación y etiquetado automáticos de correos de Gmail basados en la clasificación de OpenAI GPT-4

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Clave de API de OpenAI
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "434e0315-d478-4fc6-9d68-b6d83692d56d",
      "name": "Disparador Programado",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -220,
        -60
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9a3551be-1e97-4b1a-986e-55adb27ea660",
      "name": "Bucle sobre Elementos",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        220,
        -40
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "e44d7114-2e55-4bc3-82d6-b9fdf10651d8",
      "name": "Modelo 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": "Agregar Etiqueta (Alta Prioridad)",
      "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": "Agregar Etiqueta (Personal)",
      "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": "Agregar Etiqueta (Promociones)",
      "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": "Nota Adhesiva",
      "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": "Nota Adhesiva1",
      "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": "Nota Adhesiva2",
      "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": "Nota Adhesiva4",
      "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": "Nota Adhesiva5",
      "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": "Clasificador de Etiquetas",
      "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": "Nota Adhesiva6",
      "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 - Obtener Correos",
      "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
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿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?

Intermedio - 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.

Información del flujo de trabajo
Nivel de dificultad
Intermedio
Número de nodos15
Categoría2
Tipos de nodos6
Descripción de la dificultad

Adecuado para usuarios con experiencia intermedia, flujos de trabajo de complejidad media con 6-15 nodos

Autor
Billy Christi

Billy Christi

@billy

I build scalable automation systems with n8n to help businesses save time and cut costs. 💼 n8n expert available for new projects 📩 billychartanto@gmail.com

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34