Automate Email Appointment Scheduling Using n8n and OpenAI

Discover how this n8n workflow automates reading appointment requests from Gmail, checks calendar availability, and sends tailored replies, saving hours weekly and avoiding missed meetings.
gmailTrigger
lmChatOpenAi
googleCalendar
+11
Learn how to Build this Workflow with AI:
Workflow Identifier: 1366
NODES in Use: gmailTrigger, lmChatOpenAi, chainLlm, outputParserStructured, if, googleCalendar, filter, set, itemLists, agent, gmail, executeWorkflowTrigger, toolWorkflow, stickyNote

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Sarah, a busy executive assistant who manages her manager’s emails and calendar. Every day, Sarah receives numerous appointment requests via Gmail. Sorting through these emails manually to check availability on Google Calendar is time-consuming — often taking her 2-3 hours daily just to handle scheduling. Missed details or delays result in double bookings or lost meeting opportunities, causing frustration and wasted resources.

This is the exact scenario our Calendar_scheduling n8n workflow solves. It automates processing incoming Gmail appointment requests by evaluating email content, checking calendar availability, and responding with tailored meeting proposals, all without Sarah lifting a finger.

2. What This Automation Does

When this workflow runs, here’s what happens:

  • Monitors unread Gmail emails in real-time, focusing on potential meeting requests.
  • Uses OpenAI GPT-4 to analyze email subject and snippets, determining if the email is about scheduling an appointment.
  • Fetches Google Calendar events up to one month ahead to understand current availability and confirmed meetings.
  • Processes calendar data to extract, sort, and format confirmed appointments with detailed start and end times.
  • Leverages OpenAI as an agent to craft a personalized reply proposing specific available slots, considering a 15-minute buffer between meetings.
  • Automatically sends a reply email via Gmail with the suggested times, and marks the original email as read to keep inbox clean.

This workflow can save Sarah at least 10+ hours weekly by eliminating manual calendar cross-checking and email drafting. It also reduces human error and ensures no appointment requests slip through unnoticed.

3. Prerequisites ⚙️

  • Gmail account with OAuth2 credentials enabled in n8n 📧
  • Google Calendar account connected via OAuth2 for reading calendar events 📅
  • OpenAI API key configured for GPT-4 access 🔑
  • n8n automation platform account (cloud or self-hosted) ⏱️

If you prefer self-hosting n8n, you can explore options with providers like Hostinger to get started.

4. Step-by-Step Guide to Build This Workflow

Step 1: Set Up Gmail Trigger to Monitor Incoming Emails

Navigate to the nodes panel in n8n, click Add Node, then search and select Gmail Trigger. Configure it to monitor unread inbox emails every minute by setting the filter to readStatus: unread and polling interval to everyMinute.

Connect your Gmail account via OAuth2. This ensures the workflow activates as soon as a new unread email arrives.

Visual: You’ll see the node labeled “Gmail Trigger” with parameters for filtering unread emails.

Common mistake: Forgetting to authenticate the Gmail account will prevent the node from triggering.

Step 2: Classify Incoming Emails Using OpenAI Language Model

Add the Classify appointment node using the LangChain Chain LLM node type. Configure the prompt:

=Please evaluate the following email to determine if it suggests scheduling a meeting or a call:
Subject: {{ encodeURI($json.Subject) }}
Snippet: {{ encodeURI($json.snippet) }}
Indicate your assessment by responding with "true" if it suggests a meeting or call, or "false" otherwise. Use lowercase for your response.

Connect this node directly from the Gmail Trigger node. It sends the email subject and snippet to OpenAI GPT-4 for classification.

Outcome: The workflow will receive a boolean flag indicating if the email is a scheduling request.

Common mistake: Not using URLEncoding in the prompt can cause errors with special characters in email text.

Step 3: Parse Structured Output From OpenAI

Insert a Structured Output Parser node configured with this JSON schema:

{
 "type": "object",
 "properties": {
 "is_appointment": {
 "type": "boolean"
 }
 }
}

This steps converts raw GPT output into usable JSON with an is_appointment boolean property. Connect it from the LLM node.

Step 4: Branch Workflow Based on Appointment Detection

Add an If node named Is appointment request to check if $json.is_appointment is true. Use the condition:

  • string: $json.is_appointment == true

Only proceed downstream if the condition holds. This avoids unnecessary processing of unrelated emails.

Step 5: Fetch Google Calendar Events

From the Execute Workflow Trigger node, call the Google Calendar node configured to fetch all single events starting from yesterday’s date to one month ahead. Parameters include:

  • timeMin = {{ $now.minus(1, 'day').toISO() }}
  • timeMax = {{ $now.plus(1, 'month').toISO() }}
  • returnAll = true
  • calendar set to your Gmail calendar ID

This provides complete visibility of upcoming and recent appointments.

Common mistake: Not setting the correct calendar ID leads to empty or wrong data.

Step 6: Filter Confirmed Calendar Events with Set Times

Use a Filter node to keep only those events marked as “confirmed” and that have a valid start.dateTime field.

This ensures tentative or all-day events are excluded from scheduling decisions.

Step 7: Extract and Format Date-Time and Event Name

Next, a Set node called Extract start, end and name processes each event to pull readable date-time strings and the event’s summary:

{
 "start": "={{ DateTime.fromISO($json.start.dateTime).toLocaleString(DateTime.DATE_HUGE) }}, {{ DateTime.fromISO($json.start.dateTime).toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET) }}",
 "end": "={{ DateTime.fromISO($json.end.dateTime).toLocaleString(DateTime.DATE_HUGE) }}, {{ DateTime.fromISO($json.end.dateTime).toLocaleString(DateTime.TIME_24_WITH_SHORT_OFFSET) }}",
 "name": "={{ $json.summary }}",
 "sort": "={{ $json.start.dateTime }}"
}

This prepares data for sorting and display.

Step 8: Sort Calendar Events Chronologically

Employ an Item Lists node with “sort” operation on the “sort” field to order events by start date and time.

Sorted events provide a timeline for the scheduling agent.

Step 9: Aggregate and Format Response Object

Use another Item Lists node set to concatenate all items into a single “response” object that the AI agent will reference.

Follow this with a Set node to stringify the response JSON for passing to the OpenAI agent.

Step 10: Launch OpenAI Scheduling Agent

Add the Agent node using the LangChain Agent node type. Configure the system message to instruct the AI to:

  • Act as an email scheduling assistant
  • Refer to calendar availability JSON
  • Propose specific meeting times with 15-minute buffers
  • Always offer alternative slots if unavailable

Connect the workflow tool node “Calendar_Availability” to provide real-time calendar data during the agent’s decision-making.

Step 11: Reply to Sender and Mark Email as Read

Finally, use the Send Reply Gmail node to send the crafted email response to the original sender, replying only to the sender.

In parallel, use the Mark as Read node to mark the original email as read, keeping the inbox tidy.

5. Customizations ✏️

  • Change calendar response timeframe: In the Google Calendar node, adjust timeMax and timeMin to extend or shorten availability windows.
  • Tune AI creativity: Modify the temperature parameter in the Chat OpenAI models for more or less creative email content generation.
  • Add additional email filters: In the Gmail Trigger node, add filters, such as sender domain or subject keywords, to focus only on relevant appointment emails.
  • >

  • Change buffer time: Update the system message in the Agent node to request a different buffer duration between meetings (currently 15 minutes).
  • Integrate multiple calendars: Set up separate Google Calendar nodes for different calendars and combine results for multi-calendar availability checks.

6. Troubleshooting 🔧

Problem: “Gmail Trigger not firing despite new emails arriving.”
Cause: Gmail OAuth credentials expired or permissions missing.
Solution: Reconnect Gmail OAuth in n8n Credentials panel and ensure permissions include reading emails.

Problem: “OpenAI returns unexpected output or errors.”
Cause: Prompt formatting issues or API key limits exceeded.
Solution: Verify prompt syntax, ensure prompt uses URI encoding for email content, and monitor API usage.

Problem: “No calendar events fetched.”
Cause: Incorrect calendar ID or OAuth token expired.
Solution: Check Google Calendar node calendar configuration and refresh OAuth token.

7. Pre-Production Checklist ✅

  • Verify Gmail Trigger is connected and linked to the correct inbox filtering unread messages
  • Test Classify appointment node with sample meeting and non-meeting emails
  • Check Google Calendar node returns correct events for the intended calendar
  • Perform a dry run to confirm replies are correctly formatted and sent
  • Ensure OpenAI API keys have sufficient quota and permissions
  • Back up n8n workflow and credentials before going live

8. Deployment Guide

Activate the workflow by toggling the active switch in the n8n editor once all nodes are configured and tested.

Monitor execution logs in n8n for errors or failed runs in the initial days.

Review the inbox regularly to ensure replies are accurate and timely.

9. FAQs

  • Q: Can I use another calendar service like Outlook?
    A: This workflow is designed for Google Calendar; however, you could adapt it using n8n’s Outlook Calendar node with similar logic.
  • Q: Does OpenAI use up a lot of API credits?
    A: Each email classification and reply generation consumes API calls, so optimize prompts for cost-efficiency and monitor usage.
  • Q: Is my email data safe?
    A: n8n runs on your environment and connections use OAuth2, minimizing security risks. Always ensure credentials are stored safely.

10. Conclusion

By implementing this specific n8n workflow, Sarah has transformed a 2-3 hour daily chore into a hands-off process, gaining back precious time and reducing booking errors. This automation not only boosts productivity but also improves communication professionalism through tailored replies.

Next, consider expanding this by integrating SMS reminders, or syncing to CRM tools for seamless appointment records. With this solid base, your scheduling challenges become a thing of the past.

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free