{
  "name": "Birthday / Anniversary Wishes",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "8f60ab45-253a-437e-be95-f6a6b3e30799",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -760,
        120
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "operation": "search",
        "base": {
          "__rl": true,
          "value": "appPpy7OlMovX9FcB",
          "mode": "list",
          "cachedResultName": "SaaS Support Management",
          "cachedResultUrl": "https://airtable.com/appPpy7OlMovX9FcB"
        },
        "table": {
          "__rl": true,
          "value": "tblakT5rEzqbW9m3v",
          "mode": "list",
          "cachedResultName": "Users",
          "cachedResultUrl": "https://airtable.com/appPpy7OlMovX9FcB/tblakT5rEzqbW9m3v"
        },
        "filterByFormula": "=OR(\n  AND(\n    {Date_of_Birth},\n    MONTH({Date_of_Birth}) = MONTH(TODAY()),\n    DAY({Date_of_Birth}) = DAY(TODAY())\n  ),\n  AND(\n    {Anniversary},\n    MONTH({Anniversary}) = MONTH(TODAY()),\n    DAY({Anniversary}) = DAY(TODAY())\n  )\n)\n",
        "options": {}
      },
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 2.1,
      "position": [
        -560,
        120
      ],
      "id": "b989b923-a660-4f4c-afb6-d94983cead97",
      "name": "Search Client",
      "alwaysOutputData": true,
      "credentials": {
        "airtableTokenApi": {
          "id": "xwxnYedE3oxmtSfo",
          "name": "Suresh.Airtable Personal Access Token account"
        }
      }
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        -140,
        200
      ],
      "id": "bccc9088-c7a4-4396-b9df-d5715415c6e1",
      "name": "No Operation, do nothing"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "eff6fe23-651d-474d-8d77-3734e1ac4c13",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.Date_of_Birth }}",
              "rightValue": "={{ $('Schedule Trigger').item.json.timestamp }}"
            },
            {
              "id": "b1364fbe-5b07-4c1f-bad6-02ef3e0bf7d4",
              "leftValue": "={{ $json.Anniversary }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "31a42f90-70bc-4fbb-9d84-1d140c039efb",
      "name": "Check Available Dates",
      "type": "n8n-nodes-base.if",
      "position": [
        -360,
        120
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "jsCode": "// Input: one item per person with fields like Date_of_Birth, Anniversary, Full Name, Email Address\n\nconst itemsOut = [];\n\nfor (const item of items) {\n  const data = item.json;\n  const fullName = data[\"Full Name\"] || \"there\";\n  const email = data[\"Email Address\"];\n  const today = new Date().toISOString().slice(5, 10); // \"MM-DD\"\n\n  const dob = data.Date_of_Birth ? data.Date_of_Birth.slice(5, 10) : null;\n  const anniversary = data.Anniversary ? data.Anniversary.slice(5, 10) : null;\n\n  let subject = \"🎉 Greetings!\";\n  let message = `Hello ${fullName},\\n\\nHope you have a wonderful day!`;\n\n  if (dob === today) {\n    subject = \"🎂 Happy Birthday!\";\n    message = `Dear ${fullName},\\n\\nWishing you a very Happy Birthday! 🎈\\nHave a fantastic year ahead!`;\n  } else if (anniversary === today) {\n    subject = \"💍 Happy Anniversary!\";\n    message = `Dear ${fullName},\\n\\nWishing you a very Happy Anniversary! ❤️\\nMay your bond grow stronger every year!`;\n  }\n\n  itemsOut.push({\n    json: {\n      ...data,\n      subject,\n      message,\n      sendTo: email,\n    },\n  });\n}\n\nreturn itemsOut;\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -140,
        20
      ],
      "id": "efb0acdd-769c-4ea1-8bf3-a1ce95e7bc2c",
      "name": "Generate Subject & Body"
    },
    {
      "parameters": {
        "sendTo": "={{ $json[\"Email Address\"] }}",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.message }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        40,
        20
      ],
      "id": "bc52abd7-aefc-4480-8fc6-e0422b7af27b",
      "name": "Send Emails",
      "webhookId": "11c0028c-fb14-4a8c-9a4a-d622ab0a0e66",
      "credentials": {
        "gmailOAuth2": {
          "id": "stjUuumoBlfUIL1N",
          "name": "Suresh.Gmail account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Search Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Client": {
      "main": [
        [
          {
            "node": "Check Available Dates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Available Dates": {
      "main": [
        [
          {
            "node": "Generate Subject & Body",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Subject & Body": {
      "main": [
        [
          {
            "node": "Send Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "34ee96c0-4027-44f4-b59c-4845282c5e28",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "fcb622cbd5234c565b9b78babeaf0ea2455df9d2aad0d1adff7c1ef99583e685"
  },
  "id": "qqAMU7ojUdcffXSV"
}