毎日誕生日祝賀(コードノード最終版)

上級

これはPersonal Productivity, Multimodal AI分野の自動化ワークフローで、17個のノードを含みます。主にIf, Code, Gmail, Slack, HttpRequestなどのノードを使用。 NASA画像、GPT-4、Gmail、Slackを使用した自動太空テーマ誕生日メール

前提条件
  • Googleアカウント + Gmail API認証情報
  • Slack Bot Token または Webhook URL
  • ターゲットAPIの認証情報が必要な場合あり
  • Google Sheets API認証情報
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "0czfWskRwpjMRqaZ",
  "meta": {
    "instanceId": "66e13aec947801e3f08d27a590fb0e07109805e23a7eabde7c0647150db10195",
    "templateCredsSetupCompleted": true
  },
  "name": "Daily Birthday Celebration (Code Node Final Version)",
  "tags": [],
  "nodes": [
    {
      "id": "adaf007f-0c2d-4dc2-a8f9-55b00f7f3d53",
      "name": "毎朝7:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        256,
        -208
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 7 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "721377a2-196c-4d2e-8c33-33ffa5f9c765",
      "name": "バースデー名簿取得",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        -208
      ],
      "parameters": {
        "sheetName": "",
        "documentId": ""
      },
      "typeVersion": 4.7
    },
    {
      "id": "18bd2530-8a96-4b66-8792-2f6ab0449e17",
      "name": "本日の誕生日をフィルタリング",
      "type": "n8n-nodes-base.code",
      "position": [
        704,
        -208
      ],
      "parameters": {
        "jsCode": "const today = new Date();\nconst todayMonth = today.getMonth() + 1; // 1-12\nconst todayDay = today.getDate();\n\nconst birthdaysToday = [];\n\nfor (const item of $input.all()) {\n  const birthdayStr = item.json.birthday || item.json.Birthday;\n  if (!birthdayStr) continue;\n  \n  const birthday = new Date(birthdayStr);\n  const birthMonth = birthday.getMonth() + 1;\n  const birthDay = birthday.getDate();\n  \n  if (birthMonth === todayMonth && birthDay === todayDay) {\n    birthdaysToday.push(item.json);\n  }\n}\n\nif (birthdaysToday.length > 0) {\n  // Pass along the list of people with birthdays today\n  return [{ json: { birthdays: birthdaysToday } }];\n}\n\n// If no birthdays, return empty to stop the workflow here\nreturn [];"
      },
      "typeVersion": 2
    },
    {
      "id": "66f0cde9-e2c6-4a02-81bc-c5c8cea8048b",
      "name": "本日誕生日はあるか?",
      "type": "n8n-nodes-base.if",
      "position": [
        928,
        -208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "1fd71fc8-79c7-432f-88b4-a1418f6bed90",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $input.all().length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "707d5452-5d02-4372-aaa1-e4ffc609a9b9",
      "name": "バースデーデータ準備",
      "type": "n8n-nodes-base.code",
      "position": [
        1376,
        -304
      ],
      "parameters": {
        "jsCode": "const epicImages = $('Fetch NASA EPIC Images2').all().map(item => item.json);\nconst allBirthdays = $('Filter Today\\'s Birthdays').first().json.birthdays;\n\n// We only need one image, let's take the first one returned by the API\nconst latestImage = epicImages[0];\n\nconst results = [];\n\n// Construct the full image URL from the EPIC data parts\nconst d = new Date(latestImage.date);\nconst year = d.getFullYear();\nconst month = ('0' + (d.getMonth() + 1)).slice(-2);\nconst day = ('0' + d.getDate()).slice(-2);\nconst imageName = latestImage.image;\nconst imageUrl = `https://epic.gsfc.nasa.gov/archive/natural/${year}/${month}/${day}/png/${imageName}.png`;\n\n// Combine the image data with each birthday person's data\nfor (const person of allBirthdays) {\n  results.push({\n    json: {\n      ...person, // This includes name, email, birthday\n      epicCaption: latestImage.caption,\n      epicDate: latestImage.date,\n      epicImageUrl: imageUrl\n    }\n  });\n}\n\nreturn results;"
      },
      "typeVersion": 2
    },
    {
      "id": "ec074153-a990-4f9a-891a-6e0e3d3096f9",
      "name": "宇宙バースデーメッセージ生成",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1600,
        -304
      ],
      "parameters": {
        "text": "=Person's name: {{ $json.name || $json.Name }}\nToday's Earth photo caption: {{ $json.epicCaption }}",
        "options": {
          "systemMessage": "You are a creative birthday message writer specializing in space-themed greetings.\n\nYour task is to:\n1. Generate a fun, space-themed birthday message for the person, mentioning our home planet Earth.\n2. Incorporate the NASA EPIC photo's caption into the message.\n3. Keep the message to approximately 120 characters.\n4. Make it celebratory and cosmic!\n5. Return ONLY the birthday message text, nothing else."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "3cf8af5f-0019-46d2-8d7b-310a31b6fcaf",
      "name": "OpenAI チャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1680,
        -80
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "0550ac86-0258-4819-a2e5-a0cf737003bd",
      "name": "誕生日数をカウント",
      "type": "n8n-nodes-base.code",
      "position": [
        1152,
        -112
      ],
      "parameters": {
        "jsCode": "const birthdays = $input.item.json.birthdays || [];\nconst count = birthdays.length;\nreturn [{ json: { birthdayCount: count } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "0a531f86-adb7-4518-8aee-3e6e9d72e907",
      "name": "Slack 通知を投稿",
      "type": "n8n-nodes-base.slack",
      "position": [
        1376,
        -112
      ],
      "webhookId": "16e4d5a6-43dd-4694-9509-50f05c4db2f3",
      "parameters": {
        "text": "=🎂 Birthdays today: {{ $json.birthdayCount }}",
        "select": "channel",
        "channelId": "",
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "typeVersion": 2.3
    },
    {
      "id": "2fd5a4d7-0181-42e1-936c-b59046c714df",
      "name": "NASA EPIC画像を取得2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1152,
        -304
      ],
      "parameters": {
        "url": "https://epic.gsfc.nasa.gov/api/natural",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "2496302d-6108-43cb-b6b6-2eedbad73af5",
      "name": "バースデーメール送信",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2400,
        -304
      ],
      "webhookId": "58c2dcc8-58f5-4dd6-a291-066ff0f05a72",
      "parameters": {
        "sendTo": "=={{ $json.Email }}",
        "message": "=<h2>Happy Birthday {{ $json.name || $json.Name }}! 🎂🌏</h2>\n\n<p>{{ $json.birthdayMessage }}</p>\n\n<h3>A View of Our Home Planet For You:</h3>\n<p><strong>{{ $json.epicCaption }}</strong></p>\n<img src=\"{{ $json.epicImageUrl }}\" alt=\"NASA EPIC Earth Photo\" style=\"max-width: 600px; height: auto;\" />\n\n<p>This photo of Earth was taken on {{ new Date($json.epicDate).toLocaleDateString() }}.</p>\n\n<p>Wishing you a wonderful year ahead! 🌟</p>",
        "options": {},
        "subject": "=🎂🌏 Happy Birthday {{ $json.Name }} !"
      },
      "typeVersion": 2.1
    },
    {
      "id": "b541cac2-92d9-45ca-b75c-b2a783c2a380",
      "name": "Gmail 用にフォーマット",
      "type": "n8n-nodes-base.code",
      "position": [
        2032,
        -304
      ],
      "parameters": {
        "jsCode": "// --- ここから下をすべてコピーする ---\n\n// 個人情報が入った荷物を、すべて持ってくる\nconst personalInfoItems = $('Prepare Birthday Data').all();\n\n// AI賢者からのメッセージが入った荷物を、すべて持ってくる\nconst birthdayMessageItems = $('Generate Space Birthday Message').all();\n\n// 荷物の数が合っているか、念のために確認する\nif (personalInfoItems.length !== birthdayMessageItems.length) {\n  throw new Error(`荷物の数が合いません!個人情報は${personalInfoItems.length}件、AIメッセージは${birthdayMessageItems.length}件です。これではペアを作れません!`);\n}\n\n// 完成したプレゼントを入れるための、空の箱を用意する\nconst finalPackages = [];\n\n// forループという魔法の呪文で、荷物を先頭から一つずつ処理していく\nfor (let i = 0; i < personalInfoItems.length; i++) {\n  const personalInfo = personalInfoItems[i].json;\n  const birthdayMessage = birthdayMessageItems[i].json.output;\n\n  // 2つの情報を合体させて、一つのきれいな包みにする\n  finalPackages.push({\n    json: {\n      ...personalInfo,\n      birthdayMessage: birthdayMessage,\n    }\n  });\n}\n\n// 完成したプレゼントを、すべて次の工程へ渡す\nreturn finalPackages;\n\n// --- ここまでをすべてコピーする ---"
      },
      "typeVersion": 2
    },
    {
      "id": "a4b3d302-e082-4fcd-9caf-f241422a913c",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        -544
      ],
      "parameters": {
        "color": "#FFFFFF",
        "width": 300,
        "height": 208,
        "content": "## 4. Configure Email Sender\n- **Credentials:** Select your Gmail credentials.\n\nThe email content is pre-filled with data from the previous steps."
      },
      "typeVersion": 1
    },
    {
      "id": "03d1abb0-c969-40d1-8f6e-af82984f37f9",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -736
      ],
      "parameters": {
        "height": 1296,
        "content": "## Send daily space-themed birthday greetings via Gmail and Slack\nThis workflow automates daily birthday celebrations with a unique, cosmic twist! It checks a Google Sheet for birthdays each morning, fetches a stunning new image of Earth from NASA, uses AI to write a personalized space-themed message, and sends it as a celebratory email. It also posts a summary notification in Slack.\n\n### Who it's for\nPerfect for teams, communities, or anyone who wants a fun, automated way to remember and celebrate birthdays. If you love space and want to make someone's special day a little more cosmic, this is for you.\n\n### What it does\n1.  **Triggers Daily:** The workflow runs every morning at 7:00 AM.\n2.  **Reads Birthdays:** It fetches a list of names and birthdays from a specified Google Sheet.\n3.  **Checks for Today's Birthdays:** It filters the list to see if anyone has a birthday today.\n4.  **Gets NASA Image:** If there's a birthday, it fetches the latest \"Earth Polychromatic Imaging Camera\" (EPIC) image from NASA's API.\n5.  **Generates AI Message:** It uses an AI model to craft a unique, space-themed birthday message.\n6.  **Sends Email:** It sends a personalized HTML email to the birthday person, featuring the message and the NASA Earth photo.\n7.  **Notifies Slack:** It posts a message in a designated Slack channel to let the team know who is celebrating their birthday.\n\n### How to set up\nFollow the instructions in the sticky notes below to configure the workflow nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "8710f379-ac18-43e2-8115-696d22e6a832",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        -576
      ],
      "parameters": {
        "height": 336,
        "content": "## 1. Configure Birthday Roster\n- **Credentials:** Select your Google Sheets credentials.\n- **Document ID:** Enter the ID of the Google Sheet containing birthdays.\n- **Sheet Name:** Enter the name of the specific sheet.\n\n**IMPORTANT:** Your sheet must have columns named `Name`, `Email`, and `Birthday`."
      },
      "typeVersion": 1
    },
    {
      "id": "675f8a58-0e45-47d0-bcf3-764ec00ca94b",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -576
      ],
      "parameters": {
        "height": 224,
        "content": "## 2. Configure OpenAI Model\n- **Credentials:** Select your OpenAI credentials.\n- **Model:** Choose the AI model you wish to use for generating messages."
      },
      "typeVersion": 1
    },
    {
      "id": "31428758-c1cd-4cff-8bb7-cd6dbdc861d8",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1248,
        48
      ],
      "parameters": {
        "height": 240,
        "content": "## 3. Configure Slack Notification\n- **Credentials:** Select your Slack credentials.\n- **Channel ID:** Choose the Slack channel where you want to post birthday notifications."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {
    "Generate Space Birthday Message": [
      {
        "json": {
          "output": "Happy Birthday, 星野 光! Celebrate your day from Earth, seen by NASA's EPIC—our cosmic home in the vast universe! 🎉🌍✨"
        }
      },
      {
        "json": {
          "output": "Happy Birthday 弟子 二号! From Earth to the stars, NASA's EPIC sees your cosmic shine bright today! 🚀🌍🎉"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "75159693-40d3-49a5-986e-f6878b2a5b5d",
  "connections": {
    "0550ac86-0258-4819-a2e5-a0cf737003bd": {
      "main": [
        [
          {
            "node": "0a531f86-adb7-4518-8aee-3e6e9d72e907",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b541cac2-92d9-45ca-b75c-b2a783c2a380": {
      "main": [
        [
          {
            "node": "2496302d-6108-43cb-b6b6-2eedbad73af5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3cf8af5f-0019-46d2-8d7b-310a31b6fcaf": {
      "ai_languageModel": [
        [
          {
            "node": "ec074153-a990-4f9a-891a-6e0e3d3096f9",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "721377a2-196c-4d2e-8c33-33ffa5f9c765": {
      "main": [
        [
          {
            "node": "18bd2530-8a96-4b66-8792-2f6ab0449e17",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "66f0cde9-e2c6-4a02-81bc-c5c8cea8048b": {
      "main": [
        [
          {
            "node": "2fd5a4d7-0181-42e1-936c-b59046c714df",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "0550ac86-0258-4819-a2e5-a0cf737003bd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "adaf007f-0c2d-4dc2-a8f9-55b00f7f3d53": {
      "main": [
        [
          {
            "node": "721377a2-196c-4d2e-8c33-33ffa5f9c765",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "707d5452-5d02-4372-aaa1-e4ffc609a9b9": {
      "main": [
        [
          {
            "node": "ec074153-a990-4f9a-891a-6e0e3d3096f9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2fd5a4d7-0181-42e1-936c-b59046c714df": {
      "main": [
        [
          {
            "node": "707d5452-5d02-4372-aaa1-e4ffc609a9b9",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "18bd2530-8a96-4b66-8792-2f6ab0449e17": {
      "main": [
        [
          {
            "node": "66f0cde9-e2c6-4a02-81bc-c5c8cea8048b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ec074153-a990-4f9a-891a-6e0e3d3096f9": {
      "main": [
        [
          {
            "node": "b541cac2-92d9-45ca-b75c-b2a783c2a380",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - 個人の生産性, マルチモーダルAI

有料ですか?

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

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

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

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34