Assistant de temps de trajet
Ceci est unPersonal Productivity, AI Chatbotworkflow d'automatisation du domainecontenant 21 nœuds.Utilise principalement des nœuds comme Set, HttpRequest, Agent, ScheduleTrigger, GoogleCalendarTool. Ajout automatique de blocs de temps de déplacement dans l'agenda via l'API Google Maps
- •Peut nécessiter les informations d'identification d'authentification de l'API cible
- •Clé API OpenAI
Nœuds utilisés (21)
Catégorie
{
"id": "bwx8LUWOdqelNFta",
"meta": {
"instanceId": "76d3530512082aff31a4213cce7aa2e84150106081c71e5bc3a4b47fc45ee72c",
"templateCredsSetupCompleted": true
},
"name": "Travel Time Agent",
"tags": [],
"nodes": [
{
"id": "d3159820-3586-40d4-846b-d26a9f8e4ac4",
"name": "Déclencheur Planifié",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-352,
-16
],
"parameters": {
"rule": {
"interval": [
{
"triggerAtHour": 7
}
]
}
},
"typeVersion": 1.2
},
{
"id": "ec74cf5d-14f6-4a7f-91e7-ee5c5e246edb",
"name": "Agent IA",
"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 Chat Model",
"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": "Mémoire Simple",
"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": "get_calendar_events",
"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": "create_calendar_event",
"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": "travel_directions",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
976,
96
],
"parameters": {
"workflowId": {
"__rl": true,
"mode": "list",
"value": "bwx8LUWOdqelNFta",
"cachedResultName": "Travel Time Agent"
},
"description": "Call this tool to find the travel directions and time between two locations.",
"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": "set Travel_time",
"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": "Call Google Directions 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": "Sub: travel_directions",
"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": "Note Adhésive",
"type": "n8n-nodes-base.stickyNote",
"position": [
-400,
-80
],
"parameters": {
"width": 198,
"height": 224,
"content": "### Runs daily at 7 am"
},
"typeVersion": 1
},
{
"id": "d0433739-edf4-4da3-97dd-9db22fe84512",
"name": "Note Adhésive1",
"type": "n8n-nodes-base.stickyNote",
"position": [
464,
-80
],
"parameters": {
"width": 358,
"height": 368,
"content": "### The Agent handles the workflow"
},
"typeVersion": 1
},
{
"id": "bdf40090-c8d5-4847-b163-0bb5c673bda4",
"name": "Note Adhésive2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-144,
-320
],
"parameters": {
"color": 3,
"width": 550,
"height": 464,
"content": "### Set Default Values\n**home**: Your default address, from where travel time should be calculated\n\n**Blocker name**: The name which you want the Travel time blocker to have in your calendar\n\n**mode**: Your preferred mode of transportation. Select one of the following options:\n - \"transit\": Travel with public transport.\n - \"driving\": Driving by car\n - \"walking\": Walking by foot\n - \"bicycling\": Riding a bike"
},
"typeVersion": 1
},
{
"id": "6bb823e9-d8a2-4a13-a1ae-55e85476d041",
"name": "Note Adhésive3",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
336
],
"parameters": {
"color": 3,
"width": 438,
"height": 224,
"content": "### Select the Credentials for your Google Calendar"
},
"typeVersion": 1
},
{
"id": "42ae1381-6c17-4ad5-afd4-97ef4afb9850",
"name": "Note Adhésive4",
"type": "n8n-nodes-base.stickyNote",
"position": [
64,
176
],
"parameters": {
"color": 3,
"width": 342,
"height": 224,
"content": "### Select the Credentials for your OpenAI API or change for another provider"
},
"typeVersion": 1
},
{
"id": "2af5598b-3f61-43dd-b493-9955defed5ac",
"name": "Set Defaults",
"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": "Note Adhésive5",
"type": "n8n-nodes-base.stickyNote",
"position": [
928,
0
],
"parameters": {
"width": 374,
"height": 240,
"content": "### This exposes the Sub-workflow as a tool for the Agent"
},
"typeVersion": 1
},
{
"id": "412286ef-f9c7-4cd1-8aa7-eecfd740774d",
"name": "Note Adhésive6",
"type": "n8n-nodes-base.stickyNote",
"position": [
1328,
-96
],
"parameters": {
"color": 3,
"width": 390,
"height": 336,
"content": "### Select the Credentials for your Google Directions API\n- Follow these [Instructions to get the API key](https://g.co/gemini/share/b731be41d4f3) for the Google Directions API\n- Open the Node and create a new \"Query Auth\" Credential with the Name \"key\" and your <API key> as the Value \n"
},
"typeVersion": 1
},
{
"id": "d990d59b-f2f1-4ac5-b44f-a2d6bd323505",
"name": "Note Adhésive7",
"type": "n8n-nodes-base.stickyNote",
"position": [
896,
-128
],
"parameters": {
"color": 7,
"width": 1168,
"height": 416,
"content": "### Getting the Travel Time"
},
"typeVersion": 1
},
{
"id": "a556232d-d2c3-4c31-b999-fcebf43850ad",
"name": "Note Adhésive8",
"type": "n8n-nodes-base.stickyNote",
"position": [
1760,
-32
],
"parameters": {
"width": 246,
"height": 272,
"content": "### This passes on only the Travel_time to the Agent, saving on Tokens"
},
"typeVersion": 1
},
{
"id": "f6ffdca9-9c9a-4849-943c-d8cf4e9fab5e",
"name": "Note Adhésive9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1088,
-416
],
"parameters": {
"color": 6,
"width": 640,
"height": 1120,
"content": "## Automatically add Travel time blockers before Appointments\nThis bot automatically adds Travel time blockers to your calendar, so you never come late to an appointment again.\n\n\n## How it works\n* **Trigger**: The workflow is initiated daily at 7 AM by a \"Schedule Trigger\".\n* **AI Agent**: An \"AI Agent\" node orchestrates the main logic. \n* **Fetch events**: It uses the `get_calendar_events` tool to retrieve all events scheduled for the current day.\n* **Identify events with location**: It then filters these events to identify those that have a specified location.\n* **Check for existing travel time Blockers**: For each event with a location, it checks if a Travel time blocker already exists. Events that **do not** have such a blocker are marked for processing.\n* **Calculate travel time**: Using the `Google Directions API` it determines how lot it takes to get to the location of the event. The starting location is by default your **Home Address**, unless there is a previous event within 2 hours before the event, in which case it will use the location of that previous event.\n* **Create Travel time blocker**: Finally, it uses the `create_calendar_event` tool to create the Travel time blocker with a duration equal to the calculated travel time + 10 minutes for buffer.\n\n\n\n\n\n## Set up steps (Marked in red)\n1. Set Variables\n\t1. **Home address**\n\t2. **Blocker name**\n\t3. **Mode of Transportation**\n2. Connect your **LLM Provider**\n3. Connect your **Google Calendar**\n4. Connect your **Google Directions API**"
},
"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
}
]
]
}
}
}Comment utiliser ce workflow ?
Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.
Dans quelles scénarios ce workflow est-il adapté ?
Avancé - Productivité personnelle, Chatbot IA
Est-ce payant ?
Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.
Workflows recommandés
Kevin Armbruster
@kevin-armbrusterAutomation Consultant with a passion for Every day life improvements
Partager ce workflow