// 30-min buildsby JoshMay 3, 20265 min read

Build a Calendar-Blocker AI Agent in 30 Minutes

An agent that finds open blocks in your week, protects deep-work time, and pushes back when meetings creep in. Build it today without writing real code.

Build a Calendar-Blocker AI Agent in 30 Minutes

The build: every Sunday night, an agent reviews your upcoming week, identifies open 2+ hour blocks, and books them as "deep work" with descriptive titles. Meetings that try to overwrite get a polite decline that proposes alternatives.

Total time: 30 minutes.

What you'll need

  • -Google Calendar (or other major calendar with API access)
  • -n8n
  • -AI API key

Step 1: Sunday trigger (2 min)

n8n cron node. Fire every Sunday at 8 PM.

Step 2: Fetch the week (5 min)

Add a Google Calendar node. Action: get events. Range: next Monday through next Friday (or whatever week you protect).

Step 3: Find open blocks (10 min)

Add a Code node that processes the events and finds gaps:

```javascript const events = $input.first().json; const workdays = [/* Monday-Friday next week, as Date objects */]; const blocks = [];

workdays.forEach(day => { const dayStart = new Date(day); dayStart.setHours(9, 0, 0); const dayEnd = new Date(day); dayEnd.setHours(17, 0, 0);

const dayEvents = events.filter(e => new Date(e.start.dateTime) >= dayStart && new Date(e.end.dateTime) <= dayEnd ).sort((a, b) => new Date(a.start.dateTime) - new Date(b.start.dateTime));

let cursor = dayStart; dayEvents.forEach(e => { const eventStart = new Date(e.start.dateTime); const gap = (eventStart - cursor) / (1000 * 60); // minutes if (gap >= 120) { blocks.push({ start: new Date(cursor), end: eventStart }); } cursor = new Date(e.end.dateTime); }); // Final gap until end of day if ((dayEnd - cursor) / (1000 * 60) >= 120) { blocks.push({ start: new Date(cursor), end: dayEnd }); } });

return [{ json: { blocks } }]; ```

Step 4: AI generates titles (5 min)

For each block, generate a meaningful "deep work" title. AI prompt:

``` Generate a calendar block title for a focused work session.

Duration: {{ duration_minutes }} minutes Day of week: {{ day }} Time of day: {{ time }} My current project priorities: {PROJECT_LIST}

Return ONE specific title (5-10 words) that names a likely focus area. Make it sound like work, not like a break.

Examples of good titles: - "Deep work: prometheus content batch" - "Build: card-executor pipeline" - "Writing: weekly newsletter draft"

NOT acceptable: - "Deep work" - "Focus time" - "Personal" ```

The specificity is the magic. "Deep work: prometheus content batch" makes meetings more likely to schedule around it. "Focus time" gets overwritten.

Step 5: Create the blocks (5 min)

Add a Google Calendar "Create event" node. Loop through the blocks array (Split In Batches node). Create each event with the AI-generated title.

Set the events to "Busy" status. Add a description: "Auto-blocked by calendar agent. Move or delete if needed."

Step 6: Test (3 min)

Run the workflow manually. Check Google Calendar for next week. Verify blocks landed.

Delete any blocks you don't want.

Common gotchas

  • -Time zones: Google Calendar API expects RFC3339 timestamps with explicit TZ. Use ISO strings with the correct offset.
  • -Recurring events overlap detection is tricky. The basic version above doesn't handle them perfectly. Refine if you need it.
  • -The agent will compete with manual blocks you create. That's the point.

What I do with this

Sunday night the agent maps my week. I get a Slack notification with the proposed blocks. I approve or adjust.

Monday morning I have 6-12 hours of deep work already on my calendar, named specifically. When meeting requests come in, I see them next to real work I've already committed to, not next to white space.

Meeting count dropped 35% in the first month. Not because I declined more (the count of meetings I accepted is roughly the same). Because fewer were proposed once the calendar looked busy.

What to add next

  • -Auto-decline meetings that overlap with blocks, with a polite alternative
  • -Different block strategies (deep work, admin, meetings, recovery)
  • -Energy-aware scheduling (deep work in morning if you're a morning person)
  • -Weekly review of which blocks actually held

Don't over-engineer. The Sunday night auto-block is 80% of the value.

calendaragentgoogle calendarautomation30 min build
// go deeper

Want the full guide? Check out our deep-dive page for more context, FAQs, and resources.

read the full guide
// keep reading

Related posts

// ready to ship?

Let's build yours.

Reading is the easy part. We do the work. Tell us what's broken and we'll tell you straight up whether we can help.