Gmailスマート自動返信と分類システム

上級

これはTicket Management, AI Summarization分野の自動化ワークフローで、18個のノードを含みます。主にGmail, GmailTrigger, GoogleSheets, OpenAi, LmChatOpenAiなどのノードを使用。 Gmailメール分類と自動返信、GPT-4oとGoogle Sheetsを使用

前提条件
  • Googleアカウント + Gmail API認証情報
  • Google Sheets API認証情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "6MZqIrk7nB6lc4vB",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
    "templateCredsSetupCompleted": true
  },
  "name": "Gmail Auto Reply & Categorization with AI",
  "tags": [],
  "nodes": [
    {
      "id": "9f88a550-a517-4362-a71f-b7997b9c75fa",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -272,
        0
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "faf382e9-f898-447f-b5a1-d7a8c28d2309",
      "name": "テキスト分類器",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        -96,
        -32
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "High Priority",
              "description": "Description: Emails that require immediate attention and could have a serious impact if delayed. Typical examples include: system outages, security alerts, critical legal notices, or urgent requests from executives or key clients. Examples: '[URGENT] Service outage notice', '[IMPORTANT] Contract renewal deadline'"
            },
            {
              "category": "Advertisement",
              "description": "Description: Marketing or promotional emails that do not require an immediate response. Typical examples include: sales announcements, product launches, newsletters, and event invitations. Examples: '[LIMITED OFFER] 50% off campaign', 'New service release announcement'"
            },
            {
              "category": "Inquiry",
              "description": "Description: Customer or partner inquiries that require a reply or follow-up. Typical examples include: product or service questions, quote requests, reservations, troubleshooting, repair or refund requests. Examples: 'Inquiry about studio reservation', 'Request for quotation'"
            },
            {
              "category": "Finance/Billing",
              "description": "Description: Emails related to payments, invoices, or financial transactions. Typical examples include: invoices, receipts, payment confirmations, bank or accounting notifications, and tax-related documents. Examples: 'Invoice submission notice', '[Payment confirmed] Thank you for your payment'"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "aaddb0e0-fd5f-49ab-8887-f3ecc5bd9d89",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -96,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {
          "maxRetries": 1
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "WBKhlscRuBMQi56k",
          "name": "OpenAi account 4"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "52265538-92f0-45b9-a7e8-78ba934620cf",
      "name": "優先メールを保存",
      "type": "n8n-nodes-base.gmail",
      "position": [
        432,
        -240
      ],
      "webhookId": "18f19ef8-a4ec-4b1f-b3c6-4a9e7165eaff",
      "parameters": {
        "labelIds": [
          "Label_6395372519299544115"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a3ac1d27-05ca-4832-bee9-176899915b27",
      "name": "広告メールを保存",
      "type": "n8n-nodes-base.gmail",
      "position": [
        432,
        -48
      ],
      "webhookId": "18f19ef8-a4ec-4b1f-b3c6-4a9e7165eaff",
      "parameters": {
        "labelIds": [
          "Label_2877175876700118240"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "696b4433-3093-436c-b98d-2f910858823e",
      "name": "問い合わせメールを保存",
      "type": "n8n-nodes-base.gmail",
      "position": [
        432,
        144
      ],
      "webhookId": "18f19ef8-a4ec-4b1f-b3c6-4a9e7165eaff",
      "parameters": {
        "labelIds": [
          "Label_8971387974199578288"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "68f89db1-59b8-4b15-8ac6-52354a28093a",
      "name": "財務メールを保存",
      "type": "n8n-nodes-base.gmail",
      "position": [
        432,
        336
      ],
      "webhookId": "18f19ef8-a4ec-4b1f-b3c6-4a9e7165eaff",
      "parameters": {
        "labelIds": [
          "Label_7818902445747119871"
        ],
        "messageId": "={{ $json.id }}",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "cdb0c68f-e041-47ef-b65e-14e2c476a760",
      "name": "優先メールの下書き生成",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        640,
        -240
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an executive assistant.  \nYour task is to reply accurately to high-priority incoming emails.  \nHere is the email you need to respond to: {{ $('Gmail Trigger').item.json.text }}  \n\nPlease output the following parameters:\n- Subject  \n- Message\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "lHkSeZk3nuftEHri",
          "name": "デモ"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.8,
      "alwaysOutputData": false
    },
    {
      "id": "a59b0fc2-b11e-4e9c-a5c6-b5aa33f85bac",
      "name": "広告要約生成",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        640,
        -48
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a marketing specialist.  \nYour task is to summarize incoming promotional or marketing emails concisely in 1–2 lines for spreadsheet logging.  \n\nHere is the received email: {{ $('Gmail Trigger').item.json.text }}\n\nPlease extract and summarize the following fields:\n- Sender  \n- Subject  \n- Summary  \n- Recommendation\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "WBKhlscRuBMQi56k",
          "name": "OpenAi account 4"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.8,
      "alwaysOutputData": false
    },
    {
      "id": "64f4df61-ee88-4ea0-857f-7d738c2f3c21",
      "name": "財務要約生成",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        640,
        144
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a customer service representative.  \nYour task is to reply accurately to customer inquiries.  \nIf the question cannot be answered, instruct the sender to contact the following number: 000-0000-000.  \n\nHere is the email you need to respond to: {{ $('Gmail Trigger').item.json.text }}\n\nPlease output the following parameters:\n- Subject  \n- Message\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "WBKhlscRuBMQi56k",
          "name": "OpenAi account 4"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.8,
      "alwaysOutputData": false
    },
    {
      "id": "a8df46ff-73f7-4129-94cb-0f452b328716",
      "name": "問い合わせ返信生成",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        640,
        336
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "GPT-4O"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a finance and billing assistant.  \nYour task is to summarize emails related to invoices, payments, and financial notifications in a concise manner.  \n\nHere is the received email: {{ $('Gmail Trigger').item.json.text }}\n\nPlease output the following parameters:\n- Subject  \n- Message\n"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "id": "WBKhlscRuBMQi56k",
          "name": "OpenAi account 4"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.8,
      "alwaysOutputData": false
    },
    {
      "id": "ef15e762-463f-4acd-9c38-cb84735c9feb",
      "name": "下書き作成",
      "type": "n8n-nodes-base.gmail",
      "position": [
        992,
        -240
      ],
      "webhookId": "e203a0df-3a0f-48fc-9581-684beb49c073",
      "parameters": {
        "message": "={{ $json.message.content['message'] }}",
        "options": {},
        "subject": "={{ $json.message.content['send'] }}",
        "resource": "draft"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "45aa5109-f0c2-43e7-a91a-db0fcc109cc7",
      "name": "シートに行を追加",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        992,
        -48
      ],
      "parameters": {
        "columns": {
          "value": {
            "Sender": "={{ $json.message.content['Sender'] }}",
            "Subject": "={{ $json.message.content['Subject'] }}",
            "Summary": "={{ $json.message.content['Summary'] }}",
            "Recommendation": "={{ $json.message.content['Recommendation'] }}"
          },
          "schema": [
            {
              "id": "Sender",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Sender",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Subject",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Summary",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Recommendation",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Recommendation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13AmknC94wJ5n1FDl7E1yUFsCNYVDJklzPpTZmFQrMb4/edit#gid=0",
          "cachedResultName": "01_Advertisement Mail Summary"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "13AmknC94wJ5n1FDl7E1yUFsCNYVDJklzPpTZmFQrMb4",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/13AmknC94wJ5n1FDl7E1yUFsCNYVDJklzPpTZmFQrMb4/edit?usp=drivesdk",
          "cachedResultName": "[n8n] Advertisement Mail Summary"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "Ja0tGvoFNudNwqMM",
          "name": "md83 H2"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "6701a84f-2e2a-42f2-9c98-fb7ee3f394f1",
      "name": "財務メール送信",
      "type": "n8n-nodes-base.gmail",
      "position": [
        992,
        144
      ],
      "webhookId": "0256a9d5-e87f-499e-98c4-ced9e9b6f204",
      "parameters": {
        "message": "={{ $json.message.content['message'] }}",
        "options": {},
        "resource": "thread",
        "threadId": "={{ $('Save Inquiry Mail').item.json.threadId }}",
        "messageId": "={{ $('Save Inquiry Mail').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "89129a16-1f1a-48e4-82f1-0593c142909b",
      "name": "問い合わせに返信",
      "type": "n8n-nodes-base.gmail",
      "position": [
        992,
        336
      ],
      "webhookId": "01d72fbe-d12c-4992-9977-7aa4316e0af0",
      "parameters": {
        "sendTo": "{{YOUR_EMAIL_ADDRESS}}",
        "message": "={{ $json.message.content['message'] }}",
        "options": {},
        "subject": "={{ $json.message.content['send'] }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "NdoEDipkhQPaRDuy",
          "name": "Gmail account 6"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "6f1a41f5-ad3e-4b4b-906d-44a20bbe0623",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        -304
      ],
      "parameters": {
        "width": 416,
        "height": 880,
        "content": "## 📩Gmail Auto Reply & Categorization with AI (LangChain + OpenAI + Google Sheets)\n\n**Description:**\nThis workflow automatically categorizes incoming Gmail messages into four types — High Priority, Advertisement, Inquiry, and Finance/Billing — using the LangChain Text Classifier.\nEach category triggers a specific automated action powered by OpenAI GPT models:\n\n🟥 High Priority: Generates an AI-written draft reply in Gmail.\n\n🟨 Advertisement: Summarizes the content and logs it to Google Sheets.\n\n🟩 Inquiry: Creates an auto-reply email with fallback instructions.\n\n🟦 Finance/Billing: Generates a brief summary and forwards it to a designated address.\n\nThis setup combines Gmail + LangChain + OpenAI + Google Sheets for a complete AI-driven email management system that reduces manual sorting and response time.\n\n**Setup Instructions:**\n\nConnect your credentials for Gmail, Google Sheets, and OpenAI.\n\nReplace all placeholders such as {{YOUR_EMAIL_ADDRESS}}, {{YOUR_SPREADSHEET_ID}}, and label names with your actual values.\n\nMake sure you have Gmail labels created for “Advertisement,” “Inquiry,” etc.\n\n(Optional) Translate prompts back to your language if needed.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "49d044e4-0a1c-4fff-b205-77d43db01251",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -336,
        -176
      ],
      "parameters": {
        "color": 2,
        "width": 512,
        "height": 496,
        "content": "## ①Receive Gmail → AI understands the email content\nIncoming emails are analyzed by AI and automatically categorized into four sections: High Priority, Advertisement, Inquiry, and Finance/Billing."
      },
      "typeVersion": 1
    },
    {
      "id": "904ff69b-74bc-4c26-aa3d-5af797548e7e",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -624
      ],
      "parameters": {
        "width": 960,
        "height": 1200,
        "content": "## ②Email Processing Section\n**Flow Overview:**\nThis workflow automatically classifies all incoming Gmail messages into four categories using the LangChain Text Classifier and performs specific actions for each:\n\n🟥 High Priority: Gmail adds a “High Priority” label → OpenAI generates a reply draft → saved as a Gmail draft.\n\n🟨 Advertisement: AI summarizes the email → summary is recorded into a Google Sheet for later review.\n\n🟩 Inquiry: AI generates an automatic customer reply → sends a polite response or fallback message.\n\n🟦 Finance/Billing: AI creates a short summary of financial or billing-related content → forwards it to a designated email address.\n\n**Purpose:**\nThe system ensures that each type of incoming email is handled automatically and intelligently: urgent messages are drafted quickly, promotional content is logged, customer inquiries are answered promptly, and financial communications are safely redirected — all through a single AI-powered workflow."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "fa5d38ad-f0cb-4b9a-962d-295da7453ed7",
  "connections": {
    "9f88a550-a517-4362-a71f-b7997b9c75fa": {
      "main": [
        [
          {
            "node": "faf382e9-f898-447f-b5a1-d7a8c28d2309",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "faf382e9-f898-447f-b5a1-d7a8c28d2309": {
      "main": [
        [
          {
            "node": "52265538-92f0-45b9-a7e8-78ba934620cf",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a3ac1d27-05ca-4832-bee9-176899915b27",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "696b4433-3093-436c-b98d-2f910858823e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "68f89db1-59b8-4b15-8ac6-52354a28093a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "aaddb0e0-fd5f-49ab-8887-f3ecc5bd9d89": {
      "ai_languageModel": [
        [
          {
            "node": "faf382e9-f898-447f-b5a1-d7a8c28d2309",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "68f89db1-59b8-4b15-8ac6-52354a28093a": {
      "main": [
        [
          {
            "node": "a8df46ff-73f7-4129-94cb-0f452b328716",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "696b4433-3093-436c-b98d-2f910858823e": {
      "main": [
        [
          {
            "node": "64f4df61-ee88-4ea0-857f-7d738c2f3c21",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "52265538-92f0-45b9-a7e8-78ba934620cf": {
      "main": [
        [
          {
            "node": "cdb0c68f-e041-47ef-b65e-14e2c476a760",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a59b0fc2-b11e-4e9c-a5c6-b5aa33f85bac": {
      "main": [
        [
          {
            "node": "45aa5109-f0c2-43e7-a91a-db0fcc109cc7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a8df46ff-73f7-4129-94cb-0f452b328716": {
      "main": [
        [
          {
            "node": "89129a16-1f1a-48e4-82f1-0593c142909b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cdb0c68f-e041-47ef-b65e-14e2c476a760": {
      "main": [
        [
          {
            "node": "ef15e762-463f-4acd-9c38-cb84735c9feb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a3ac1d27-05ca-4832-bee9-176899915b27": {
      "main": [
        [
          {
            "node": "a59b0fc2-b11e-4e9c-a5c6-b5aa33f85bac",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "64f4df61-ee88-4ea0-857f-7d738c2f3c21": {
      "main": [
        [
          {
            "node": "6701a84f-2e2a-42f2-9c98-fb7ee3f394f1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - チケット管理, AI要約

有料ですか?

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

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

上級者向け、16ノード以上の複雑なワークフロー

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34