AI Agent:使用 OpenAI 的 Google 日历助手

中级

这是一个AI领域的自动化工作流,包含 13 个节点。主要使用 Agent、GoogleCalendarTool、ChatTrigger、LmChatOpenAi、MemoryBufferWindow 等节点,结合人工智能技术实现智能自动化。 AI 智能助手:基于 OpenAI 的 Google 日历助手

前置要求
  • OpenAI API Key

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ITH6r6UYtlCyUcpj",
  "meta": {
    "instanceId": "b9faf72fe0d7c3be94b3ebff0778790b50b135c336412d28fd4fca2cbbf8d1f5"
  },
  "name": "AI Agent:使用 OpenAI 的 Google 日历助手",
  "tags": [],
  "nodes": [
    {
      "id": "2e670a54-f789-4c8b-abba-ae35c458f5ed",
      "name": "当收到聊天消息时",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -280,
        0
      ],
      "webhookId": "5308edc9-738b-4aae-a789-214e2392579a",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "96bf895f-a18c-4a4c-bc26-3ec5d2372de5",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        160,
        820
      ],
      "parameters": {
        "model": "gpt-4o",
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "",
          "name": "OpenAi"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "270176df-9c2d-4f1a-b017-9349cb249341",
      "name": "窗口缓冲内存",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        580,
        820
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "5cdece35-bd69-4c77-b240-963df8781d64",
      "name": "Google Calendar - 获取事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        960,
        800
      ],
      "parameters": {
        "options": {
          "timeMax": "={{ $fromAI('end_date') }}",
          "timeMin": "={{ $fromAI('start_date') }}"
        },
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": ""
        },
        "operation": "getAll",
        "descriptionType": "manual",
        "toolDescription": "Use this tool when you’re asked to retrieve events data."
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "634e6472-099c-4f0e-b9eb-67956c4881b8",
      "name": "Google Calendar - 创建事件",
      "type": "n8n-nodes-base.googleCalendarTool",
      "position": [
        1380,
        800
      ],
      "parameters": {
        "end": "={{ $fromAI('end_date') }} ",
        "start": "={{ $fromAI('start_date') }} ",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": ""
        },
        "descriptionType": "manual",
        "toolDescription": "Use this Google Calendar tool when you are asked to create an event.",
        "additionalFields": {
          "summary": "={{ $fromAI('event_title') }} ",
          "attendees": [],
          "description": "={{ $fromAI('event_description') }} "
        },
        "useDefaultReminders": false
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "id": "",
          "name": "Google Calendar account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5c93e130-29d5-489b-84ea-3e31f5849b3a",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -380,
        -380
      ],
      "parameters": {
        "color": 7,
        "width": 320,
        "height": 560,
        "content": "## 聊天触发器 - 当收到消息时"
      },
      "typeVersion": 1
    },
    {
      "id": "a1e850b4-d0fe-417c-8e1e-13fb4cdbb0a8",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        -380
      ],
      "parameters": {
        "color": 7,
        "width": 1520,
        "height": 560,
        "content": "## 工具代理 - 日历 AI Agent"
      },
      "typeVersion": 1
    },
    {
      "id": "9b259245-5fd5-4798-973e-bc6aa15da20f",
      "name": "日历 AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        580,
        0
      ],
      "parameters": {
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "=You are a Google Calendar assistant.\nYour primary goal is to assist the user in managing their calendar effectively using two tools: Event Creation and Event Retrieval. Always base your responses on the current date: \n{{ DateTime.local().toFormat('cccc d LLLL yyyy') }}.\nGeneral Guidelines:\nIf the user's initial message is vague (e.g., \"hello\" or a generic greeting) or does not specify a request, explain your capabilities clearly:\nExample: \"Hello! I can help you manage your Google Calendar. You can ask me to create an event or retrieve event data. What would you like me to do?\"\nIf the user specifies a request in their first message, begin preparing to use the appropriate tool:\nFor event creation, gather necessary details like start date, end date, title, and description.\nFor event retrieval, ask for the date range or time period they want to query.\nTool: Event Creation\nWhen asked to create an event:\n\nRequest the start and end dates/times from the user.\nDate format: YYYY-MM-DD HH:mm:ss\nCollect the following information:\nstart_date: Exact start date and time of the event.\nend_date: Exact end date and time of the event.\nevent_title: Event title in uppercase. Suggest one if not provided.\nevent_description: Generate a brief description and present it for confirmation.\nTool: Event Retrieval\nWhen asked to retrieve events:\n\nAsk for the date range or period they are interested in. Examples:\nFor \"last week,\" retrieve events from Monday of the previous week to Friday of the same week.\nFor \"today,\" use the current date.\nFormat the date range:\nstart_date: Start date and time in YYYY-MM-DD HH:mm:ss.\nend_date: End date and time in YYYY-MM-DD HH:mm:ss.\nKey Behaviors:\nClarity: Provide a clear and helpful introduction when the user's request is unclear.\nValidation: Confirm details with the user before finalizing actions.\nAdaptation: Handle varying levels of detail in requests (e.g., \"Add a meeting for next Monday morning\" or \"Retrieve my events for this weekend\").\nProactivity: Offer suggestions to fill in missing details or clarify ambiguous inputs.\nLanguage Matching: Ensure all interactions, including event titles, descriptions, and messages, are in the user's language to provide a seamless experience."
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "b902a7d0-c2ca-4ab9-9f2a-047b9ccb1678",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 720,
        "content": "## OpenAI 聊天模型"
      },
      "typeVersion": 1
    },
    {
      "id": "c67e1e1b-ef9a-4fec-a860-4ec6b7439df6",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        460,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 720,
        "content": "## 窗口缓冲内存"
      },
      "typeVersion": 1
    },
    {
      "id": "bf719d53-e21b-4bd5-9443-c24d008f732b",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 720,
        "content": "## Google Calendar - 获取事件"
      },
      "typeVersion": 1
    },
    {
      "id": "e94eb1f8-df42-414b-9bec-9e6991a5a832",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1260,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 320,
        "height": 720,
        "content": "## Google Calendar - 创建事件"
      },
      "typeVersion": 1
    },
    {
      "id": "707c011c-c822-4922-8ef7-c4368947d179",
      "name": "便签6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        1000
      ],
      "parameters": {
        "color": 4,
        "width": 720,
        "height": 380,
        "content": "## 觉得有趣吗?以下是提升此 AI agent 的方法!"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "timezone": "Europe/Paris",
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "25b51038-e103-4be6-bcd1-64df4b90d4c6",
  "connections": {
    "Calendar AI Agent": {
      "main": [
        []
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Calendar AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Window Buffer Memory": {
      "ai_memory": [
        [
          {
            "node": "Calendar AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Calendar AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar - Get Events": {
      "ai_tool": [
        [
          {
            "node": "Calendar AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar - Create events": {
      "ai_tool": [
        [
          {
            "node": "Calendar AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

这是一个中级难度的工作流,适用于AI等场景。适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

需要付费吗?

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

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

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

作者
Dataki

Dataki

@dataki

I am passionate about transforming complex processes into seamless automations with n8n. My expertise spans across creating ETL pipelines, sales automations, and data & AI-driven workflows. As an avid problem solver, I thrive on optimizing workflows to drive efficiency and innovation.

外部链接
在 n8n.io 上查看 →

分享此工作流