Plantilla: Procesar archivos adjuntos en Gmail

Avanzado

Este es unFile Managementflujo de automatización del dominio deautomatización que contiene 22 nodos.Utiliza principalmente nodos como Gmail, Slack, Filter, Switch, SplitOut. Administrador de archivos adjuntos de Gmail con carga a Google Drive y filtrado inteligente

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Bot Token de Slack o URL de Webhook
  • Credenciales de API de Google Drive
  • Pueden requerirse credenciales de autenticación para la API de destino
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
{
  "id": "Z3wOGZdXKSlSWzgO",
  "meta": {
    "instanceId": "5b61629a145a38a93588ff78addb36f97647fd75c5392fcb856e858941f87d19",
    "templateCredsSetupCompleted": true
  },
  "name": "TEMPLATE Process attached files in Gmail",
  "tags": [],
  "nodes": [
    {
      "id": "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364",
      "name": "Marcar como leído y archivar correo",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -80,
        -80
      ],
      "webhookId": "0dd820ff-1f3e-4e9e-9fb8-922f59eabf8c",
      "parameters": {
        "labelIds": [
          "UNREAD",
          "INBOX"
        ],
        "messageId": "={{ $('Filter based on sender or receiver').item.json.id }}",
        "operation": "removeLabels"
      },
      "credentials": {},
      "typeVersion": 2.1
    },
    {
      "id": "1327a765-2c40-40ef-929f-dfb0790cf048",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -560
      ],
      "parameters": {
        "color": 5,
        "width": 1344,
        "height": 432,
        "content": "## Information\nTemplate created by Smultron Studio (https://smultronstudio.com/en) - feel free to reach out at hello@smultronstudio.com\n\n### Instructions (numbers refer to red cards):\n1. Configure credentials\n2. Configure credentials\n3. If you have one or many specific senders for the emails to be processed in this workflow, specify here\n4. If you want a filter on which file types to process, specify here\n5. If you want to process multiple file types and need separate paths, build that here\n6. Configure where to post or upload the files\n7. Configure credentials and customize Slack message\n\n#### Modifications:\nThis template is a skeleton to customize for your use case. It sorts out the n8n specific references and logic to process the files fetched from an email in Gmail.\n\n#### List of mimeTypes for filtering:\nhttps://docs.cloud.google.com/appengine/docs/legacy/standard/php/mail/mail-with-headers-attachments"
      },
      "typeVersion": 1
    },
    {
      "id": "f50f6e40-1b10-48da-9440-1cffe6f6d323",
      "name": "Enviar un mensaje",
      "type": "n8n-nodes-base.slack",
      "position": [
        592,
        -336
      ],
      "webhookId": "92ba6b9b-92d1-47a8-bf51-103a5598212d",
      "parameters": {
        "text": "=Did something with {{$('Loop attachments').all().length}} files received from {{ $('Trigger on incoming email with attachment').item.json.from.value[0].address }}",
        "otherOptions": {}
      },
      "typeVersion": 2.3
    },
    {
      "id": "5c972c0f-dc9f-4056-a4b5-99bd62ea1a83",
      "name": "Activar al recibir correo con adjunto",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -864,
        80
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": "has:attachment -label:DRAFT"
        },
        "options": {
          "downloadAttachments": true
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {},
      "typeVersion": 1.3
    },
    {
      "id": "d4504562-3549-4d70-8b60-37e8c027adc7",
      "name": "Filtrar según tipo de archivo",
      "type": "n8n-nodes-base.filter",
      "position": [
        144,
        144
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "5b96c7b7-5896-4e65-89e2-69e679346f42",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": "application/zip"
            },
            {
              "id": "ac183995-c533-4698-a2e7-8601f7420c79",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": "text/plain"
            },
            {
              "id": "0a949152-7478-4b66-a2c2-e52798627eba",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $binary.values()[0].mimeType }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2,
      "alwaysOutputData": true
    },
    {
      "id": "75ebfebd-0d76-45e1-b722-6ebcc159460d",
      "name": "Tratar diferentes tipos de archivo de forma distinta",
      "type": "n8n-nodes-base.switch",
      "position": [
        368,
        128
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "zip",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "48e9243a-8e5b-4f5d-90e7-4c78b0580a76",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $binary.values()[0].mimeType }}",
                    "rightValue": "application/zip"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "no file",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c9b50caa-7335-469f-a863-e24836c1ca79",
                    "operator": {
                      "type": "object",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $input.first().json }}",
                    "rightValue": "0"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.3
    },
    {
      "id": "e653ee4e-cf13-4d51-b43b-79920f5add10",
      "name": "Descomprimir zip",
      "type": "n8n-nodes-base.compression",
      "position": [
        528,
        48
      ],
      "parameters": {
        "outputPrefix": "=file_",
        "binaryPropertyName": "={{ Object.keys($binary)[0] }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "faf61d9d-2e43-4c6c-b23c-08c85042e1fe",
      "name": "Publicar archivo en webhook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1056,
        272
      ],
      "parameters": {
        "url": "https://n8n.com:8443/webhook/[unique-id]",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}"
      },
      "typeVersion": 4.2
    },
    {
      "id": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
      "name": "Bucle de adjuntos",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -272,
        80
      ],
      "parameters": {
        "options": {
          "reset": false
        }
      },
      "typeVersion": 3
    },
    {
      "id": "febc18da-137c-4759-b21d-ec1910778a98",
      "name": "Nota adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -928,
        -112
      ],
      "parameters": {
        "color": 6,
        "width": 1904,
        "height": 560,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "9ebd9a7e-bc46-4d8c-81b9-c621394683a0",
      "name": "Nota adhesiva2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        432,
        -560
      ],
      "parameters": {
        "width": 544,
        "height": 432,
        "content": "## Notification out\nNotify in Slack that files has been processed"
      },
      "typeVersion": 1
    },
    {
      "id": "512d195b-ffab-42db-9c60-dd9f60cde8fe",
      "name": "Nota adhesiva3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 448,
        "content": "## 6. Upload file somewhere\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nConfigure or replace this node with some other destination for your files."
      },
      "typeVersion": 1
    },
    {
      "id": "44de5019-f2fd-4c87-bc91-a3c789b18ae5",
      "name": "Nota adhesiva4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        16
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 496,
        "content": "## 4. Filter based on file type\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect one or more file types, you can specify that here. \n\nOr if you only want to process a specific file type in emails with multiple attachments."
      },
      "typeVersion": 1
    },
    {
      "id": "3260063c-d547-418e-af65-2de4f80eaf35",
      "name": "Nota adhesiva5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 368,
        "height": 512,
        "content": "## 5. Treat different file types separate\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nIf you expect multiple file types that requires different processing, build those paths here (like decompressing zip files). \n\nIf you filter to only process one specific file type or will process all files the same then you can remove this part. "
      },
      "typeVersion": 1
    },
    {
      "id": "79a0bfcf-c12a-4c78-af7a-7174a9f6c8e0",
      "name": "Nota adhesiva6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -912,
        -16
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 272,
        "content": "## 1. Trigger\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "f25b842d-2324-42f2-9f4a-847098d2669f",
      "name": "Nota adhesiva7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -176
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 288,
        "content": "## 2. Archive\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "367f6c68-5b16-4062-8be8-8a5094b24c0a",
      "name": "Nota adhesiva8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -704,
        -16
      ],
      "parameters": {
        "color": 3,
        "width": 208,
        "height": 272,
        "content": "## 3. Filter sender/receiver\n"
      },
      "typeVersion": 1
    },
    {
      "id": "16094578-c919-4cd3-8a6b-4bf730426f11",
      "name": "Nota adhesiva9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -448
      ],
      "parameters": {
        "color": 3,
        "height": 288,
        "content": "## 7. Slack notification\nConfigure your credentials here"
      },
      "typeVersion": 1
    },
    {
      "id": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
      "name": "Cargar archivo a Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        768,
        160
      ],
      "parameters": {
        "name": "={{ $binary.values()[0].fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "inputDataFieldName": "={{ Object.keys($binary)[0] }}"
      },
      "credentials": {},
      "typeVersion": 3
    },
    {
      "id": "44a5eaa9-181c-4871-9a66-00927e293dd0",
      "name": "Nota adhesiva10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        176
      ],
      "parameters": {
        "color": 3,
        "width": 256,
        "height": 272,
        "content": "## 8. Example\nThis is a webhook example to replace the Google Drive node (6)"
      },
      "typeVersion": 1
    },
    {
      "id": "95604855-1bf5-485c-bd31-65b4352b6cec",
      "name": "Filtrar según remitente o destinatario",
      "type": "n8n-nodes-base.filter",
      "position": [
        -656,
        80
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "dab0779d-b14a-481c-80d6-33c356009ef5",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.from.value[0].address }}",
              "rightValue": "sender@domain.tld"
            },
            {
              "id": "09479cf5-3c9a-4dab-a987-016462db5470",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.to.value[0].address }}",
              "rightValue": "recipient@domain.tld"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7",
      "name": "Dividir salida",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -448,
        80
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "$binary"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8fd24c8f-f0fe-48e5-bf27-da6a79d17f5e",
  "connections": {
    "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7": {
      "main": [
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e653ee4e-cf13-4d51-b43b-79920f5add10": {
      "main": [
        [
          {
            "node": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f50f6e40-1b10-48da-9440-1cffe6f6d323": {
      "main": [
        []
      ]
    },
    "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72": {
      "main": [
        [
          {
            "node": "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d4504562-3549-4d70-8b60-37e8c027adc7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "faf61d9d-2e43-4c6c-b23c-08c85042e1fe": {
      "main": [
        []
      ]
    },
    "d4504562-3549-4d70-8b60-37e8c027adc7": {
      "main": [
        [
          {
            "node": "75ebfebd-0d76-45e1-b722-6ebcc159460d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fc56a7c7-e89d-46f6-88d1-a6b4c8ce7364": {
      "main": [
        [
          {
            "node": "f50f6e40-1b10-48da-9440-1cffe6f6d323",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "35253661-cf9c-414d-a0ad-b9f4bf9fa83a": {
      "main": [
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "95604855-1bf5-485c-bd31-65b4352b6cec": {
      "main": [
        [
          {
            "node": "87a1ecf3-63d8-4bb4-9426-f4c9afbc40e7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "75ebfebd-0d76-45e1-b722-6ebcc159460d": {
      "main": [
        [
          {
            "node": "e653ee4e-cf13-4d51-b43b-79920f5add10",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "f96f3ca8-fa1a-4f0c-b0a3-e7b6d9527a72",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "35253661-cf9c-414d-a0ad-b9f4bf9fa83a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5c972c0f-dc9f-4056-a4b5-99bd62ea1a83": {
      "main": [
        [
          {
            "node": "95604855-1bf5-485c-bd31-65b4352b6cec",
            "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?

Avanzado - Gestión de archivos

¿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
Avanzado
Número de nodos22
Categoría1
Tipos de nodos11
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
Ossian Madisson

Ossian Madisson

@ossian

AI & Automation consultant with many years of experience from both devops and business management. A solid combination to really understand where technology can create real business value. My focus is to help businesses in Sweden work smarter and achieve more by applying technology in a useful and responsible way. Feel free to contact me at ossian@smultronstudio.com or schedule a short call at https://smultronstudio.com

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34