8
n8n 中文网amn8n.com

使用AI和NextCloud/Google/Zoho将事件文本转换为日历条目

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 19 个节点。主要使用 If, Switch, Webhook, HttpRequest, GoogleCalendar 等节点。 通过AI和NextCloud/Google/Zoho将事件文本转换为日历条目

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "90f9a6ef38ec632934192a5de51518245cd649d4287258dedc9971969910cdb7"
  },
  "nodes": [
    {
      "id": "758f90ce-d94a-4c62-a793-7ddd088178f9",
      "name": "转为 UTC",
      "type": "@n8n/n8n-nodes-langchain.toolCode",
      "position": [
        1120,
        560
      ],
      "parameters": {
        "name": "to_UTC",
        "jsCode": "function toICSDate(query) {\n  let d;\n\n  if (query instanceof Date) {\n    d = query;\n\n  } else if (typeof query === 'string') {\n    if (/^\\d{8}T\\d{6}Z$/.test(query)) {\n      // Already ICS UTC format\n      return query;\n    } else if (/^\\d{8}T\\d{6}$/.test(query)) {\n      // Compact local format, parse manually\n      const [datePart, timePart] = query.split('T');\n      const year   = +datePart.slice(0, 4);\n      const month  = +datePart.slice(4, 6) - 1; // 0‑based\n      const day    = +datePart.slice(6, 8);\n      const hour   = +timePart.slice(0, 2);\n      const minute = +timePart.slice(2, 4);\n      const second = +timePart.slice(4, 6);\n      d = new Date(year, month, day, hour, minute, second);\n    } else {\n      // Assume ISO‑8601 string (\"2025-09-26T11:00:00-04:00\")\n      d = new Date(query);\n    }\n  }\n\n  if (!(d instanceof Date) || isNaN(d)) {\n    throw new Error('Invalid input: must be Date, ISO, ICS UTC, or compact string');\n  }\n\n  // Always format UTC\n  return d.toISOString()\n          .replace(/[-:]/g, '')   // strip separators\n          .replace(/\\.\\d{3}Z$/, 'Z'); // remove ms\n}\n\n// Export\nreturn toICSDate(query);",
        "description": "=调用此工具并提供 *{{ $now.zone.zoneName }}* 时区的 datetime 对象,这将为您提供 UTC 时间,格式为字符串 \"yyyyMMdd'T'HHmmss'Z'\"。"
      },
      "typeVersion": 1.1
    },
    {
      "id": "6917181e-dfdc-4cec-b621-8ce68c774231",
      "name": "大脑",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1020,
        560
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "bbcd8973-12d9-4d85-b6f6-4cec224ad447",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        240
      ],
      "parameters": {
        "color": 4,
        "height": 663.3731744745251,
        "content": "## 开始"
      },
      "typeVersion": 1
    },
    {
      "id": "8b7d5184-0f36-4ae8-87d1-bbaf4b8133f0",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        240
      ],
      "parameters": {
        "color": 7,
        "height": 663.3731744745248,
        "content": "## 扩展"
      },
      "typeVersion": 1
    },
    {
      "id": "2c338370-8748-4c8f-8bdd-29f8b25f86fb",
      "name": "切换",
      "type": "n8n-nodes-base.switch",
      "disabled": true,
      "position": [
        780,
        720
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Text",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "19b65514-2493-4128-8e9c-c1dd40454ac6",
                    "operator": {
                      "type": "string",
                      "operation": "notEmpty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.body.eventInfo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $binary }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "allMatchingOutputs": false
        }
      },
      "typeVersion": 3.1
    },
    {
      "id": "2f211450-6b40-4bac-8a1b-00592164d11d",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1000,
        240
      ],
      "parameters": {
        "width": 358.7342715692612,
        "height": 663.3731744745251,
        "content": "## 解析事件详情"
      },
      "typeVersion": 1
    },
    {
      "id": "276e4820-bbab-48a2-9d9d-dd4275924052",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1380,
        240
      ],
      "parameters": {
        "color": 5,
        "height": 663.3731744745251,
        "content": "## 创建事件"
      },
      "typeVersion": 1
    },
    {
      "id": "93d6676b-f337-4052-927a-d4a86e9d589d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1640,
        240
      ],
      "parameters": {
        "color": 3,
        "height": 663.3731744745251,
        "content": "## 响应"
      },
      "typeVersion": 1
    },
    {
      "id": "6b37e5dd-e26a-4920-a929-9a9749ad8cc1",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        920
      ],
      "parameters": {
        "color": 7,
        "width": 1400.3576539723263,
        "height": 258.08325199688073,
        "content": "## 建议"
      },
      "typeVersion": 1
    },
    {
      "id": "4e383a02-ece9-4c0f-a8a6-4090885e6c40",
      "name": "创建 Zoho 事件 (API)",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Documentation:\nhttps://www.zoho.com/calendar/help/api/post-create-event.html",
      "disabled": true,
      "position": [
        1420,
        720
      ],
      "parameters": {
        "url": "https://calendar.zoho.com/api/v1/calendars/INSERT_CAL_UID_HERE/events",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "queryParameters": {
          "parameters": [
            {
              "name": "eventdata",
              "value": "={\n    \"dateandtime\": {\n        \"timezone\": {{ JSON.stringify($now.zone.zoneName) }},\n        \"start\": {{ JSON.stringify($json.output.startTime) }},\n        \"end\": {{ JSON.stringify($json.output.endTime) }}\n    },\n    \"title\": {{ JSON.stringify($json.output.eventTitle) }},\n    \"location\": {{ JSON.stringify($json.output.location != null ? $json.output.location : \"\") }},\n    \"url\": {{ JSON.stringify($json.output.url != null ? $json.output.url : \"\") }},\n    \"transparency\": 1,\n    \"attendees\": [\n        {\n            \"email\": \"INSERT_EMAIL_HERE\"\n        }\n    ],\n    \"description\": {{ JSON.stringify($json.output.description != null ? $json.output.description : \"\") }}\n}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "06883e54-7548-448d-92d8-6d7079bdbf43",
      "name": "结构化输出",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1220,
        560
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"eventTitle\": \"Marketing Conference\",\n  \"description\": null,\n  \"startTime\": \"20250912T160000Z\",\n  \"endTime\": \"20250912T200000Z\",\n  \"location\": \"15000 Park Ave, Suite 1234, New York, New York, United States\",\n  \"url\": null\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "1102b5a1-932b-4ab9-a2d3-17950c4b8b99",
      "name": "成功响应",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1700,
        540
      ],
      "parameters": {
        "options": {
          "responseCode": 201
        },
        "respondWith": "text",
        "responseBody": "=Your calendar event was successfully created."
      },
      "typeVersion": 1.1
    },
    {
      "id": "c162405c-ed1a-4177-8f9f-5110ffbeb426",
      "name": "失败响应",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1700,
        740
      ],
      "parameters": {
        "options": {
          "responseCode": 400
        },
        "respondWith": "text",
        "responseBody": "=There was a problem with the event info. Try again."
      },
      "typeVersion": 1.1
    },
    {
      "id": "7f11b9f4-526e-45fd-8e89-e89c8b9e2db4",
      "name": "NextCloud 日历事件创建",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        1440,
        540
      ],
      "parameters": {
        "url": "https://your.nextcloudurl.com/remote.php/dav/calendars/YOUR_USER/personal/newEvent.ics",
        "body": "=BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//n8n//CalDAV Connector//EN\nBEGIN:VEVENT\nUID:123456789@example.com\nDTSTAMP:{{ $now.setZone($now.zone.zoneName).toUTC().toFormat(\"yyyyMMdd'T'HHmmss'Z'\") }}\nDTSTART:{{ $json.output.startTime }}\nDTEND:{{ $json.output.endTime }}\nSUMMARY:{{ $json.output.eventTitle }}\nDESCRIPTION:{{ $json.output.description }}\nLOCATION:{{ $json.output.location }}\nURL:{{ $json.output.url }}\nEND:VEVENT\nEND:VCALENDAR",
        "method": "PUT",
        "options": {},
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "text/calendar; charset=utf-8"
      },
      "typeVersion": 4.2
    },
    {
      "id": "9a789e02-203a-40b8-a834-aa6fa6881ce7",
      "name": "良好解析",
      "type": "n8n-nodes-base.if",
      "position": [
        1040,
        760
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3bd94ff5-bebb-43a4-ae06-7790de6df7a6",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.error }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "c6bb115d-bf79-457d-a8db-fb4a8ef1bcf5",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        -260
      ],
      "parameters": {
        "color": 5,
        "width": 435.7280989463619,
        "height": 478.57603298212047,
        "content": "## Eric Knaus www.MarketingGuy.ai"
      },
      "typeVersion": 1
    },
    {
      "id": "f10d8f8d-88b0-49be-8263-14c7a343bc1d",
      "name": "Google Calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "disabled": true,
      "position": [
        1480,
        740
      ],
      "parameters": {
        "end": "={{ $json.output.endTime }}",
        "start": "={{ $json.output.startTime }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "additionalFields": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "b4be10a7-0306-425e-9e24-f449dc198ae0",
      "name": "入站事件信息",
      "type": "n8n-nodes-base.webhook",
      "position": [
        540,
        540
      ],
      "webhookId": "2ee09e2c-6ee0-4e12-a941-a40a63442bb1",
      "parameters": {
        "path": "make-cal-event-xdt8gh4-rf3827",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "80fc0363-4991-4eb9-a019-17b8597e9bfe",
      "name": "解析事件信息",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1040,
        380
      ],
      "parameters": {
        "text": "=Local time context: {{ $now.toString() }}  \nServer timezone: {{ $now.zone.zoneName }}  \n\nInstructions:\n1. Extract calendar event details from the text below.  \n2. For event times, pass each local datetime through `to_UTC(Datetime)` to get UTC output values, in \"YYYYMMDDTHHmmssZ\" format.  \n4. Apply special cases:\n   - Case 1: If text has a date and at least one person/place but no clear details → infer event. If no time, use 08:00–22:00 local.  \n   - Case 2: If there is no date and no person/place/event → output exactly: {\"error\": \"BAD INPUT\"} \n\nText to parse:\n{{ JSON.stringify($json.body.eventInfo) }}",
        "options": {
          "systemMessage": "You are an assistant that extracts calendar event information from text.\n\nAlways respond ONLY in JSON.\n\nNormal Output Schema (when event is valid or inferable):\n{\n  \"eventTitle\": \"string\",\n  \"description\": \"string or null\",\n  \"startTime\": \"YYYYMMDDTHHmmssZ\",  // UTC, ISO8601\n  \"endTime\": \"YYYYMMDDTHHmmssZ\",    // UTC, ISO8601\n  \"location\": \"string or null\",\n  \"url\": \"string or null\"\n}\n\nSpecial Rules:\n1. If text includes at least one date and a name or place but lacks other details → infer a plausible event.  \n   - If no time is provided → assume 08:00 for start time and 22:00 for end time, local time. Convert using `to_UTC`.  \n2. If text has no date and no usable event/person/place detail → output:\n   {\n     \"error\": \"BAD INPUT\"\n   }\n\nFormatting Rules:\n- Output strictly valid JSON only.\n- Use null values for missing optional fields unless you are inferring details under rule (1).\n- Use the `to_UTC(Datetime)` tool to convert each local datetime to UTC."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    }
  ],
  "pinData": {},
  "connections": {
    "Brain": {
      "ai_languageModel": [
        [
          {
            "node": "Parse Event Info",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "to_UTC": {
      "ai_tool": [
        [
          {
            "node": "Parse Event Info",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Good Parse": {
      "main": [
        [
          {
            "node": "NextCloud Cal Event Creation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Event Info": {
      "main": [
        [
          {
            "node": "Good Parse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Parse Event Info",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Inbound Event Info": {
      "main": [
        [
          {
            "node": "Parse Event Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "NextCloud Cal Event Creation": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

高级 - 内容创作, 多模态 AI

需要付费吗?

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

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

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

作者

Automation Wizard bzzt Years of experience as a digital marketer. Honed skill in JS, web dev, email mktg. All about the value to the client. Value, baby, it's everything.

外部链接
在 n8n.io 查看

分享此工作流