メール要約

中級

これはPersonal Productivity, AI Summarization分野の自動化ワークフローで、11個のノードを含みます。主にIf, Code, Gmail, Limit, GoogleDocsなどのノードを使用。 毎日のメール要約をGoogleドキュメントに送信(GPT-4)

前提条件
  • Googleアカウント + Gmail API認証情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "p5e76vbOIDIaf29H",
  "meta": {
    "instanceId": "6304e8877aa0fde3913b14034debe07006963fb497d63f280a91bbd75c6c24e1",
    "templateCredsSetupCompleted": true
  },
  "name": "Email Summary",
  "tags": [
    {
      "id": "TNPHEZ52JXA88tV0",
      "name": "AI",
      "createdAt": "2025-06-28T18:46:13.842Z",
      "updatedAt": "2025-06-28T18:46:13.842Z"
    },
    {
      "id": "pD2RVg49fBlIR8pA",
      "name": "Gmail",
      "createdAt": "2025-06-28T19:24:47.979Z",
      "updatedAt": "2025-06-28T19:24:47.979Z"
    },
    {
      "id": "wZ14hcyo2pYAOVlF",
      "name": "OpenAI",
      "createdAt": "2025-06-28T18:46:13.462Z",
      "updatedAt": "2025-06-28T18:46:13.462Z"
    },
    {
      "id": "M3TlU8Xdj7ZlK0PE",
      "name": "Project Management",
      "createdAt": "2025-06-28T18:46:13.681Z",
      "updatedAt": "2025-06-28T18:46:13.681Z"
    },
    {
      "id": "bpJw62xLnDDElGob",
      "name": "Building blocks",
      "createdAt": "2025-06-28T18:46:13.530Z",
      "updatedAt": "2025-06-28T18:46:13.530Z"
    },
    {
      "id": "3nY5Wk7HNEt9e9gW",
      "name": "DevOps",
      "createdAt": "2025-06-28T18:46:13.916Z",
      "updatedAt": "2025-06-28T18:46:13.916Z"
    },
    {
      "id": "1Z9wnauckk6RWoYl",
      "name": "Email",
      "createdAt": "2025-07-19T17:42:50.746Z",
      "updatedAt": "2025-07-19T17:42:50.746Z"
    }
  ],
  "nodes": [
    {
      "id": "10e1dc39-0561-4bfd-b80f-e60a91af3cb5",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -60
      ],
      "parameters": {
        "width": 1880,
        "height": 460,
        "content": "Telegram Email Summary Workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "ef07131c-2d2c-42ed-a1de-7e5625c8057c",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -720
      ],
      "parameters": {
        "color": 3,
        "width": 580,
        "height": 640,
        "content": "Email Summary Workflow:\n\nThis n8n workflow automatically summarizes the latest email in your inbox and saves the summary to a Google Doc. It's designed as a simple, modular starting point that users can easily expand or customize.\n\nHow It Works\n- Trigger: A Schedule Trigger runs the workflow daily at 8 AM.\n\n- Get Email: The Gmail node fetches the most recent email.\n\n- Limit: Only the most recent email is passed through.\n\n- Check for New Email: An IF node determines whether a new email was found.\n\nIf yes, the email content is cleaned (HTML stripped, base64 decoded).\n\nIf no, a fallback message is created noting there are no new emails.\n\n- Summarization: The content is passed to OpenAI with a detailed prompt to summarize:\n\nSender\nDate\nSubject\nMain points, requests, and action items\n\n- Google Docs Output:\nA new Google Doc titled Email Summary is created (or reused).\nThe summary is inserted into the document for future reference.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "28c3ca0d-9397-41e3-b8b9-13a577e0ca98",
      "name": "スケジュールトリガー",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -40,
        100
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "da1aaa80-87a6-4d98-b14f-e08e327553bc",
      "name": "リミット",
      "type": "n8n-nodes-base.limit",
      "position": [
        340,
        100
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "54653ec9-413f-4656-955c-3dcaacdee6cf",
      "name": "条件分岐",
      "type": "n8n-nodes-base.if",
      "position": [
        540,
        100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "621c437c-e857-4e21-9aa6-ed75ae360775",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $('Get Gmail').item.json.headers.from }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f6b7ea0d-b521-459d-856c-f39a26962356",
      "name": "メール",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        0
      ],
      "parameters": {
        "jsCode": "// This function will strip out HTML tags to leave only the plain text.\nfunction extractCleanText(html) {\n  if (!html) {\n    return '';\n  }\n  // A regular expression to remove HTML tags and extra whitespace.\n  return html.replace(/<[^>]*>/g, \"\").replace(/\\s+/g, ' ').trim();\n}\n\n// Process each email item passed to the node.\nreturn $input.all().map(item => {\n  const payload = item.json.payload || {};\n  const headers = payload.headers || [];\n  \n  // A helper function to find a specific header's value.\n  const getHeader = (name) => headers.find(h => h.name.toLowerCase() === name.toLowerCase())?.value || 'N/A';\n\n  const from = getHeader('From');\n  const subject = getHeader('Subject');\n  const date = getHeader('Date');\n\n  let bodyData = '';\n  // Check for multipart emails first.\n  if (payload.parts) {\n    // Prefer plain text over HTML for simplicity.\n    const plainPart = payload.parts.find(p => p.mimeType === 'text/plain');\n    const htmlPart = payload.parts.find(p => p.mimeType === 'text/html');\n    \n    // Use the data from the preferred part.\n    if (plainPart && plainPart.body && plainPart.body.data) {\n      bodyData = plainPart.body.data;\n    } else if (htmlPart && htmlPart.body && htmlPart.body.data) {\n      bodyData = htmlPart.body.data;\n    }\n  } else if (payload.body && payload.body.data) {\n    // Fallback for single-part emails.\n    bodyData = payload.body.data;\n  }\n\n  // The body content is Base64 encoded, so it needs to be decoded.\n  const decodedBody = Buffer.from(bodyData, 'base64').toString('utf-8');\n  \n  // Clean the decoded body to remove any lingering HTML.\n  const cleanBody = extractCleanText(decodedBody);\n\n  return {\n    json: {\n      from,\n      subject,\n      date,\n      body: cleanBody\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "6967e64d-32ac-4981-969b-76719d0b0377",
      "name": "メールなし",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        240
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      from: \"N/A\",\n      subject: \"No Email Found\",\n      date: new Date().toISOString(),\n      body: \"No new emails were found during this summary check. There is nothing to summarize at this time.\"\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a0e30b66-7329-4731-9401-5896855a7a22",
      "name": "Get Gmail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        160,
        100
      ],
      "webhookId": "efcd3ee6-26a7-4c3d-84c2-c1cdef8a8d7c",
      "parameters": {
        "limit": 1,
        "simple": false,
        "filters": {},
        "options": {},
        "operation": "getAll"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "B0oVer8pX52LHrvw",
          "name": "Gmail account 2"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a931d85d-40ea-4bde-a0aa-8f9a7ef14c04",
      "name": "メール要約 OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1060,
        120
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "GPT-4.1"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are a professional AI assistant tasked with summarizing the most recent email received.\n\nYour goal is to deliver a clear, concise, and accurate summary that saves the user time by eliminating the need to read the full email. The summary should convey all essential details and maintain a professional tone.\n\nPlease include the following in your response:\n\nSender's name and email address: {{ $('Get Gmail').item.json.headers.from }}\n\nDate and time received: {{ $('Get Gmail').item.json.headers.date }}\n\nSubject line (if available): {{ $('Get Gmail').item.json.headers.subject }}\n\nMain purpose or topic of the email\n\nKey points, requests, or required actions\n\nAny additional relevant context that helps the user understand the email at a glance\n\nAvoid unnecessary repetition or filler. The summary should be easy to scan, but detailed enough that the user can fully understand the message without opening the original email.\n\nSummarize the following content:\n\n{{ $('Get Gmail').item.json.text }}"
            }
          ]
        },
        "simplify": false
      },
      "credentials": {
        "openAiApi": {
          "id": "Yks1Eic3YR07Cpm6",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "537c41f8-5cea-46d6-92a9-a2cffdd65bb2",
      "name": "Create Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1420,
        120
      ],
      "parameters": {
        "title": "Email Summary",
        "folderId": "1ihoRENubwDmcwMqhFzbdnfuYQdU2YXVR"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "dSGiWWxQdhY5ywpg",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "96ca547a-cb62-4eef-a9dc-765654c13e1d",
      "name": "Update Google Docs",
      "type": "n8n-nodes-base.googleDocs",
      "position": [
        1620,
        120
      ],
      "parameters": {
        "simple": false,
        "actionsUi": {
          "actionFields": [
            {
              "text": "={{ $('Summary Email OpenAI').item.json.choices[0].message.content }}",
              "action": "insert"
            }
          ]
        },
        "operation": "update",
        "documentURL": "={{ $json.id }}"
      },
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "dSGiWWxQdhY5ywpg",
          "name": "Google Docs account"
        }
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bf63aae4-7580-4cb7-93ab-9631974dc104",
  "connections": {
    "54653ec9-413f-4656-955c-3dcaacdee6cf": {
      "main": [
        [
          {
            "node": "f6b7ea0d-b521-459d-856c-f39a26962356",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "6967e64d-32ac-4981-969b-76719d0b0377",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f6b7ea0d-b521-459d-856c-f39a26962356": {
      "main": [
        [
          {
            "node": "a931d85d-40ea-4bde-a0aa-8f9a7ef14c04",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "da1aaa80-87a6-4d98-b14f-e08e327553bc": {
      "main": [
        [
          {
            "node": "54653ec9-413f-4656-955c-3dcaacdee6cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6967e64d-32ac-4981-969b-76719d0b0377": {
      "main": [
        [
          {
            "node": "a931d85d-40ea-4bde-a0aa-8f9a7ef14c04",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a0e30b66-7329-4731-9401-5896855a7a22": {
      "main": [
        [
          {
            "node": "da1aaa80-87a6-4d98-b14f-e08e327553bc",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "28c3ca0d-9397-41e3-b8b9-13a577e0ca98": {
      "main": [
        [
          {
            "node": "a0e30b66-7329-4731-9401-5896855a7a22",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "537c41f8-5cea-46d6-92a9-a2cffdd65bb2": {
      "main": [
        [
          {
            "node": "96ca547a-cb62-4eef-a9dc-765654c13e1d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a931d85d-40ea-4bde-a0aa-8f9a7ef14c04": {
      "main": [
        [
          {
            "node": "537c41f8-5cea-46d6-92a9-a2cffdd65bb2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

中級 - 個人の生産性, AI要約

有料ですか?

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

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

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

作成者
Michael Gullo

Michael Gullo

@drdoom

I’m passionate about using n8n to create realistic workflows that help working class people simplify their daily tasks. My workflows aim to make life easier by eliminating mundane, repetitive responsibilities that take up valuable time. I love turning automation into a tool that lets people focus on what matters most to them.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34