Célébration d'anniversaire quotidienne (version finale du nœud de code)

Avancé

Ceci est unPersonal Productivity, Multimodal AIworkflow d'automatisation du domainecontenant 17 nœuds.Utilise principalement des nœuds comme If, Code, Gmail, Slack, HttpRequest. E-mail d'anniversaire spatial automatisé basé sur des images de la NASA, GPT-4, Gmail et Slack

Prérequis
  • Compte Google et informations d'identification Gmail API
  • Token Bot Slack ou URL Webhook
  • Peut nécessiter les informations d'identification d'authentification de l'API cible
  • Informations d'identification Google Sheets API
  • Clé API OpenAI
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "0czfWskRwpjMRqaZ",
  "meta": {
    "instanceId": "66e13aec947801e3f08d27a590fb0e07109805e23a7eabde7c0647150db10195",
    "templateCredsSetupCompleted": true
  },
  "name": "Daily Birthday Celebration (Code Node Final Version)",
  "tags": [],
  "nodes": [
    {
      "id": "adaf007f-0c2d-4dc2-a8f9-55b00f7f3d53",
      "name": "Chaque matin à 7h00",
      "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": "Obtenir la liste des anniversaires",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        -208
      ],
      "parameters": {
        "sheetName": "",
        "documentId": ""
      },
      "typeVersion": 4.7
    },
    {
      "id": "18bd2530-8a96-4b66-8792-2f6ab0449e17",
      "name": "Filtrer les anniversaires du jour",
      "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": "Des anniversaires aujourd'hui ?",
      "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": "Préparer les données d'anniversaire",
      "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": "Générer un message d'anniversaire spatial",
      "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 Chat Model",
      "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": "Compter les anniversaires",
      "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": "Poster une notification 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": "Récupérer les images NASA EPIC2",
      "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": "Envoyer l'email d'anniversaire",
      "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": "Formater pour 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": "Note autocollante",
      "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": "Note autocollante1",
      "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": "Note autocollante2",
      "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": "Note autocollante4",
      "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": "Note autocollante3",
      "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
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Avancé - Productivité personnelle, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Avancé
Nombre de nœuds17
Catégorie2
Types de nœuds10
Description de la difficulté

Adapté aux utilisateurs avancés, avec des workflows complexes contenant 16+ nœuds

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34