Automatic Focus Time Blocking in Google Calendar - n8n Workflow

Use this powerful n8n workflow to automatically analyze your upcoming week's calendar, identify busy days (6+ hours booked), and block dedicated focus time slots using n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Professionals struggling with calendar fragmentation and constant interruptions.

  • Users who rely on n8n automation to optimize personal and team productivity.

  • Anyone needing dedicated, uninterrupted deep work time on their busiest days.

  • Technical users looking for advanced n8n templates utilizing custom code for complex scheduling logic.

Overview

This n8n workflow solves the common problem of fragmented work time caused by excessive meetings. By running daily, this automation looks ahead at the full current week (Sunday to Saturday) and identifies any day where 6 or more hours of an 8-hour workday (defined as 9 AM to 5 PM) are already booked. If a day is deemed 'busy' based on this 6+ hour threshold, the workflow calculates the remaining open blocks—free slots of 15 minutes or more—and automatically creates 'Focus Time' events in your Google Calendar. This sophisticated n8n node combination ensures that high-priority deep work is scheduled precisely when your calendar is most demanding, maximizing efficiency and protecting your schedule. Use this powerful n8n template to regain control over your work week.

How it Works


  1. The n8n workflow is initiated daily at 8:00 AM by the Schedule Trigger n8n trigger node.

  2. It connects to Google Calendar via the Google Calendar n8n node to retrieve all events for the current Sunday-to-Saturday week.

  3. The crucial Calculate Full Week Focus Time Slots n8n node analyzes the data. It iterates through each day, calculates the booked time between 9 AM and 5 PM, and identifies days exceeding 6 hours of booked time.

  4. For those busy days, the custom code calculates all valid free slots (at least 15 minutes long) available for focused work.

  5. An IF n8n node checks the output to determine if any focus time slots were found (shouldCreateFocusTime is true).

  6. If slots exist, the Split Free Slots n8n node transforms the array of time slots into individual items.

  7. For every individual item, the final Google Calendar n8n node executes an 'Create' operation, blocking the time slot with a 'Focus Time' event.

  8. The process concludes by logging the outcome, whether focus time was created or skipped, providing full transparency of the n8n workflow execution.

Installation Guide


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Google Calendar Credentials: This n8n workflow requires Google Calendar API credentials. Click on the 'Get Full Week Events' and 'Create Focus Time Event' n8n node and update the 'Google Calendar OAuth2 API' credential with your connected Google account.

  3. Activate: Ensure the workflow is set to 'Active' to start running daily according to the schedule trigger (default: 8:00 AM). You may need to manually adjust the time in the 'Schedule Trigger' n8n trigger node parameters if your workday starts earlier or later.

  4. Review Custom Code: Review the logic in the 'Calculate Full Week Focus Time Slots' n8n node if you need to adjust the 9 AM to 5 PM workday window or the 6-hour busy threshold.

Node Details

Schedule Trigger n8n trigger: Sets the execution schedule. It runs every day at 8:00 AM (0 8 ).
Google Calendar (Get Full Week Events) n8n node: Authenticates with Google and fetches all calendar events from the 'Primary' calendar to analyze the weekly load.
Calculate Full Week Focus Time Slots (Code n8n node): Contains the complex logic to calculate booked time and identify free slots. Key settings include:
Work window: 9:00 AM to 5:00 PM.
Busy threshold: 6+ hours booked required to trigger focus time creation.
Minimum slot duration: 15 minutes.
Should Create Focus Time? (IF n8n node): A core logic n8n node that directs the flow based on the custom code's shouldCreateFocusTime output.
Split Free Slots (Item Lists n8n node): Splits the array of calculated focus slots so each slot can be handled individually by the subsequent 'Create Event' n8n node.
Create Focus Time Event (Google Calendar n8n node): Uses the output from the split items to create new calendar events titled 'Focus Time' on the respective busy day.


  • Log Results (Code n8n node): Logs successful event creation and skipped executions, aiding in monitoring this specialized n8n workflow.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by
Moe Ahad
Moe Ahad

Featured*