GmailメールをAIで自動分類し、タグを適用してインボックスを整理

中級

これはOther, AI分野の自動化ワークフローで、8個のノードを含みます。主にCode, Gmail, Merge, Aggregate, GmailTriggerなどのノードを使用、AI技術を活用したスマート自動化を実現。 AIを使ってGmailのメールを自動分類し、タグを付けて受信トレーを整理

前提条件
  • Googleアカウント + Gmail API認証情報

カテゴリー

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "5a90cf25b26f3375705646dd979ac7968c2f7780e9cb14036112ef363426c72c",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "37166e51-ffb6-43fe-8bd5-fe5eb1249366",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        540,
        540
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash-preview-05-20",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "ogejgDjpnXZzGonu",
          "name": "OpenRouter account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "067f6b55-dc4c-4757-b19e-2d539b8b2526",
      "name": "Gmailメッセージの集約",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -360,
        220
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "7807ff72-49f7-4a7b-9d75-24746d0dfdb7",
      "name": "ラベルとメッセージの結合",
      "type": "n8n-nodes-base.merge",
      "position": [
        240,
        320
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.1
    },
    {
      "id": "8c51f04b-3415-4d53-8624-ce8d484145b9",
      "name": "AIによるメール分類",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        520,
        320
      ],
      "parameters": {
        "text": "=You are an email classification assistant. Your task is to analyze Gmail email snippets and categorize them into one of the following labels:\n\n1. To respond - Emails requiring a direct personal response from you (questions from individuals, personal conversations, NOT automated feedback requests)\n2. FYI - Emails requesting you to take action, reminders, or alerts about issues (add money requests, payment failures, action needed)\n3. Comment - Emails specifically asking for your feedback, review, or opinion in a professional/collaborative context\n4. Notification - Automated updates about completed or ongoing events (successful payments, transfers sent, deployments, shipments, security alerts)\n5. Meeting update - Calendar invites, meeting changes, or meeting-related communications\n6. Awaiting reply - Follow-up emails or reminders about your pending responses\n7. Actioned - Confirmations of actions YOU specifically took (not automated system actions)\n8. Marketing - Promotional content, sales emails, feature announcements, newsletters, or automated customer feedback surveys\n\nKey classification rules:\n- Automated status updates (deployments, transfers, payments processed) → Notification\n- Requests to add money or take action → FYI\n- Payment failure alerts → FYI\n- Security alert digests → Notification\n- Shipment updates → Notification\n- Direct Debit payment confirmations → Notification\n- Balance update confirmations → Notification\n- Customer satisfaction surveys or feedback requests → Marketing\n- Automated \"how was your experience\" emails → Marketing\n- Only use \"Actioned\" for confirmations of YOUR manual actions\n- Only use \"Marketing\" for promotional content, including feedback surveys\n\nInstructions:\n1. Read the email snippet carefully\n2. Note the sender (if provided) for context\n3. Choose the single most appropriate label based on the rules above\n4. IMPORTANT: Respond ONLY with the number and label (e.g., \"2. FYI\")\n5. Do not include any other text, explanation, or repeat the email content\n\nEmail From:\n{{ $json.From }}\nEmail To:\n{{ $json.To }}\nEmail subject:\n{{ $json.Subject }}\nEmail snippet:\n{{ $json.snippet }}\n\nYour response must be exactly one of these 8 options:\n1. To respond\n2. FYI\n3. Comment\n4. Notification\n5. Meeting update\n6. Awaiting reply\n7. Actioned\n8. Marketing",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "ddbdc31a-ea27-415e-b9e2-954959cfcb7a",
      "name": "新規Gmailメール受信",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -560,
        340
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "hour": 12
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "V5NiRamelad0WTXx",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "52b3a1d8-3be8-4f57-8759-7ae9abcdb5cb",
      "name": "利用可能なGmailラベルの取得",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -140,
        220
      ],
      "webhookId": "8574ca24-b439-4bc3-aa28-ae2b539a8d8e",
      "parameters": {
        "resource": "label",
        "returnAll": true
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "V5NiRamelad0WTXx",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "2d15670f-5735-4110-a1eb-d5b6b8abef89",
      "name": "ラベル名からIDへのマッピング",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        220
      ],
      "parameters": {
        "jsCode": "const items = $input.all();\nconst combinedObject = items.reduce((acc, item) => {\n  return { ...acc, [item.json.name]: item.json.id };\n}, {});\n\nreturn { combinedObject };\n"
      },
      "typeVersion": 2
    },
    {
      "id": "4c5d1e4a-93ce-4f78-b0ce-8b94aff99498",
      "name": "分類ラベルの適用",
      "type": "n8n-nodes-base.gmail",
      "position": [
        960,
        320
      ],
      "webhookId": "2ffe45e7-a0e3-4304-a6bf-e217c15ea6cc",
      "parameters": {
        "labelIds": "={{ $('Map Label Names to IDs').item.json.combinedObject[$json.text] }}",
        "messageId": "={{ $('Merge Labels & Messages').item.json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "V5NiRamelad0WTXx",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "pinData": {},
  "connections": {
    "37166e51-ffb6-43fe-8bd5-fe5eb1249366": {
      "ai_languageModel": [
        [
          {
            "node": "8c51f04b-3415-4d53-8624-ce8d484145b9",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "8c51f04b-3415-4d53-8624-ce8d484145b9": {
      "main": [
        [
          {
            "node": "4c5d1e4a-93ce-4f78-b0ce-8b94aff99498",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2d15670f-5735-4110-a1eb-d5b6b8abef89": {
      "main": [
        [
          {
            "node": "7807ff72-49f7-4a7b-9d75-24746d0dfdb7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7807ff72-49f7-4a7b-9d75-24746d0dfdb7": {
      "main": [
        [
          {
            "node": "8c51f04b-3415-4d53-8624-ce8d484145b9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "067f6b55-dc4c-4757-b19e-2d539b8b2526": {
      "main": [
        [
          {
            "node": "52b3a1d8-3be8-4f57-8759-7ae9abcdb5cb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ddbdc31a-ea27-415e-b9e2-954959cfcb7a": {
      "main": [
        [
          {
            "node": "067f6b55-dc4c-4757-b19e-2d539b8b2526",
            "type": "main",
            "index": 0
          },
          {
            "node": "7807ff72-49f7-4a7b-9d75-24746d0dfdb7",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "52b3a1d8-3be8-4f57-8759-7ae9abcdb5cb": {
      "main": [
        [
          {
            "node": "2d15670f-5735-4110-a1eb-d5b6b8abef89",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級 - その他, 人工知能

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
中級
ノード数8
カテゴリー2
ノードタイプ7
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

作成者
Alex Dunlop

Alex Dunlop

@alexdunlop

Kiwi Developer & Founder. Working on AI Startups while in London. Passionate about AI Tech, Learning, and Helping Engineers.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34