GmailとGPTを使って毎日のメール要約を自動送信

中級

これはPersonal Productivity, AI Summarization分野の自動化ワークフローで、6個のノードを含みます。主にCron, Gmail, OpenAi, Functionなどのノードを使用。 GmailとGPTを使って毎日のメール要約を自動送信し、午後に送信する

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

使用ノード (6)

ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "nodes": [
    {
      "name": "午後トリガー (16時)",
      "type": "n8n-nodes-base.cron",
      "notes": {
        "text": "### 1. Trigger in the Afternoon\n\nThis `Cron` node is configured to run automatically every **day at 4:00 PM (16:00)** based on your n8n server's local time zone.\n\n**To change the schedule:** Adjust the 'Hour' and 'Minute' fields to your preferred time.",
        "position": "right"
      },
      "position": [
        240,
        300
      ],
      "parameters": {
        "mode": "everyDay",
        "value": {
          "hour": [
            16
          ],
          "minute": [
            0
          ]
        },
        "options": {}
      },
      "typeVersion": 1,
      "id": "-16--0"
    },
    {
      "name": "今日の日付を算出",
      "type": "n8n-nodes-base.function",
      "notes": {
        "text": "### 2. Calculate Today's Dates\n\nThis `Function` node calculates the start of the current day (midnight) and the current time, which will be used to fetch emails received *today* up to the moment the workflow runs.\n\n**Output:** It generates two fields:\n* `minDate`: The ISO string for today's midnight (00:00:00).\n* `nowDate`: The ISO string for the current time (when the workflow runs).\n\n**No configuration needed here**; it automatically determines the dates.",
        "position": "right"
      },
      "position": [
        480,
        300
      ],
      "parameters": {
        "options": {},
        "function": "const DateTime = this.getNodeParameter('DateTime');\n\nconst now = DateTime.now();\n\n// Calculate the start of the current day (e.g., today at 00:00:00)\nconst startOfDay = now.startOf('day');\n\nreturn [{ json: { \n  minDate: startOfDay.toISO(),\n  nowDate: now.toISO()\n} }];"
      },
      "typeVersion": 1,
      "id": "--1"
    },
    {
      "name": "今日のメールを取得 (Gmail)",
      "type": "n8n-nodes-base.gmail",
      "notes": {
        "text": "### 3. Get Today's Emails\n\nThis `Gmail` node fetches emails received in your inbox since the beginning of the current day until the workflow is triggered.\n\n**Setup:**\n1.  **Gmail Credential:** Click on 'Credentials' and select 'New Credential'. Choose 'Gmail API'. Follow the n8n instructions to connect your Gmail account.\n2.  **Query:** The 'Query' field uses Gmail's search operators (`after:` and `before:`) combined with the dates calculated in the previous node to ensure it only fetches today's emails.\n3.  **Max Results:** Adjust `Max Results` if you typically receive many more than 20 emails in a day that you'd want summarized. (Be mindful of AI token limits for very large inputs).\n\n**Important:** Ensure your Gmail API has the necessary read scope (`https://www.googleapis.com/auth/gmail.readonly` or full access).",
        "position": "right"
      },
      "position": [
        720,
        300
      ],
      "parameters": {
        "query": "after:{{ $json.minDate }} before:{{ $json.nowDate }}",
        "options": {
          "maxResults": 20
        },
        "emailType": "inbox",
        "operation": "getAll"
      },
      "credentials": {
        "gmailApi": {
          "id": "YOUR_GMAIL_CREDENTIAL_ID",
          "resolve": false
        }
      },
      "typeVersion": 2,
      "id": "-Gmail--2"
    },
    {
      "name": "メールの内容を結合",
      "type": "n8n-nodes-base.function",
      "notes": {
        "text": "### 4. Combine Email Content\n\nThis `Function` node takes all the fetched emails and combines their sender, subject, and snippet (a short preview) into a single text string.\n\n**Purpose:** This consolidated text string will then be fed into the AI summarization node.\n\n**No configuration needed here**; it's pre-programmed to format your email data.",
        "position": "right"
      },
      "position": [
        960,
        300
      ],
      "parameters": {
        "options": {},
        "function": "let emailContent = \"\";\n\nif (items.length === 0) {\n  emailContent = \"No new emails received today.\";\n} else {\n  emailContent = \"Today's Emails Summary:\\n\\n\";\n  for (const item of items) {\n    const email = item.json;\n    const sender = email.payload.headers.find(h => h.name === 'From').value || 'Unknown Sender';\n    const subject = email.payload.headers.find(h => h.name === 'Subject').value || 'No Subject';\n    const snippet = email.snippet || 'No snippet available.';\n\n    emailContent += `From: ${sender}\\nSubject: ${subject}\\nSnippet: ${snippet}\\n---\\n`;\n  }\n}\n\nreturn [{ json: { combinedEmails: emailContent } }];"
      },
      "typeVersion": 1,
      "id": "--3"
    },
    {
      "name": "AI: メールを要約",
      "type": "n8n-nodes-base.openAi",
      "notes": {
        "text": "### 5. AI: Summarize Emails\n\nThis `OpenAI` node takes the combined email content and generates a high-level summary using artificial intelligence.\n\n**Setup:**\n1.  **OpenAI Credential:** Select your existing OpenAI API Key credential.\n2.  **Model:** You can choose `gpt-3.5-turbo` for cost-effectiveness or `gpt-4o` for potentially better and more nuanced summaries.\n3.  **Prompt:** The system prompt instructs the AI on how to summarize the emails, focusing on key topics and action items.\n\n**Output:** The AI-generated summary will be in `{{ $node[\"AI: Summarize Emails\"].json.choices[0].message.content }}`.",
        "position": "right"
      },
      "position": [
        1200,
        300
      ],
      "parameters": {
        "model": "gpt-3.5-turbo",
        "options": {},
        "messages": [
          {
            "role": "system",
            "content": "You are an AI assistant specialized in summarizing daily email communications. Your task is to read the provided email subjects and snippets, identify the most important topics and action items, and create a concise, readable summary. Group related emails if possible. If there are no emails, state that clearly."
          },
          {
            "role": "user",
            "content": "Summarize the following daily email content:\n\n{{ $json.combinedEmails }}"
          }
        ]
      },
      "credentials": {
        "openAiApi": {
          "id": "YOUR_OPENAI_CREDENTIAL_ID",
          "resolve": false
        }
      },
      "typeVersion": 1,
      "id": "AI--4"
    },
    {
      "name": "要約メールを送信",
      "type": "n8n-nodes-base.gmail",
      "notes": {
        "text": "### 6. Send Summary Email\n\nThis `Gmail` node sends the final AI-generated summary to your specified email address.\n\n**Setup:**\n1.  **Gmail Credential:** Select your existing Gmail API credential.\n2.  **From Email:** Enter your Gmail address (this must be the same account you authenticated).\n3.  **To Email:** **IMPORTANT: Change `YOUR_RECIPIENT_EMAIL@example.com` to your actual email address!**\n4.  **Subject:** Includes the current date for easy reference.\n5.  **Text:** The email body contains the summary generated by the AI.\n\nAfter setting up, you can test by clicking 'Execute Workflow' (from the 'Afternoon Trigger' node) to receive an immediate summary of today's emails.",
        "position": "right"
      },
      "position": [
        1440,
        300
      ],
      "parameters": {
        "text": "Hello!\n\nHere's your daily email summary from n8n for today:\n\n{{ $node[\"AI: Summarize Emails\"].json.choices[0].message.content }}\n\n---\n\n*This is an automated summary generated by n8n. Please log into your inbox for full details.*",
        "options": {},
        "subject": "Daily Email Summary: {{ DateTime.now().toFormat('cccc, LLLL dd, yyyy') }}",
        "toEmail": "YOUR_RECIPIENT_EMAIL@example.com",
        "fromEmail": "YOUR_GMAIL_EMAIL@gmail.com"
      },
      "credentials": {
        "gmailApi": {
          "id": "YOUR_GMAIL_CREDENTIAL_ID",
          "resolve": false
        }
      },
      "typeVersion": 2,
      "id": "--5"
    }
  ],
  "pinData": {},
  "version": 1,
  "connections": {
    "AI--4": {
      "main": [
        [
          {
            "node": "--5",
            "type": "main"
          }
        ]
      ]
    },
    "--3": {
      "main": [
        [
          {
            "node": "AI--4",
            "type": "main"
          }
        ]
      ]
    },
    "--1": {
      "main": [
        [
          {
            "node": "-Gmail--2",
            "type": "main"
          }
        ]
      ]
    },
    "-16--0": {
      "main": [
        [
          {
            "node": "--1",
            "type": "main"
          }
        ]
      ]
    },
    "-Gmail--2": {
      "main": [
        [
          {
            "node": "--3",
            "type": "main"
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

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

有料ですか?

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

関連ワークフロー

OpenAIとGmailを使用した毎日のポジティブニュース要約
OpenAIとGmailを使用した毎日のポジティブなニュース要約
If
Cron
Gmail
+
If
Cron
Gmail
9 ノードPiotr Sobolewski
個人の生産性
企業のオンラインイメージ監視ツール
AI感情分析とマルチプラットフォーム追跡を使用した毎日の企業のオンラインイメージ監視
Set
Cron
Gmail
+
Set
Cron
Gmail
17 ノードPiotr Sobolewski
市場調査
マルチプラットフォームゲーム割引追踪の自動化
Deko Deals と Gmail アラートを使用したマルチプラットフォームゲーム割引の自動追跡
If
Cron
Gmail
+
If
Cron
Gmail
11 ノードPiotr Sobolewski
個人の生産性
自動ウェブクローラー:仕事の細分化/製品モニタリングとTelegramアラート
自動化された Web クローラー: セグメント化されたジョブ/製品の監視と Telegram アラート
If
Cron
Function
+
If
Cron
Function
6 ノードPiotr Sobolewski
市場調査
OpenAIとGmailを使用してポッドキャストの文字起こしを要約し、キーワードを生成
OpenAIとGmailを使用してポッドキャストの字幕を要約し、キーワードを生成する
Set
Gmail
Open Ai
+
Set
Gmail
Open Ai
6 ノードPiotr Sobolewski
コンテンツ作成
静かなCFOの日の出 —ソフトテクノロジーモーニングブリーフ(ホームCEO)🌸
🌸 CFO 日の出 - 家庭用CEO向けソフトウェア技術モーニングブリーフィング(n8n テンプレート)
Set
Cron
Open Ai
+
Set
Cron
Open Ai
15 ノードShelly-Ann Davy
個人の生産性
ワークフロー情報
難易度
中級
ノード数6
カテゴリー2
ノードタイプ4
難易度説明

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

作成者
Piotr Sobolewski

Piotr Sobolewski

@piotrsobolewski

AI PhD with 7 years experience as a game dev CEO, currently teaching, helping others and building something new.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34