8
n8n 中文网amn8n.com

Telegram日历机器人

中级

这是一个Personal Productivity领域的自动化工作流,包含 11 个节点。主要使用 If, Code, Telegram, GoogleCalendar, ScheduleTrigger 等节点。 从Google日历通过Telegram发送每日日历摘要通知

前置要求
  • Telegram Bot Token
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "SeY9lTVPdPeVIQdg",
  "meta": {
    "instanceId": "b7b2db9d6a461f902b25d685e4550cab3c88fcbb3254a8654e06246b67e4ff5c",
    "templateCredsSetupCompleted": true
  },
  "name": "Telegram 日历机器人",
  "tags": [
    {
      "id": "5iQR5Cw05Bzz7Aqt",
      "name": "Google",
      "createdAt": "2025-08-02T17:36:32.751Z",
      "updatedAt": "2025-08-02T17:36:32.751Z"
    },
    {
      "id": "DW3QCDhQZ9ZpSunz",
      "name": "Bot",
      "createdAt": "2025-08-02T17:37:06.011Z",
      "updatedAt": "2025-08-02T17:37:06.011Z"
    },
    {
      "id": "pvFbKYpUu6xv7RQ8",
      "name": "Calendar",
      "createdAt": "2025-08-02T17:36:30.352Z",
      "updatedAt": "2025-08-02T17:36:30.352Z"
    },
    {
      "id": "rYuINsb3Y1XjrgNv",
      "name": "Productivity",
      "createdAt": "2025-08-02T17:36:49.812Z",
      "updatedAt": "2025-08-02T17:36:49.812Z"
    },
    {
      "id": "yfpCFhbNZGRtYKc0",
      "name": "Telegram",
      "createdAt": "2025-08-02T17:36:35.592Z",
      "updatedAt": "2025-08-02T17:36:35.592Z"
    }
  ],
  "nodes": [
    {
      "id": "a79f7817-b3e8-417c-b176-eb507d9c7b69",
      "name": "统计事件数量",
      "type": "n8n-nodes-base.code",
      "position": [
        416,
        0
      ],
      "parameters": {
        "jsCode": "// Get all the event from the items\nconst allItems = $items(\"Check google Calendar\");\n\n// initiate event board\nlet events = [];\n\n// Check items and extract events\nallItems.forEach(item => {\n  const data = item.json;\n\n  if (Array.isArray(data)) {\n    events.push(...data.filter(e => e && Object.keys(e).length > 0));\n  } else if (data && Object.keys(data).length > 0) {\n    events.push(data);\n  }\n});\n\n// Calculate the number of events\nconst eventCount = events.length;\n\nreturn [\n  {\n    json: {\n      eventCount,\n      events\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3daa99b4-dc92-47eb-a9a2-a749ca5fa215",
      "name": "早上7点触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "11e1cff6-439b-4cae-8d1c-a48e7a8bed90",
      "name": "条件判断",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "0a556b19-d5f6-42fd-aa9f-6ebfc2c5e042",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.eventCount}}",
              "rightValue": 0
            }
          ]
        }
      },
      "executeOnce": false,
      "typeVersion": 2.2,
      "alwaysOutputData": false
    },
    {
      "id": "711a4b13-a376-4f54-b458-f97a832e4fe1",
      "name": "消息代码",
      "type": "n8n-nodes-base.code",
      "position": [
        832,
        -96
      ],
      "parameters": {
        "jsCode": "// Get all of the events from IF true branch\nconst rawItems = $items();\nlet events = [];\n\n// Normalize data\nrawItems.forEach(item => {\n  const data = item.json;\n\n  if (Array.isArray(data.events)) {\n    events.push(...data.events);\n  } else if (data.event) {\n    events.push(data.event);\n  } else {\n    events.push(data);\n  }\n});\n\n// Message creation\nlet message = `☀️ Good morning! Here's your calendar for today\\n\\n📅 You have ${events.length} event${events.length > 1 ? 's' : ''} today.\\n\\n`;\n\nevents.forEach(e => {\n  message += `──────────────────────\\n`;\n  message += `📌 Name: ${e.summary || \"N/A\"}\\n`;\n  message += `⏰ Starts: ${e.start?.dateTime || e.start?.date || \"N/A\"}\\n`;\n  message += `⏳ Ends: ${e.end?.dateTime || e.end?.date || \"N/A\"}\\n\\n`;\n\n  message += `👤 Creator: ${e.creator?.email || \"N/A\"}\\n`;\n  message += `👥 Organizer: ${e.organizer?.email || \"N/A\"}\\n\\n`;\n\n  message += `📄 Type: ${e.eventType || \"N/A\"}\\n`;\n  message += `🔗 Link: ${e.htmlLink || \"N/A\"}\\n\\n`;\n\n  message += `📝 Description: ${e.description || \"No description\"}\\n`;\n  message += `📍 Location: ${e.location || \"N/A\"}\\n\\n`;\n});\n\nmessage += \"✨ Have a great day!\";\n\nreturn [\n  {\n    json: {\n      text: message\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "b6b693b3-c599-49e2-b4cd-7781ef0c97c0",
      "name": "今日无会议消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        928,
        176
      ],
      "webhookId": "9d964a15-b2bc-4d33-afbe-fdb5d537d11a",
      "parameters": {
        "text": "=👋 Hi! Your calendar is clear for today 🗓️✨",
        "chatId": "1234",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "q45sTNe4DEc2aR0Q",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "774ce326-9fd9-4136-8882-e68167c23c13",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -496
      ],
      "parameters": {
        "color": 2,
        "width": 416,
        "height": 848,
        "content": "## 1.工作流触发器和 Google Calendar"
      },
      "typeVersion": 1
    },
    {
      "id": "d2319706-cda9-45a0-860e-d3b1f330d3f0",
      "name": "检查 Google Calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        208,
        0
      ],
      "parameters": {
        "options": {
          "orderBy": "startTime"
        },
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "fr.french#holiday@group.v.calendar.google.com",
          "cachedResultName": "Jours fériés et autres fêtes en France"
        },
        "operation": "getAll",
        "returnAll": true
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "UNaR3A3kfDhLIVuc",
          "name": "Google Calendar account"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.3,
      "alwaysOutputData": true
    },
    {
      "id": "79952d85-8136-40b4-976a-409ecb103230",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -496
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 848,
        "content": "## 2.统计事件代码和分支"
      },
      "typeVersion": 1
    },
    {
      "id": "bbc556dc-619a-4bc1-9fdb-6c0f3a44576e",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -496
      ],
      "parameters": {
        "color": 4,
        "width": 560,
        "height": 848,
        "content": "## 3. 发送 Telegram 消息"
      },
      "typeVersion": 1
    },
    {
      "id": "1e479d9c-0d57-469c-8631-195a879fb351",
      "name": "发送摘要消息",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1040,
        -96
      ],
      "webhookId": "126cc2af-1a44-4309-af2b-83a5f71d65d7",
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "1234",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "q45sTNe4DEc2aR0Q",
          "name": "Telegram account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2d7ba810-f3d8-4e33-940f-516ea9b93a71",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -496
      ],
      "parameters": {
        "color": 3,
        "content": "## 必需条件"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8576f66a-463e-4a95-a07a-205e8f57ff27",
  "connections": {
    "7am trigger": {
      "main": [
        [
          {
            "node": "Check google Calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count event": {
      "main": [
        [
          {
            "node": "If condition",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If condition": {
      "main": [
        [
          {
            "node": "Message code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Message no meeting today",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message code": {
      "main": [
        [
          {
            "node": "Send sum up message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check google Calendar": {
      "main": [
        [
          {
            "node": "Count event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 个人效率

需要付费吗?

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

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

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Yassin Zehar

Yassin Zehar

@yassinzehar

Digital & IT Project Manager | Data-oriented | Agile certified (PSM I, PSPO I) | 6+ yrs experience | Paris

外部链接
在 n8n.io 查看

分享此工作流