8
n8n 中文网amn8n.com

生日和星历通知

高级

这是一个Other领域的自动化工作流,包含 26 个节点。主要使用 If, Set, Code, Merge, Telegram 等节点。 生日和星历通知 (Google联系人、Telegram和Home Assistant)

前置要求
  • Telegram Bot Token
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "y76cTME4BEhw95mU",
  "meta": {
    "instanceId": "89af474e60c70a1e45bf242e266e9ca1446dd974ab86f6d185b8ccded3effed2",
    "templateCredsSetupCompleted": true
  },
  "name": "生日和星历通知(Google 联系人、Telegram 和 Home Assistant)",
  "tags": [
    {
      "id": "TwicI38nhopsenFM",
      "name": "tutorial",
      "createdAt": "2025-05-01T16:25:25.881Z",
      "updatedAt": "2025-05-01T16:25:25.881Z"
    }
  ],
  "nodes": [
    {
      "id": "a2f6a1b1-07e7-4ea8-8c44-507e4a4ce8d7",
      "name": "Google 联系人",
      "type": "n8n-nodes-base.googleContacts",
      "position": [
        500,
        -420
      ],
      "parameters": {
        "fields": [
          "birthdays",
          "names"
        ],
        "options": {},
        "rawData": true,
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "googleContactsOAuth2Api": {
          "id": "lGaPwXvxmFj4DUSB",
          "name": "Google Contacts account (TF)"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "448e68ee-81e5-4487-b023-0aeb7666009d",
      "name": "获取名字列表",
      "type": "n8n-nodes-base.set",
      "position": [
        940,
        -220
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a14c29b7-0902-4184-987d-2c367dbcd257",
              "name": "prénoms",
              "type": "string",
              "value": "={{ Array.from(new Set([...( $json.name || [] ), ...( $json.givenName || [] )])) }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "de0a4d55-7bd7-4d24-97a0-593442472a57",
      "name": "名字",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        720,
        -220
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "names[0].givenName"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a8ee01f9-05d6-4589-b399-a0ff141995ec",
      "name": "Nominis - 今日圣人",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        720,
        40
      ],
      "parameters": {
        "url": "={{ $json.URL }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "4c6c0726-187f-4697-b935-a93e68e7e9d2",
      "name": "组合名字与圣人",
      "type": "n8n-nodes-base.merge",
      "position": [
        1160,
        -220
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3
    },
    {
      "id": "61384cde-744a-4091-b639-dfbb9e801026",
      "name": "今日无圣人?",
      "type": "n8n-nodes-base.if",
      "position": [
        1600,
        -220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "91fd004e-ac14-4957-b3eb-aeb08ddcb90f",
              "operator": {
                "type": "boolean",
                "operation": "false",
                "singleValue": true
              },
              "leftValue": "={{ $json.hasMatch }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "36836914-c1c0-45e4-8e40-e95255af0c04",
      "name": "撰写消息",
      "type": "n8n-nodes-base.set",
      "position": [
        2620,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "00b2965c-a9c8-45ea-8dff-b241517aa474",
              "name": "message",
              "type": "string",
              "value": "=Nous sommes le {{ $('Set Date Offset').item.json.date.toDateTime().setLocale('fr').format('dd LLL yyyy') }}:\n{{ $json.Birthday }}{{ $json.fete }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1c3eecb1-5623-4f0d-b361-9b1f0f520c40",
      "name": "单一列表生日",
      "type": "n8n-nodes-base.set",
      "position": [
        1160,
        -620
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7a8cde23-384d-41b1-bda8-4fb954f1ded9",
              "name": "anniversary",
              "type": "array",
              "value": "={{ [].concat($json.displayName || [], $json.name || []) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8417f6b0-1174-48ae-81a0-367a95eb9f71",
      "name": "获取 Nominis URL",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        40
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d5a204e9-b6b4-46d7-8e10-43b272c3df27",
              "name": "URL",
              "type": "string",
              "value": "=https://nominis.cef.fr/json/nominis.php?jour={{ $json.date.slice(8,10) }}&mois={{ $json.date.slice(5,7) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ae03ca3a-b89e-461d-9fee-8fa5e0835ff6",
      "name": "已发送 Telegram 消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2840,
        -300
      ],
      "webhookId": "eeda1f74-6e01-4507-895d-eb4448cf97c3",
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "Enter ID here",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "CXhPqEQYE959f1rf",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "72561cef-18c0-42bb-aeba-5a0c9edebbb2",
      "name": "今日生日?",
      "type": "n8n-nodes-base.if",
      "position": [
        720,
        -520
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "91fd004e-ac14-4957-b3eb-aeb08ddcb90f",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.birthdays[0].date.month }}",
              "rightValue": "={{ $('Set Date Offset').item.json.date.toDateTime().month }}"
            },
            {
              "id": "e22d0adc-27bc-4806-a8eb-882a324de2e3",
              "operator": {
                "type": "number",
                "operation": "equals"
              },
              "leftValue": "={{ $json.birthdays[0].date.day }}",
              "rightValue": "={{ $('Set Date Offset').item.json.date.toDateTime().day }}"
            },
            {
              "id": "de6faccb-3dc9-46a5-9b9f-2dcd67323003",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "73b23829-3de7-4ce1-af1a-3c0d3d7b8d47",
      "name": "设置日期偏移",
      "type": "n8n-nodes-base.set",
      "position": [
        180,
        -200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c9683414-7c6c-434e-952d-fa7e6fb1d89d",
              "name": "date",
              "type": "string",
              "value": "={{ $today.plus({days:3}) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "af033f75-db4f-4bdc-b2ea-fb5a9d226165",
      "name": "每日早上7点",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -40,
        -200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 7 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "18992707-c7f8-471c-81c3-10c0c1c7562e",
      "name": "今日圣人列表",
      "type": "n8n-nodes-base.set",
      "position": [
        940,
        40
      ],
      "parameters": {
        "options": {
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "94478a1c-c75f-4e42-911d-53873b8a157a",
              "name": "Saints",
              "type": "array",
              "value": "={{ Array.from(new Set([...Object.keys($json.response.prenoms.majeurs), ...Object.keys($json.response.prenoms.derives)])) }}\n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0446428f-678c-4798-84a1-17a4cfdc5615",
      "name": "检查是否有名字匹配今日圣人",
      "type": "n8n-nodes-base.code",
      "position": [
        1380,
        -220
      ],
      "parameters": {
        "jsCode": "// Helper function to remove accents and convert to lowercase\nfunction normalizeString(str) {\n  str\n    .normalize(\"NFD\")                  // Decompose accented characters\n    .replace(/[\\u0300-\\u036f]/g, \"\")   // Remove diacritics\n    .toLowerCase();                    // Convert to lowercase\n  return str.charAt(0).toUpperCase() + str.slice(1)\n}\n\nconst saints = $json[\"Saints\"]\n  .split(',')\n  .map(s => normalizeString(s.trim()))\n  .filter(s => s.length > 0);\n\nconst givenNames = $json[\"prénoms\"]\n  .split(',')\n  .map(s => normalizeString(s.trim()))\n  .filter(s => s.length > 0);\n\nconst matches = saints.filter(name => givenNames.includes(name));\nreturn [{ json: { matches, hasMatch: matches.length > 0 } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "8ae56325-b16b-4222-b14b-6631da56eba5",
      "name": "聚合生日",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        940,
        -620
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "names[0].displayName"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8ebf2870-feab-4ed9-bc18-2e1bd46cf0c6",
      "name": "聚合无生日",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        940,
        -420
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "name"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a66b44d7-6fee-4480-b2e7-dbf862c27d9b",
      "name": "\"圣名纪念日\"庆祝消息",
      "type": "n8n-nodes-base.set",
      "position": [
        1960,
        -300
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "3b11dc8e-7905-4358-af6b-767550f79b55",
              "name": "fete",
              "type": "string",
              "value": "=\nBonne fête {{ $json.matches.join(', ') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40b49097-0910-44fc-9287-c976e13da70d",
      "name": "生日庆祝消息",
      "type": "n8n-nodes-base.set",
      "position": [
        1960,
        -500
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "60bb0fb7-3395-4772-baf3-32922f7da1c4",
              "name": "Birthday",
              "type": "string",
              "value": "=\nAujourd'hui, c'est l'anniversaire de {{ $json.anniversary.join(', ') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "54d92f95-03c9-4258-9ebf-66fb9f13f195",
      "name": "合并生日 + 圣名纪念日消息",
      "type": "n8n-nodes-base.merge",
      "position": [
        2180,
        -400
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3
    },
    {
      "id": "2e26ec97-bff0-41be-914e-e978cba49cd5",
      "name": "检查是否有庆祝活动",
      "type": "n8n-nodes-base.if",
      "position": [
        2400,
        -400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "5ba01568-dfa9-496d-afeb-30b9c08f5af5",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.Birthday }}",
              "rightValue": ""
            },
            {
              "id": "41f70dad-ec70-49f2-bc43-09b88eb60997",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.fete }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "693c9749-4d63-442a-b6f8-bd2090bb1be9",
      "name": "发送到 Google Home 扬声器",
      "type": "n8n-nodes-base.homeAssistant",
      "position": [
        2840,
        -500
      ],
      "parameters": {
        "domain": "tts",
        "service": "speak",
        "resource": "service",
        "operation": "call",
        "serviceAttributes": {
          "attributes": [
            {
              "name": "entity_id",
              "value": "tts.google_translate_fr_fr"
            },
            {
              "name": "message",
              "value": "={{ $json.message }}"
            },
            {
              "name": "media_player_entity_id",
              "value": "media_player.google_cuisine"
            }
          ]
        }
      },
      "credentials": {
        "homeAssistantApi": {
          "id": "VurjB0xfUjis4pXd",
          "name": "Home Assistant account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e2f0d6c7-711c-49d4-82a6-5216a166c75a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -340
      ],
      "parameters": {
        "width": 400,
        "height": 300,
        "content": "## 调度与偏移"
      },
      "typeVersion": 1
    },
    {
      "id": "4ddd362a-d254-42e8-8b81-ecb8e31951fe",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        0
      ],
      "parameters": {
        "width": 620,
        "height": 340,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "dc4ca251-80ec-4069-94b2-205bb111d4b2",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -720
      ],
      "parameters": {
        "width": 1260,
        "height": 680,
        "content": "## 生日与名字操作"
      },
      "typeVersion": 1
    },
    {
      "id": "42577f80-1c10-4935-af8f-076f1f2838c3",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1880,
        -620
      ],
      "parameters": {
        "width": 860,
        "height": 520,
        "content": "## 庆祝消息撰写"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f1eb642f-f198-4d75-86ee-c4967d4f8791",
  "connections": {
    "First names": {
      "main": [
        [
          {
            "node": "Get One first name list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Birthday Today?": {
      "main": [
        [
          {
            "node": "Aggregate Birthdays",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Aggregate No Birthday",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Compose Message": {
      "main": [
        [
          {
            "node": "Sent Telegram Message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send to Google Home Speaker",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Everyday at 7am": {
      "main": [
        [
          {
            "node": "Set Date Offset",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Nominis URL": {
      "main": [
        [
          {
            "node": "Nominis - Saints du jour",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Contacts": {
      "main": [
        [
          {
            "node": "First names",
            "type": "main",
            "index": 0
          },
          {
            "node": "Birthday Today?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Date Offset": {
      "main": [
        [
          {
            "node": "Google Contacts",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Nominis URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "No Saint Today ?": {
      "main": [
        [
          {
            "node": "Merge Birthday + Fête Messages",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "\"Bonne fête\" celebration message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Birthdays": {
      "main": [
        [
          {
            "node": "Single list Birthday",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Single list Birthday": {
      "main": [
        [
          {
            "node": "Birthday celebration message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate No Birthday": {
      "main": [
        [
          {
            "node": "Merge Birthday + Fête Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get One first name list": {
      "main": [
        [
          {
            "node": "Combine Firstname & Saints",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Nominis - Saints du jour": {
      "main": [
        [
          {
            "node": "List of Saints of the day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List of Saints of the day": {
      "main": [
        [
          {
            "node": "Combine Firstname & Saints",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Combine Firstname & Saints": {
      "main": [
        [
          {
            "node": "Check if any firstname match a Saints of the day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Birthday celebration message": {
      "main": [
        [
          {
            "node": "Merge Birthday + Fête Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Birthday + Fête Messages": {
      "main": [
        [
          {
            "node": "Check if any celebration to make",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if any celebration to make": {
      "main": [
        [
          {
            "node": "Compose Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\"Bonne fête\" celebration message": {
      "main": [
        [
          {
            "node": "Merge Birthday + Fête Messages",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Check if any firstname match a Saints of the day": {
      "main": [
        [
          {
            "node": "No Saint Today ?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 其他

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量26
分类1
节点类型11
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Thibaud

Thibaud

@tderouze

Automation consultant with over 10 years experience helping Sales & Marketing teams to streamline their processes.

外部链接
在 n8n.io 查看

分享此工作流