Gmail AI 自動返信

中級

これはMultimodal AI分野の自動化ワークフローで、11個のノードを含みます。主にIf, Set, Gmail, GmailTrigger, Agentなどのノードを使用。 Gmail自動返信ジェネレーター、GPT-4o-miniを使用

前提条件
  • Googleアカウント + Gmail API認証情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "name": "Gmail Auto-Reply with AI",
  "tags": [],
  "nodes": [
    {
      "id": "50972917-6da6-4b55-b18b-0bd96445e9f8",
      "name": "新着メールトリガー",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        -352
      ],
      "parameters": {
        "filters": {
          "readStatus": "unread"
        },
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f42bb871-a182-4708-aa12-65f6c9c5ee28",
      "name": "未読メール取得",
      "type": "n8n-nodes-base.gmail",
      "position": [
        224,
        -352
      ],
      "parameters": {
        "simple": false,
        "options": {},
        "messageId": "={{ $json.id }}",
        "operation": "get"
      },
      "typeVersion": 2.1
    },
    {
      "id": "c0ce4d37-a5ce-4926-9edf-5aa68d80426a",
      "name": "必須フィールド取得",
      "type": "n8n-nodes-base.set",
      "position": [
        448,
        -352
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "name": "threadId",
              "type": "string",
              "value": "={{ $json.threadId }}"
            },
            {
              "name": "id",
              "type": "string",
              "value": "={{ $json.id }}"
            },
            {
              "name": "From",
              "type": "string",
              "value": "={{ $json.headers.from }}"
            },
            {
              "name": "message",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "name": "subject",
              "type": "string",
              "value": "={{ $json.subject }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        672,
        -352
      ],
      "parameters": {
        "text": "=You are an assistant that helps draft email replies.\n\nYour task:\n1. Read the email message below:\n\"{{ $json.message }}\"\n\n2. Decide if this is an email that requires a reply.  \n   - If it's spam, a notification, or irrelevant, set `isReply` to false.  \n   - If it's a genuine message that can be replied to, set `isReply` to true.  \n\n3. If `isReply` is true, draft a short and polite reply that:  \n   - Acknowledges the sender.  \n   - Is under 120 words.  \n   - Does not promise action you cannot take.  \n\n4. Return the result **only in valid JSON**, no extra text.\n\nJSON format to return:\n{\n  \"isReply\": true | false,\n  \"response\": \"string or empty if isReply is false\"\n}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "5673e94b-82b0-407f-9db4-60b35dfb8253",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        680,
        -128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "00fe0a38-cc10-492e-86d6-af0494c8afc9",
      "name": "構造化出力",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        808,
        -128
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"isReply\": {\n      \"type\": \"boolean\",\n      \"description\": \"Whether the email requires a reply\"\n    },\n    \"response\": {\n      \"type\": \"string\",\n      \"description\": \"The drafted reply text if isReply is true, otherwise empty\"\n    }\n  },\n  \"required\": [\"isReply\", \"response\"]\n}\n"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7fd55349-a8a3-4c1b-8dc8-221a50915a5e",
      "name": "AIエージェントは返信可能か?",
      "type": "n8n-nodes-base.if",
      "position": [
        1024,
        -352
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.output.isReply }}",
              "rightValue": "true"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe",
      "name": "下書き作成",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1248,
        -352
      ],
      "parameters": {
        "message": "={{ $json.output.response }}",
        "options": {
          "threadId": "={{ $('Get Required Fields').item.json.threadId }}"
        },
        "subject": "={{ $('Get Required Fields').item.json.subject }}",
        "resource": "draft"
      },
      "typeVersion": 2.1
    },
    {
      "id": "be177f90-54e7-472f-8b30-3dd6c8c1f4a3",
      "name": "メールに「対応済」ラベル付与",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1472,
        -352
      ],
      "parameters": {
        "labelIds": [
          "Label_4601850039988562325"
        ],
        "resource": "thread",
        "threadId": "={{ $('Get Required Fields').item.json.threadId }}",
        "operation": "addLabels"
      },
      "typeVersion": 2.1
    },
    {
      "id": "434ebfe4-410a-4f49-9285-cfd6256abb6f",
      "name": "付箋メモ",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        0
      ],
      "parameters": {
        "width": 336,
        "content": "## 🛠️ Setup Instructions\n  - Connect Gmail and OpenAI credentials before activating.\n  - Make sure your Gmail has a label called `Action`."
      },
      "typeVersion": 1
    },
    {
      "id": "77831399-3e74-454e-8e27-b9d6e2af638c",
      "name": "付箋メモ1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        608,
        -576
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 656,
        "content": "## ⚠️ Reply Logic\n  - AI won't reply to spam, notifications, or irrelevant messages.\n  - Only genuine messages get responses. You can review drafts before sending.\n  - Tweak the AI agent's prompt to match your brand voice."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "connections": {
    "5673e94b-82b0-407f-9db4-60b35dfb8253": {
      "ai_languageModel": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112": {
      "main": [
        [
          {
            "node": "7fd55349-a8a3-4c1b-8dc8-221a50915a5e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe": {
      "main": [
        [
          {
            "node": "be177f90-54e7-472f-8b30-3dd6c8c1f4a3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f42bb871-a182-4708-aa12-65f6c9c5ee28": {
      "main": [
        [
          {
            "node": "c0ce4d37-a5ce-4926-9edf-5aa68d80426a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "00fe0a38-cc10-492e-86d6-af0494c8afc9": {
      "ai_outputParser": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "c0ce4d37-a5ce-4926-9edf-5aa68d80426a": {
      "main": [
        [
          {
            "node": "64d9c2c7-0ef8-49f2-9c6c-5b0aabd27112",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "50972917-6da6-4b55-b18b-0bd96445e9f8": {
      "main": [
        [
          {
            "node": "f42bb871-a182-4708-aa12-65f6c9c5ee28",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7fd55349-a8a3-4c1b-8dc8-221a50915a5e": {
      "main": [
        [
          {
            "node": "ba0480ca-4f1d-4813-b6d8-674ec1f2bafe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

中級 - マルチモーダルAI

有料ですか?

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

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

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

作成者
Matt Chong | n8n Creator

Matt Chong | n8n Creator

@mattxchong

Automation nerd fueled by good coffee, deep curiosity, and clean flows.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34