2番目のGmail下書きと送信

上級

これはTicket Management, Multimodal AI分野の自動化ワークフローで、18個のノードを含みます。主にGmail, Switch, GmailTrigger, Agent, LmChatGoogleGeminiなどのノードを使用。 Gemini AI と Gmail を使ったインタラクティブなメール返信の自動化管理

前提条件
  • Googleアカウント + Gmail API認証情報
  • Google Gemini API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "yAmWWzUXTwmC6hPO",
  "meta": {
    "instanceId": "679a5e6996c7b87733ea9da67669642511fe2f1215d268a884919abfbd13ffdb",
    "templateCredsSetupCompleted": true
  },
  "name": "2nd gmail draft and send",
  "tags": [],
  "nodes": [
    {
      "id": "04005997-5f22-40f8-b1c5-8791b106d277",
      "name": "人間によるレビューフラグ",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -48,
        480
      ],
      "webhookId": "f391c634-6d29-44eb-b122-e40c93df2cd0",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {
          "sendTo": "={{ $('Get a message').item.json.from.value[0].address }}",
          "threadId": "={{ $('Get a message').item.json.threadId }}"
        },
        "subject": "={{ $('Get a message').item.json.subject }}",
        "resource": "draft"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PuAE61pOClI4CRxE",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "57d5d8fd-3391-4af0-9305-2249d4885f5f",
      "name": "Gmail トリガー",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1648,
        240
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PuAE61pOClI4CRxE",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "55ee3c91-fa91-44eb-ad28-87c2a614f2a1",
      "name": "Google Gemini チャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -1168,
        416
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "7X1ZyvDFg4ocTHrj",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "af2b05c9-5229-4027-a514-0d210ea26fe7",
      "name": "AIカテゴライザー",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1168,
        240
      ],
      "parameters": {
        "text": "=You are an AI assistant that drafts helpful email replies. For each incoming email, you will draft a reply and classify whether the email is 'simple' (can be auto-replied) or 'complex' (requires human review) or needs nothing to do.\n\nRules for classification:\n\n\nIf the email contains any sensitive topic (e.g: personal data such as biometric data, health records, racial or ethnic origin, religious or philosophical beliefs, political opinions, and sexual orientation, financial data (account numbers, credit card information), government identifiers (Social Security Numbers), and company-specific data such as trade secrets and strategic plans, etc.). classify it as \"draft\".\n\nAnd if the email does not contain any of the sensitive information and is a normal email and needs a reply, classify it as \"Reply\".\n\nAnd if an email does not contain any of the topic or information that does need reply (e.g, marketing or spam, automated notifications like \"do not reply\" emails or pickup alerts, transactional messages such as purchase receipts or account verification, and emails with no clear call to action that could bury important messages for recipients. In general, if a message is purely informational, doesn't ask for action, or is from an unknown source.) Classify it as \"Nothing\".\n\nProvide the Category Only: Respond with the category name and nothing else. Do not add any extra text, explanations, or commentary. Your response should be a single word. and you have 3 categories: \n\n1. Draft\n2. Reply\n3. Nothing\n\nHere is the Email:\n\n{{ $json.text }}",
        "options": {
          "batching": {
            "batchSize": 1,
            "delayBetweenBatches": 0
          },
          "passthroughBinaryImages": true,
          "returnIntermediateSteps": false
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "9a53a9bf-9665-4f5c-a0b9-74f5421509f5",
      "name": "Gemini チャット下書き",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -384,
        640
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "7X1ZyvDFg4ocTHrj",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "75bda556-8de8-462d-8ca6-a3fc30ca3436",
      "name": "Gemini チャット返信",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -384,
        192
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-preview-05-20"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "7X1ZyvDFg4ocTHrj",
          "name": "Google Gemini(PaLM) Api account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5396f107-619c-426d-b759-ebece261871f",
      "name": "操作なし(何もしない)",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -688,
        560
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "dd50a20e-869e-4e9e-9c07-820be5fa9f95",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1712,
        48
      ],
      "parameters": {
        "width": 448,
        "height": 400,
        "content": "## Gmail Trigger + Get a message\n\nPurpose: Watches Gmail for new incoming messages, then fetches the full details (ID, subject, text, threadId, sender).\n\nThis provides the input data that downstream AI nodes will analyze and act on."
      },
      "typeVersion": 1
    },
    {
      "id": "1c0fdd25-c89d-4ee8-a83e-7f0b455921e8",
      "name": "メッセージ取得",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1424,
        240
      ],
      "webhookId": "b6b6ae33-af63-423a-b24d-70f9c8ccb73c",
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PuAE61pOClI4CRxE",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "09f432ed-6285-4147-92d5-2b645912098d",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        -112
      ],
      "parameters": {
        "width": 400,
        "height": 704,
        "content": "## Google Gemini Chat Model + AI Categorizer\n\nPurpose: Uses Gemini to classify each email into one of three categories:\n\n⦿ Reply: normal emails needing an auto-response\n\n⦿ Draft: sensitive or complex emails that need human review\n\n⦿ Nothing: spam, automated notices, or irrelevant messages\nOnly the single word category is returned."
      },
      "typeVersion": 1
    },
    {
      "id": "53e0e46b-f29f-45d0-a417-df2fdf1f56bb",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -144
      ],
      "parameters": {
        "width": 320,
        "height": 608,
        "content": "## Reply, Draft, or Nothing (Switch)\n\nPurpose: Routes emails based on AI categorization:\n\n⦿ Reply → Generate Reply Email → Reply (auto-response sent immediately)\n\n⦿ Draft → Generate Draft Email → Flag for Human Review (reply is drafted but stored for human validation before sending)\n\n⦿ Nothing → No Operation (message ignored, nothing happens)"
      },
      "typeVersion": 1
    },
    {
      "id": "c4d14987-f859-4983-9adc-7e326554262c",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        -240
      ],
      "parameters": {
        "width": 672,
        "height": 576,
        "content": "## Generate Email Reply + Gemini Chat Reply + Reply\n\nPurpose:\n\n⦿ Gemini writes a warm, professional final reply using the subject + body of the incoming message.\n\n⦿ Reply node sends this AI-written response directly back to the sender, keeping the thread intact."
      },
      "typeVersion": 1
    },
    {
      "id": "2664562a-abe4-4857-ab53-82b8726a57ce",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        496
      ],
      "parameters": {
        "width": 320,
        "height": 400,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## No Operation, do nothing\n\nPurpose: Handles the “Nothing” category gracefully. The workflow ends here without any email action."
      },
      "typeVersion": 1
    },
    {
      "id": "447df387-dbca-40eb-990e-2d22906a0447",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -448,
        432
      ],
      "parameters": {
        "width": 672,
        "height": 592,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Generate Draft Email + Gemini Chat Draft + Flag for Human Review\n\nPurpose:\n\n⦿ Gemini drafts a professional reply in the same style, but does not send it.\n\n⦿ Draft is created in Gmail (with the sender and subject filled in).\n\n⦿ A human can then review/edit before sending. "
      },
      "typeVersion": 1
    },
    {
      "id": "6ec6fb16-1f87-408d-8bd2-9211384cea2b",
      "name": "返信、下書き、または無処理",
      "type": "n8n-nodes-base.switch",
      "position": [
        -736,
        224
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "68b68c40-f028-4431-9940-66543b04578a",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "Reply"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7df0c8a2-3616-4e84-9af3-14a2e637cb7c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "Draft"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "799f30a4-15c6-45cb-8617-d9e2fe148536",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output }}",
                    "rightValue": "Nothing"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "a4e6e81d-de73-4562-b37e-dfab96ba5fc4",
      "name": "メール下書き生成",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -384,
        480
      ],
      "parameters": {
        "text": "=Reply to the email I give you in a warm, polite, and professional tone. Write like a thoughtful human—use natural phrasing, gentle transitions, and avoid robotic or overly formal wording. Address all points clearly, keep it concise, and maintain a friendly, respectful feel. Reply must be easy to read. and don't output subject line, only output the reply. My name is hashir. must keep an eye on one thing, don't add in the reply anything like this \"[Your Company Name]\" etc. its a final reply so don't add anything that that needs any manual addition or editing. Output the final reply.\n\nHere is the Subject line: {{ $('Get a message').item.json.headers.subject }}\n\nHere is the Email:\n\n{{ $('Get a message').item.json.text }}",
        "options": {
          "batching": {
            "batchSize": 1,
            "delayBetweenBatches": 0
          },
          "passthroughBinaryImages": true,
          "returnIntermediateSteps": false
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "65df0884-ef4d-483b-a8d4-a9ba0e252f94",
      "name": "メール返信生成",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -384,
        32
      ],
      "parameters": {
        "text": "=Reply to the email I give you in a warm, polite, and professional tone. Write like a thoughtful human—use natural phrasing, gentle transitions, and avoid robotic or overly formal wording. Address all points clearly, keep it concise, and maintain a friendly, respectful feel. Reply must be easy to read. and don't output subject line, only output the reply. My name is hashir. must keep an eye on one thing, don't add in the reply anything like this \"[Your Company Name]\" etc. its a final reply so don't add anything that needs any manual addition or editing. Output the final reply.\n\nHere is the Subject line: {{ $('Get a message').item.json.headers.subject }}\n\nHere is the Email:\n\n{{ $('Get a message').item.json.text }}",
        "options": {
          "passthroughBinaryImages": true,
          "returnIntermediateSteps": false
        },
        "promptType": "define"
      },
      "typeVersion": 2
    },
    {
      "id": "f45ae81c-8201-46cd-ba7f-955b69070108",
      "name": "メール返信",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -96,
        32
      ],
      "webhookId": "4729862b-1009-44e9-a631-9b6651d34d0f",
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {
          "appendAttribution": true,
          "replyToSenderOnly": false
        },
        "emailType": "text",
        "messageId": "={{ $('Get a message').item.json.id }}",
        "operation": "reply"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PuAE61pOClI4CRxE",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "82f0e737-89c4-45cd-b18c-2d01f85218da",
  "connections": {
    "1c0fdd25-c89d-4ee8-a83e-7f0b455921e8": {
      "main": [
        [
          {
            "node": "af2b05c9-5229-4027-a514-0d210ea26fe7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "57d5d8fd-3391-4af0-9305-2249d4885f5f": {
      "main": [
        [
          {
            "node": "1c0fdd25-c89d-4ee8-a83e-7f0b455921e8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "af2b05c9-5229-4027-a514-0d210ea26fe7": {
      "main": [
        [
          {
            "node": "6ec6fb16-1f87-408d-8bd2-9211384cea2b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9a53a9bf-9665-4f5c-a0b9-74f5421509f5": {
      "ai_languageModel": [
        [
          {
            "node": "a4e6e81d-de73-4562-b37e-dfab96ba5fc4",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "75bda556-8de8-462d-8ca6-a3fc30ca3436": {
      "ai_languageModel": [
        [
          {
            "node": "65df0884-ef4d-483b-a8d4-a9ba0e252f94",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "a4e6e81d-de73-4562-b37e-dfab96ba5fc4": {
      "main": [
        [
          {
            "node": "04005997-5f22-40f8-b1c5-8791b106d277",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "65df0884-ef4d-483b-a8d4-a9ba0e252f94": {
      "main": [
        [
          {
            "node": "f45ae81c-8201-46cd-ba7f-955b69070108",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "55ee3c91-fa91-44eb-ad28-87c2a614f2a1": {
      "ai_languageModel": [
        [
          {
            "node": "af2b05c9-5229-4027-a514-0d210ea26fe7",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6ec6fb16-1f87-408d-8bd2-9211384cea2b": {
      "main": [
        [
          {
            "node": "65df0884-ef4d-483b-a8d4-a9ba0e252f94",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a4e6e81d-de73-4562-b37e-dfab96ba5fc4",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "5396f107-619c-426d-b759-ebece261871f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - チケット管理, マルチモーダルAI

有料ですか?

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

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

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

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34