使用Google路线API自动添加出行时间块到日历
高级
这是一个Personal Productivity, AI Chatbot领域的自动化工作流,包含 21 个节点。主要使用 Set, HttpRequest, Agent, ScheduleTrigger, GoogleCalendarTool 等节点。 使用Google路线API自动添加出行时间块到日历
前置要求
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (21)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "bwx8LUWOdqelNFta",
"meta": {
"instanceId": "76d3530512082aff31a4213cce7aa2e84150106081c71e5bc3a4b47fc45ee72c",
"templateCredsSetupCompleted": true
},
"name": "出行时间助手",
"tags": [],
"nodes": [
{
"id": "d3159820-3586-40d4-846b-d26a9f8e4ac4",
"name": "计划触发器",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-352,
-16
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 7
}
]
}
},
"typeVersion": 1.2
},
{
"id": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
496,
-16
],
"parameters": {
"text": "=### Objective:\n\nYou are a calendar management agent. Your primary goal is to ensure timely arrival at events by proactively adding blockers for travel time to the user's calendar.\nFor each event on the current day that has a specified location, check if a preceding \"{{ $('Set Defaults').item.json['Blocker name'] }}\" event already exists. If not, calculate the necessary travel time and create a new \"{{ $('Set Defaults').item.json['Blocker name'] }}\" event.\n\nToday is {{ $('Schedule Trigger').item.json['Readable date'] }}\n\n---\n\n### Workflow Breakdown:\n\n1. Use the `get_calendar_events` tool to fetch all events scheduled for today\n\n2. For each retrieved event check if there is a location defined. Those are the events_with_location\n\n3. For all events_with_location, check if there is an event named \"{{ $('Set Defaults').item.json['Blocker name'] }}\" that immediately precedes them. Those which do not have a \"{{ $('Set Defaults').item.json['Blocker name'] }}\" event before them are the events_to_process.\n\n4. For all events_to_process, determine the [Travel_time], which is how long it takes to get to the location of the event. To do this, use the travel_directions tool with the following parameters:\n * End: The location of the event.\n * Start: Check if there is a previous event on the same day that ends within 2 hours before the start time of the current event_to_process. If such an event exists and has a location, then the starting point for `travel_directions` will be the \"location of that previous event\". If no previous Event exists or if the \"location of that previous event\" is not a valid location, then the starting point defaults to \"{{ $('Set Defaults').item.json.home }}\".\n\n\n5. Use the create_calendar_event tool to Create a \"{{ $('Set Defaults').item.json['Blocker name'] }}\" Event with the following parameters:\n * End Time: [Start time of the current event_to_process]\n * Start Time = [Start time of the current event_to_process] - [Travel_time] - [10 minutes]\n",
"options": {},
"promptType": "define"
},
"typeVersion": 2.1
},
{
"id": "e2973419-4b29-49e9-896a-2253ba32bdcc",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
192,
272
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "dYdshxlvWx6vzqIz",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "495b92f3-9ad0-4cad-9675-55dbc237ca1c",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
592,
160
],
"parameters": {
"sessionKey": "={{ $('Schedule Trigger').item.json.timestamp }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "f8db0af5-71c2-4ea4-a576-9b9bd3d56544",
"name": "获取日历事件",
"type": "n8n-nodes-base.googleCalendarTool",
"position": [
976,
416
],
"parameters": {
"options": {},
"timeMax": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Before', ``, 'string') }}",
"timeMin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "k.armbruster91@gmail.com",
"cachedResultName": "Kevin (Home)"
},
"operation": "getAll",
"returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}",
"descriptionType": "manual",
"toolDescription": "Use this get_calendar_events tool to fetch existing appointments for a specified period."
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "NYXw2aJ39yxeyYaw",
"name": "Google Calendar account"
}
},
"typeVersion": 1.3
},
{
"id": "b266622e-0ed4-4d2d-b7b7-8a519f63112e",
"name": "创建日历事件",
"type": "n8n-nodes-base.googleCalendarTool",
"position": [
1184,
416
],
"parameters": {
"end": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('End', ``, 'string') }}",
"start": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Start', ``, 'string') }}",
"calendar": {
"__rl": true,
"mode": "list",
"value": "k.armbruster91@gmail.com",
"cachedResultName": "Kevin (Home)"
},
"additionalFields": {
"summary": "={{ $('Set Defaults').item.json['Blocker name'] }}"
}
},
"credentials": {
"googleCalendarOAuth2Api": {
"id": "NYXw2aJ39yxeyYaw",
"name": "Google Calendar account"
}
},
"typeVersion": 1.3
},
{
"id": "2fa6cda0-ec33-40b9-b7fd-ca2322f811c0",
"name": "出行路线",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
976,
96
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "bwx8LUWOdqelNFta",
"cachedResultName": "Travel Time Agent"
},
"description": "调用此工具来查找两个地点之间的出行路线和时间。",
"workflowInputs": {
"value": {
"mode": "={{ $('Set Defaults').item.json.mode }}",
"origin": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('origin', `Starting point of the Journey.`, 'string') }}",
"destination": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('destination', `End point of the Journey.`, 'string') }}"
},
"schema": [
{
"id": "origin",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "origin",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "destination",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "destination",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "mode",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "mode",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"input"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.2
},
{
"id": "7d71f6ef-5b2f-4de5-a3c1-ab1a97aae97e",
"name": "设置出行时间",
"type": "n8n-nodes-base.set",
"position": [
1824,
80
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "8f5c981c-8a66-4dfe-b820-56173e8e5ff1",
"name": "Travel_time",
"type": "string",
"value": "={{ $json.routes[0].legs[0].duration.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "214b8939-1f46-4444-a49d-e31f6b3f5237",
"name": "调用 Google 路线 API",
"type": "n8n-nodes-base.httpRequest",
"position": [
1472,
80
],
"parameters": {
"url": "=https://maps.googleapis.com/maps/api/directions/json?origin={{ $('Sub: travel_directions').item.json.origin }}&destination={{ $('Sub: travel_directions').item.json.destination }}&mode={{ $('Sub: travel_directions').item.json.mode }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpQueryAuth"
},
"credentials": {
"httpQueryAuth": {
"id": "Cg00y73entM09Op5",
"name": "Google Directions API"
},
"httpBearerAuth": {
"id": "R5SbrGNRBOhfwify",
"name": "Google Directions API"
},
"httpHeaderAuth": {
"id": "g9H1Z2sxkw5Bvlnr",
"name": "n8n MCP Server"
}
},
"typeVersion": 4.2
},
{
"id": "07272792-441a-4386-9cde-32f69f37a64f",
"name": "子流程:出行路线",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
1136,
80
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "origin"
},
{
"name": "destination"
},
{
"name": "mode"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "cad9a72e-e5fe-483a-aa76-67ae557ed688",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
-80
],
"parameters": {
"width": 198,
"height": 224,
"content": "### 每天上午 7 点运行"
},
"typeVersion": 1
},
{
"id": "d0433739-edf4-4da3-97dd-9db22fe84512",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
464,
-80
],
"parameters": {
"width": 358,
"height": 368,
"content": "### 由助手处理工作流"
},
"typeVersion": 1
},
{
"id": "bdf40090-c8d5-4847-b163-0bb5c673bda4",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-320
],
"parameters": {
"color": 3,
"width": 550,
"height": 464,
"content": "### 设置默认值"
},
"typeVersion": 1
},
{
"id": "6bb823e9-d8a2-4a13-a1ae-55e85476d041",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
336
],
"parameters": {
"color": 3,
"width": 438,
"height": 224,
"content": "### 选择您的 Google Calendar 凭据"
},
"typeVersion": 1
},
{
"id": "42ae1381-6c17-4ad5-afd4-97ef4afb9850",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
64,
176
],
"parameters": {
"color": 3,
"width": 342,
"height": 224,
"content": "### 选择您的 OpenAI API 凭据或更改为其他提供商"
},
"typeVersion": 1
},
{
"id": "2af5598b-3f61-43dd-b493-9955defed5ac",
"name": "设置默认值",
"type": "n8n-nodes-base.set",
"position": [
80,
-16
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b4ae68b4-066c-45d7-993d-4a175c9b69b8",
"name": "home",
"type": "string",
"value": "Homestreet 25, 12345 Berlin"
},
{
"id": "ae1e2738-4a51-47a9-880e-49f5ff9c1495",
"name": "mode",
"type": "string",
"value": "transit"
},
{
"id": "e79bdb16-4476-4ce4-9265-3588ac48171b",
"name": "Blocker name",
"type": "string",
"value": "Travel time"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "37163bbe-366d-4c35-a3f7-6f6a55304ed8",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
928,
0
],
"parameters": {
"width": 374,
"height": 240,
"content": "### 这将子工作流作为工具暴露给助手"
},
"typeVersion": 1
},
{
"id": "412286ef-f9c7-4cd1-8aa7-eecfd740774d",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1328,
-96
],
"parameters": {
"color": 3,
"width": 390,
"height": 336,
"content": "### 选择您的 Google Directions API 凭据"
},
"typeVersion": 1
},
{
"id": "d990d59b-f2f1-4ac5-b44f-a2d6bd323505",
"name": "便签7",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
-128
],
"parameters": {
"color": 7,
"width": 1168,
"height": 416,
"content": "### 获取出行时间"
},
"typeVersion": 1
},
{
"id": "a556232d-d2c3-4c31-b999-fcebf43850ad",
"name": "便签8",
"type": "n8n-nodes-base.stickyNote",
"position": [
1760,
-32
],
"parameters": {
"width": 246,
"height": 272,
"content": "### 这仅将出行时间传递给助手,节省 Token"
},
"typeVersion": 1
},
{
"id": "f6ffdca9-9c9a-4849-943c-d8cf4e9fab5e",
"name": "便签9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1088,
-416
],
"parameters": {
"color": 6,
"width": 640,
"height": 1120,
"content": "## 自动在约会前添加出行时间占用块"
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {
"callerPolicy": "workflowsFromSameOwner",
"executionOrder": "v1"
},
"versionId": "394d1db0-fbe4-4c81-ba6f-03013510cb2b",
"connections": {
"2af5598b-3f61-43dd-b493-9955defed5ac": {
"main": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "main",
"index": 0
}
]
]
},
"495b92f3-9ad0-4cad-9675-55dbc237ca1c": {
"ai_memory": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "ai_memory",
"index": 0
}
]
]
},
"d3159820-3586-40d4-846b-d26a9f8e4ac4": {
"main": [
[
{
"node": "2af5598b-3f61-43dd-b493-9955defed5ac",
"type": "main",
"index": 0
}
]
]
},
"e2973419-4b29-49e9-896a-2253ba32bdcc": {
"ai_languageModel": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"2fa6cda0-ec33-40b9-b7fd-ca2322f811c0": {
"ai_tool": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "ai_tool",
"index": 0
}
]
]
},
"f8db0af5-71c2-4ea4-a576-9b9bd3d56544": {
"ai_tool": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "ai_tool",
"index": 0
}
]
]
},
"b266622e-0ed4-4d2d-b7b7-8a519f63112e": {
"ai_tool": [
[
{
"node": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"type": "ai_tool",
"index": 0
}
]
]
},
"07272792-441a-4386-9cde-32f69f37a64f": {
"main": [
[
{
"node": "214b8939-1f46-4444-a49d-e31f6b3f5237",
"type": "main",
"index": 0
}
]
]
},
"214b8939-1f46-4444-a49d-e31f6b3f5237": {
"main": [
[
{
"node": "7d71f6ef-5b2f-4de5-a3c1-ab1a97aae97e",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 个人效率, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
高级多代理AI个人助手(250+任务能力,WhatsApp + GPT)
高级多代理AI个人助手(250+任务能力,WhatsApp + GPT)
Set
Switch
Whats App
+
Set
Switch
Whats App
213 节点Electrabot
个人效率
使用GPT-4创建播放列表和控制Spotify播放器
通过GPT-4创建播放列表并控制Spotify播放器
Set
Code
Spotify
+
Set
Code
Spotify
29 节点Guillaume Duvernay
个人效率
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+
If
Ftp
Set
113 节点I versus AI
其他
博客WordPress复制销售
使用GPT-4、Perplexity AI和WordPress自动化SEO博客内容创建
Set
Code
Notion
+
Set
Code
Notion
39 节点LukaszB
人工智能
自动化博客撰写与社交媒体推广代理
使用GPT-4、Perplexity和WordPress自动化SEO博客创建+社交媒体
Set
Code
Gmail
+
Set
Code
Gmail
79 节点LukaszB
设计
在Braze中更新现有邮件模板
使用AI为Instagram、Facebook、LinkedIn和X自动化社交媒体内容
Set
Gmail
Merge
+
Set
Gmail
Merge
73 节点LukaszB
设计
工作流信息
难度等级
高级
节点数量21
分类2
节点类型10
作者
Kevin Armbruster
@kevin-armbrusterAutomation Consultant with a passion for Every day life improvements
外部链接
在 n8n.io 查看 →
分享此工作流