AutomationFlowsEmail & Gmail › Gmail Email Classification to LINE & Sheets

Gmail Email Classification to LINE & Sheets

Original n8n title: Gmail分類poc ワークフロー

Gmail分類PoC ワークフロー. Uses gmailTrigger, httpRequest, line, googleSheets. Event-driven trigger; 8 nodes.

Event trigger★★★★☆ complexity8 nodesGmail TriggerHTTP RequestLineGoogle Sheets
Email & Gmail Trigger: Event Nodes: 8 Complexity: ★★★★☆ Added:

This workflow follows the Gmail Trigger → Google Sheets 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
{
  "name": "Gmail\u5206\u985ePoC \u30ef\u30fc\u30af\u30d5\u30ed\u30fc",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {},
        "options": {}
      },
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// HTML\u30bf\u30b0\u9664\u53bb\u3068\u30c6\u30ad\u30b9\u30c8\u6b63\u898f\u5316\nconst items = $input.all();\n\nreturn items.map(item => {\n  const data = item.json;\n  \n  // HTML\u30bf\u30b0\u9664\u53bb\n  const cleanBody = data.textPlain || data.textHtml?.replace(/<[^>]*>/g, '') || '';\n  \n  // \u57fa\u672c\u7684\u306a\u6b63\u898f\u5316\n  const normalizedBody = cleanBody\n    .replace(/\\r\\n/g, '\\n')\n    .replace(/\\n+/g, ' ')\n    .trim();\n  \n  return {\n    json: {\n      ...data,\n      subject: data.subject || '',\n      body: normalizedBody,\n      processedAt: new Date().toISOString()\n    }\n  };\n});"
      },
      "name": "Email Preprocessing",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://localhost:5000/api/enrich-context",
        "options": {
          "bodyContentType": "json",
          "headers": {
            "item": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ]
          }
        },
        "jsonParameters": true,
        "bodyParametersJson": "{\n  \"subject\": \"{{ $json.subject }}\",\n  \"body\": \"{{ $json.body }}\"\n}"
      },
      "name": "MCP Context Enricher",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://localhost:5000/api/classify",
        "options": {
          "bodyContentType": "json",
          "headers": {
            "item": [
              {
                "name": "Content-Type",
                "value": "application/json"
              }
            ]
          }
        },
        "jsonParameters": true,
        "bodyParametersJson": "{\n  \"subject\": \"{{ $json.subject }}\",\n  \"body\": \"{{ $json.body }}\"\n}"
      },
      "name": "AI Classification",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "{{ $json.classification }}",
              "operation": "equal",
              "value2": "\u91cd\u8981"
            }
          ]
        }
      },
      "name": "Switch\u5206\u985e",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        1120,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "// LINE\u901a\u77e5\u30e1\u30c3\u30bb\u30fc\u30b8\u4f5c\u6210\nconst items = $input.all();\n\nreturn items.map(item => {\n  const classification = $('AI Classification').item.json.classification;\n  const confidence = $('AI Classification').item.json.confidence;\n  const context = $('MCP Context Enricher').item.json.enriched_context;\n  const subject = item.json.subject;\n  \n  const message = `\ud83d\udea8 \u91cd\u8981\u30e1\u30fc\u30eb\u691c\u51fa\\n` +\n    `\u5206\u985e: ${classification}\\n` +\n    `\u4fe1\u983c\u5ea6: ${(confidence * 100).toFixed(1)}%\\n` +\n    `\u4ef6\u540d: ${subject}\\n` +\n    `\u6587\u8108: ${context}`;\n  \n  return {\n    json: {\n      message: message,\n      classification: classification\n    }\n  };\n});"
      },
      "name": "LINE Message Creation",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1340,
        200
      ]
    },
    {
      "parameters": {
        "messageType": "text",
        "text": "={{ $json.message }}",
        "additionalFields": {}
      },
      "name": "LINE\u901a\u77e5",
      "type": "n8n-nodes-base.line",
      "typeVersion": 1,
      "position": [
        1560,
        200
      ]
    },
    {
      "parameters": {
        "sheetId": "YOUR_SHEET_ID",
        "range": "A:F",
        "options": {
          "valueInputMode": "USER_ENTERED"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{ new Date().toISOString() }}",
            "subject": "={{ $json.subject }}",
            "classification": "={{ $('AI Classification').item.json.classification }}",
            "confidence": "={{ $('AI Classification').item.json.confidence }}",
            "context": "={{ $('MCP Context Enricher').item.json.enriched_context }}",
            "priority": "={{ $('MCP Context Enricher').item.json.priority_level }}"
          }
        }
      },
      "name": "Google Sheets\u30ed\u30b0\u4fdd\u5b58",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        1340,
        400
      ]
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Email Preprocessing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Preprocessing": {
      "main": [
        [
          {
            "node": "MCP Context Enricher",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MCP Context Enricher": {
      "main": [
        [
          {
            "node": "AI Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Classification": {
      "main": [
        [
          {
            "node": "Switch\u5206\u985e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch\u5206\u985e": {
      "main": [
        [
          {
            "node": "LINE Message Creation",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets\u30ed\u30b0\u4fdd\u5b58",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Sheets\u30ed\u30b0\u4fdd\u5b58",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "LINE Message Creation": {
      "main": [
        [
          {
            "node": "LINE\u901a\u77e5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": "gmail-classifier-workflow"
}
Pro

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

About this workflow

Gmail分類PoC ワークフロー. Uses gmailTrigger, httpRequest, line, googleSheets. Event-driven trigger; 8 nodes.

Source: https://github.com/deep-dev-yuya/gmail-classifier/blob/7b9f031bc8dd39f744e547863a4f05d470821e48/n8n/workflow_sample.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

📘 Description

HTTP Request, Gmail Trigger, ClickUp +3
Email & Gmail

This n8n workflow is designed for IT security professionals, email administrators, and organizations that want to automatically scan URLs received in emails for potential security threats. It provides

Gmail Trigger, HTTP Request, N8N Nodes Rapiwa +2
Email & Gmail

This workflow automatically detects duplicate invoices from Gmail. Incoming PDF attachments are scanned by the easybits AI Extractor, then checked against the Master Finance File in Google Sheets. Dup

Google Sheets, Gmail Trigger, HTTP Request +1
Email & Gmail

Receive any business document via email. The attachment is automatically classified (Invoice, Contract, or Purchase Order) using easybits Extractor, then routed down the correct path where a second Ex

@Easybits/N8N Nodes Extractor, Gmail Trigger, Google Drive +2
Email & Gmail

The goal is to reduce inbox noise and automatically organize repetitive types of emails so that imprtant messages remain visible while unsolicited or promotional emails are handled automatically. When

Gmail, Gmail Trigger, Google Sheets