8
n8n 中文网amn8n.com

维护计划程序-通过ICS邮件

中级

这是一个Project Management, Multimodal AI领域的自动化工作流,包含 7 个节点。主要使用 Code, Gmail, GoogleSheets, ConvertToFile, ScheduleTrigger 等节点。 使用Google Sheets和Gmail ICS邀请发送预防性维护计划

前置要求
  • Google 账号和 Gmail API 凭证
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "dZK8ffaLQG6lZMAM",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa"
  },
  "name": "维护计划程序-通过-ICS-邮件",
  "tags": [],
  "nodes": [
    {
      "id": "c45ddf2c-d266-4ca6-afce-5a9daddb4234",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        -120
      ],
      "parameters": {
        "width": 1240,
        "height": 320,
        "content": "## 通过 ICS 邮件的预防性维护计划程序 (n8n | Google Sheets | SMTP)"
      },
      "typeVersion": 1
    },
    {
      "id": "8cfde48b-026c-4164-9e31-bddba8badfe0",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -680,
        220
      ],
      "parameters": {
        "width": 1240,
        "height": 360,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "43d85eb1-15f2-4dcd-8dba-bf262da239a6",
      "name": "每日触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -580,
        -20
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8f95d48-7616-4c97-83c1-9e73046d0d6b",
      "name": "读取维护任务",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -380,
        -20
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json[\"Day of month\"] }}/{{ $json.Month }}/{{ $json.Year }}",
              "lookupColumn": "date"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bYe5FlYuNNcajCWA5WW8f1wfNbVEMwIP9nyAcZtZeCc",
          "cachedResultUrl": "",
          "cachedResultName": "Preventive_Maintenance_Scheduler_final"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "DG43xmppQ7B2T3O7",
          "name": "Google Sheets account 2"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "fc964f2f-3323-40ee-83d6-e54b7ab95da9",
      "name": "生成 ICS 数据",
      "type": "n8n-nodes-base.code",
      "position": [
        -180,
        -20
      ],
      "parameters": {
        "jsCode": "// Utility function: pad number to 2 digits\nfunction pad(n) { return n < 10 ? '0' + n : n; }\n\nconst result = [];\nfor (const item of $input.all()) {\n  // Parse and convert date to iCal format (YYYYMMDDT090000Z)\n  let rawDate = item.json.date;\n  // Your date is \"30/July/2025\", convert it to YYYYMMDD\n  const monthNames = {\n    \"January\": \"01\", \"February\": \"02\", \"March\": \"03\", \"April\": \"04\",\n    \"May\": \"05\", \"June\": \"06\", \"July\": \"07\", \"August\": \"08\",\n    \"September\": \"09\", \"October\": \"10\", \"November\": \"11\", \"December\": \"12\"\n  };\n  // Split and parse date\n  let [day, month, year] = rawDate.split(\"/\");\n  let eventDate = `${year}${monthNames[month]}${pad(Number(day))}`;\n  // Set time: 09:00 to 10:00 UTC (adjust as needed)\n  let dtStart = `${eventDate}T090000Z`;\n  let dtEnd   = `${eventDate}T100000Z`;\n  // Push the ICS content as a new field\n  result.push({\n    json: {\n      ...item.json,\n      dtStart: dtStart,\n      dtEnd: dtEnd\n    }\n  });\n}\n\nreturn result;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "82b85f31-4329-47ad-a1d0-a4a9959b13e4",
      "name": "创建 ICS 文件",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        40,
        -20
      ],
      "parameters": {
        "end": "={{ $json.dtEnd }}",
        "start": "={{ $json.dtStart }}",
        "title": "=Maintenance",
        "operation": "iCal",
        "additionalFields": {
          "location": "={{ $json.location }}",
          "description": "=Asset - {{ $json.asset }}\nTask - {{ $json.task }}"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "63532b15-5a17-4813-9c7a-b51ad825d99b",
      "name": "发送日历邀请邮件",
      "type": "n8n-nodes-base.gmail",
      "position": [
        260,
        -20
      ],
      "webhookId": "03bf7b9d-1dff-406d-96bd-36d2ac261e96",
      "parameters": {
        "sendTo": "={{ $('Read Maintenance Tasks').item.json.email }}",
        "message": "=Hello,\n\nYou have a scheduled preventive maintenance task today.\n\nDetails:\n- Asset: {{ $('Read Maintenance Tasks').item.json.asset }}\n- Task: {{ $('Read Maintenance Tasks').item.json.task }}\n- Location: {{ $('Read Maintenance Tasks').item.json.location }}\n- Date: {{ $('Read Maintenance Tasks').item.json.date }}\n\nPlease find the calendar invite attached. Add it to your calendar so you don’t miss the task.\n\nThank you,\nMaintenance Team\n",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "=data"
              }
            ]
          },
          "appendAttribution": false
        },
        "subject": "=Preventive Maintenance Task: {{ $('Read Maintenance Tasks').item.json.task }} for {{ $('Read Maintenance Tasks').item.json.asset }} on {{ $('Read Maintenance Tasks').item.json.date }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "Kb30iigFce7pjkMZ",
          "name": "Gmail account 5"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "282a4855-9d31-4c25-b05a-c034b9849839",
  "connections": {
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Read Maintenance Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create ICS File": {
      "main": [
        [
          {
            "node": "Send Calendar Invite Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate ICS Data": {
      "main": [
        [
          {
            "node": "Create ICS File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Maintenance Tasks": {
      "main": [
        [
          {
            "node": "Generate ICS Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 项目管理, 多模态 AI

需要付费吗?

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

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

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

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流