AutomationFlowsEmail & Gmail › Gmail Auto-Label Messages Workflow

Gmail Auto-Label Messages Workflow

Original n8n title: Gmailtrigger Workflow

Gmailtrigger Workflow. Uses gmailTrigger, gmail, splitOut, noOp. Event-driven trigger; 20 nodes.

Event trigger★★★★☆ complexity20 nodesGmail TriggerGmailStop And Error
Email & Gmail Trigger: Event Nodes: 20 Complexity: ★★★★☆ Added:
Gmail Auto-Label Messages Workflow — n8n workflow card showing Gmail Trigger, Gmail, Stop And Error integration

This workflow follows the Gmail → Gmail Trigger 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 →

Download .json
{
  "meta": {
    "versionId": "1.0.0",
    "createdAt": "2025-09-29T07:07:52.746687",
    "updatedAt": "2025-09-29T07:07:52.746706",
    "owner": "n8n-user",
    "license": "MIT",
    "category": "automation",
    "status": "active",
    "priority": "high",
    "environment": "production"
  },
  "nodes": [
    {
      "id": "3102dc76-7123-4e87-b30f-e15c240e77da",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1,
      "notes": "This gmailTrigger node performs automated tasks as part of the workflow."
    },
    {
      "id": "1e4a55e5-289e-4d67-a161-9109bd430e75",
      "name": "Only n8n Paddle invoice mails",
      "type": "n8n-nodes-base.if",
      "position": [
        420,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "229200d1-ec13-4970-ae0e-2c8e17da0bdf",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.from.value[0].address }}",
              "rightValue": "you@example.com"
            },
            {
              "id": "1830d49a-5ee0-472c-bb9d-0090c0e1f5a4",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Your invoice"
            }
          ]
        }
      },
      "typeVersion": 2.1,
      "notes": "This if node performs automated tasks as part of the workflow."
    },
    {
      "id": "a87ed337-a582-44ed-9185-ea0dd9486245",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        820,
        -120
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "link"
      },
      "typeVersion": 1,
      "notes": "This splitOut node performs automated tasks as part of the workflow."
    },
    {
      "id": "3a4dd56b-3177-4364-ac48-ce9e475b773f",
      "name": "Only keep invoice link",
      "type": "n8n-nodes-base.filter",
      "position": [
        1000,
        -120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "d8a78835-46bd-40c0-b9ef-c1a631ab0a00",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.link }}",
              "rightValue": "/receipt/"
            }
          ]
        }
      },
      "typeVersion": 2.1,
      "notes": "This filter node performs automated tasks as part of the workflow."
    },
    {
      "id": "2da9e7c0-8954-442a-a33c-a942cd634b27",
      "name": "Do nothing on other emails",
      "type": "n8n-nodes-base.noOp",
      "position": [
        640,
        80
      ],
      "parameters": {},
      "typeVersion": 1,
      "notes": "This noOp node performs automated tasks as part of the workflow."
    },
    {
      "id": "dd837661-97af-4abc-8b44-a10931cda54c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -280
      ],
      "parameters": {
        "height": 440,
        "content": "## Setup\n1. Setup your **Gmail** and **Google Drive** credentials\n1. Create a free account at {{ $env.WEBHOOK_URL }}\n2. Insert your **pdflayer** API key into the `Setup` node\n3. Insert the URL to the wanted drive folder into the setup node (make sure to remove everything after the `?`)"
      },
      "typeVersion": 1,
      "notes": "This stickyNote node performs automated tasks as part of the workflow."
    },
    {
      "id": "8de9b630-0a5f-4d2c-ac7f-e3264314a97c",
      "name": "Setup",
      "type": "n8n-nodes-base.set",
      "position": [
        220,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "86a22cf3-262a-4089-88ab-fafc01307bb4",
              "name": "api_key",
              "type": "string",
              "value": "{{ your_key_here }}"
            },
            {
              "id": "4cca07a2-6a70-4011-a025-65246e652fb9",
              "name": "url_to_drive_folder",
              "type": "string",
              "value": "{{ folder_URL }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4,
      "notes": "This set node performs automated tasks as part of the workflow."
    },
    {
      "id": "b06860a4-3895-4a28-9365-71c31f220d10",
      "name": "Download Invoice PDF from URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1200,
        -120
      ],
      "parameters": {
        "url": "{{ $env.API_BASE_URL }}",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "access_key",
              "value": "={{ $('Setup').first().json.api_key }}"
            },
            {
              "name": "document_url",
              "value": "={{ $json.link }}"
            },
            {
              "name": "page_size",
              "value": "A4"
            }
          ]
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true,
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "id": "c2be351e-76ce-4bfa-8965-e41d59a6c49a",
      "name": "Rename file",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1580,
        -120
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "update",
        "newUpdatedFileName": "=n8n_cloud_invoice_{{ $now.format('yyyy-MM-dd') }}.pdf"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3,
      "notes": "This googleDrive node performs automated tasks as part of the workflow."
    },
    {
      "id": "20b90e38-dd17-462c-8007-e83dcc2dc8df",
      "name": "Move to the correct folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1760,
        -120
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $('Setup').item.json.url_to_drive_folder }}"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3,
      "notes": "This googleDrive node performs automated tasks as part of the workflow."
    },
    {
      "id": "5c2930eb-90f8-4f4f-ae6a-638a01faccd3",
      "name": "Upload PDF to Drive",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1400,
        -120
      ],
      "parameters": {
        "url": "{{ $env.API_BASE_URL }}",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendQuery": true,
        "contentType": "binaryData",
        "authentication": "{{ $credentials.predefinedCredentialType }}",
        "queryParameters": {
          "parameters": [
            {
              "name": "uploadType",
              "value": "media"
            }
          ]
        },
        "inputDataFieldName": "data",
        "nodeCredentialType": "YOUR_CREDENTIAL_HERE"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2,
      "notes": "This httpRequest node performs automated tasks as part of the workflow."
    },
    {
      "id": "1806abe4-d80e-4ab8-8303-6b92d569aac5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1353.6776457357505,
        -255.65646735405625
      ],
      "parameters": {
        "color": 7,
        "width": 608.5129596994967,
        "height": 306.2353014680544,
        "content": "## Adjust me\nYou can adjust this part and save the file wherever you want. E.g. you could save it in your local file system by using the `Read/Write Files from Disk` node or save it in Dropbox by using the `Dropbox` node. You could even email the PDF to the right person instead."
      },
      "typeVersion": 1,
      "notes": "This stickyNote node performs automated tasks as part of the workflow."
    },
    {
      "id": "efa55724-3b42-4abd-a30a-ad7e9836ede5",
      "name": "Extract \"a-tags\" from email",
      "type": "n8n-nodes-base.html",
      "position": [
        640,
        -120
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "dataPropertyName": "html",
        "extractionValues": {
          "values": [
            {
              "key": "YOUR_CREDENTIAL_HERE",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2,
      "notes": "This html node performs automated tasks as part of the workflow."
    }
  ],
  "connections": {
    "Download Invoice PDF from URL": {
      "main": [
        [],
        [],
        [],
        [],
        [],
        [],
        [],
        [],
        []
      ]
    },
    "Upload PDF to Drive": {
      "main": [
        [],
        [],
        [],
        [],
        [],
        [],
        [],
        [],
        []
      ]
    },
    "Rename file": {
      "main": [
        []
      ]
    },
    "Move to the correct folder": {
      "main": [
        []
      ]
    }
  },
  "name": "Gmailtrigger Workflow",
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": null,
    "timezone": "UTC",
    "executionTimeout": 3600,
    "maxExecutions": 1000,
    "retryOnFail": true,
    "retryCount": 3,
    "retryDelay": 1000
  },
  "description": "Automated workflow: Gmailtrigger Workflow. This workflow integrates 11 different services: filter, stickyNote, httpRequest, gmailTrigger, splitOut. It contains 19 nodes and follows best practices for error handling and security.",
  "notes": "Excellent quality workflow: Gmailtrigger Workflow. This workflow has been optimized for production use with comprehensive error handling, security, and documentation.",
  "id": "wfe594e95eca43"
}

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.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

How this works

Effortlessly manage incoming emails by automatically applying custom labels based on their content, saving hours of manual sorting and ensuring important messages are always organised and easy to find. This workflow suits busy professionals or teams handling high email volumes, such as customer support or project managers, who rely on Gmail for communication. The key step involves the Gmail trigger detecting new emails, followed by nodes that analyse content, split out existing labels, and apply the most relevant ones using the Gmail integration.

Use this workflow when you need rule-based labelling for consistent email organisation without constant oversight, particularly for recurring patterns like client queries or urgent alerts. Avoid it for highly complex categorisation requiring AI analysis, as it relies on predefined rules; instead, opt for simpler setups if your needs are basic. Common variations include adding filters for specific senders or integrating with tools like Google Sheets to log labelled emails for reporting.

About this workflow

Gmailtrigger Workflow. Uses gmailTrigger, gmail, splitOut, noOp. Event-driven trigger; 20 nodes.

Source: https://github.com/Zie619/n8n-workflows/blob/main/workflows/Aggregate/1324_Aggregate_Gmail_Send_Triggered.json — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

Stickynote Workflow. Uses stickyNote, gmailTrigger, gmail, noOp. Event-driven trigger; 20 nodes.

Gmail Trigger, Gmail, Stop And Error
Email & Gmail

Unsubscribe Mautic contacts from automated unsubscribe emails. Uses gmailTrigger, mautic, gmail, stopAndError. Event-driven trigger; 17 nodes.

Gmail Trigger, Mautic, Gmail +1
Email & Gmail

Splitinbatches Workflow. Uses gmail, gmailTrigger, slack, stopAndError. Event-driven trigger; 7 nodes.

Gmail, Gmail Trigger, Slack +1
Email & Gmail

Splitinbatches Workflow. Uses gmail, gmailTrigger, slack, stopAndError. Event-driven trigger; 7 nodes.

Gmail, Gmail Trigger, Slack +1
Email & Gmail

email. Uses gmailTrigger, gmail, ftp, mattermost. Event-driven trigger; 81 nodes.

Gmail Trigger, Gmail, Ftp +1