{
  "id": "VF6PzqKpoe5DTKoL",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Create Google Calendar events from labeled Gmail emails using AI",
  "tags": [],
  "nodes": [
    {
      "id": "64518e77-91fe-40ee-b5c8-94daf87cdd26",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        -340
      ],
      "parameters": {
        "color": 1,
        "width": 700,
        "height": 700,
        "content": "## Create Google Calendar events from labeled Gmail emails using AI\n\nThis workflow automates the process of creating Google Calendar events from emails you label in Gmail, using AI to parse the details.\n\n## Who is it for?\nThis template is for anyone who frequently receives unstructured event or task information via email and wants to quickly add it to their Google Calendar without manual data entry. It's perfect for busy professionals, personal productivity enthusiasts, and anyone looking to streamline their scheduling.\n\n## What it does\n1.  **Triggers on Labeled Email**: The workflow starts when a new email is given a specific label in Gmail (e.g., \"Scheduled\").\n2.  **Parses Event with AI**: The email's content is sent to Google Gemini to extract structured event data: title, start time, end time, location, and a description.\n3.  **Creates Calendar Event**: Using the data extracted by the AI, a new event is automatically created in your Google Calendar.\n4.  **Sends Confirmation Email**: A confirmation email is sent back to you, containing a summary of the created event, a direct link to edit it in Google Calendar, and the original email content for reference.\n\n## Requirements\n- A Google account for Gmail and Google Calendar.\n- Credentials for the Google Gemini API.\n- An active n8n instance.\n\n## How to set up\n1.  **Credentials**: Configure your credentials for the 'Gmail Trigger', 'Google Gemini Chat Model', 'Create Google Calendar Event', and 'Send Confirmation Email' nodes.\n2.  **Gmail Trigger**: Select the 'Gmail Trigger' node. In the 'Label Ids' field, choose the Gmail label you want to use to trigger the workflow (e.g., a label named `Scheduled`).\n3.  **Confirmation Email**: Select the 'Send Confirmation Email' node. In the 'Send To' field, enter the email address where you want to receive the confirmation email (e.g., `YOUR_EMAIL_ADDRESS@example.com`).\n4.  **Activate Workflow**: Save and activate the workflow.\n\n## How to customize\n- **AI Prompt**: You can modify the prompt in the 'Parse Event with AI' node to better suit your needs. For example, you can change the default timezone (`JST (UTC+9)`) or add rules for how to handle recurring events.\n- **Email Content**: Customize the subject and body of the confirmation email in the 'Send Confirmation Email' node.\n- **Calendar Options**: In the 'Create Google Calendar Event' node, you can add more event details, such as attendees or reminders."
      }
    },
    {
      "id": "47fd7701-2381-442f-9cdc-349d483c8c64",
      "name": "Create Google Calendar Event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        896,
        304
      ],
      "parameters": {
        "end": "={{ $json.output.end.dateTime }}",
        "start": "={{ $json.output.start.dateTime }}",
        "calendar": {
          "__rl": true,
          "mode": "id",
          "value": "primary"
        },
        "additionalFields": {
          "summary": "={{ $json.output.summary }}",
          "location": "={{ $json.output.location }}",
          "description": "={{ $json.output.description }}"
        }
      }
    },
    {
      "id": "14a3e816-9995-44f6-8679-0ba3318dd515",
      "name": "Send Confirmation Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1120,
        304
      ],
      "parameters": {
        "sendTo": "YOUR_EMAIL_ADDRESS",
        "message": "=<html><body>\n    <p>An event has been created in your Google Calendar with the following details.</p>\n    <hr>\n    <h2>Event Summary:</h2>\n    <p><strong>Title:</strong> {{ $json.summary }}</p>\n    <p><strong>Time:</strong> {{ new Date($json.start.dateTime).toLocaleString() }} - {{ new Date($json.end.dateTime).toLocaleString() }}</p>\n    <p><strong>Location:</strong> {{ $json.location }}</p>\n    <p><strong>Description:</strong><br>{{ $json.description.replace(/\\n/g, '<br>') }}</p>\n    <p><a href=\"{{ $json.htmlLink }}\">Edit in Google Calendar</a></p>\n    <hr>\n    <h2>Original Email Content:</h2>\n    <pre>{{ $json.description }}</pre>\n</body></html>",
        "options": {
          "attachmentsUi": {
            "values": []
          },
          "appendAttribution": false
        },
        "subject": "=Event Created in Google Calendar: {{ $json.summary }}"
      }
    },
    {
      "id": "afd18080-dbe2-402d-8e0f-1cb1439dcc1c",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        272,
        304
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "labelIds": []
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "2da76e21-c4cb-4a50-83a9-e8575fbeb416",
      "name": "Parse Event with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        496,
        304
      ],
      "parameters": {
        "text": "=Extract the Google Calendar event information from the following email content into JSON format.\n\nJSON format:\n{\n  \"summary\": \"Event title (e.g., Meeting, Appointment, Task)\",\n  \"start\": { \"dateTime\": \"YYYY-MM-DDTHH:MM:SS+09:00\" },\n  \"end\": { \"dateTime\": \"YYYY-MM-DDTHH:MM:SS+09:00\" },\n  \"location\": \"Location (e.g., URL for online meetings, Meeting Room A, Cafe)\",\n  \"description\": \"Detailed description of the event (should contain the original email content)\"\n}\n\nIf the date and time are not explicit, infer them based on the current time or set the most likely period. Use 24-hour format for time. Please ensure the timezone is correct for your location (e.g., change 'JST (UTC+9)' if needed). The location is optional.\n\nEmail content:\n{{$json[\"text\"]}}",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.1
    },
    {
      "id": "b53b7775-c167-442e-be5d-c4f60e546b69",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        656,
        528
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"summary\": \"Event title (e.g., Meeting, Appointment, Task)\",\n  \"start\": { \"dateTime\": \"YYYY-MM-DDTHH:MM:SS+09:00\" },\n  \"end\": { \"dateTime\": \"YYYY-MM-DDTHH:MM:SS+09:00\" },\n  \"location\": \"Location (e.g., URL for online meetings, Meeting Room A, Cafe)\",\n  \"description\": \"Detailed description of the event (e.g., the original email content)\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "89203420-d082-4f9e-b7cf-1338564a9804",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        528,
        528
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "4a13fd28-3b5c-4bec-9989-fd5543f90131",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        208
      ],
      "parameters": {
        "width": 224,
        "height": 256,
        "content": "## 1. Email Trigger"
      },
      "typeVersion": 1
    },
    {
      "id": "d50510c0-7d34-4730-9c63-bbe77b3d2436",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        472,
        208
      ],
      "parameters": {
        "width": 320,
        "height": 256,
        "content": "## 2. Parse Event with AI"
      },
      "typeVersion": 1
    },
    {
      "id": "c40078b0-cf09-458c-9b42-4436771c299b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        208
      ],
      "parameters": {
        "width": 224,
        "height": 256,
        "content": "## 3. Create Calendar Event"
      },
      "typeVersion": 1
    },
    {
      "id": "ead2ae4f-28c8-4473-8192-2fbaf6c3ac83",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1088,
        208
      ],
      "parameters": {
        "width": 224,
        "height": 256,
        "content": "## 4. Send Confirmation Email"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "27ede62c-79ed-4e33-b0e5-7d5bea5a21e1",
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Parse Event with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Event with AI": {
      "main": [
        [
          {
            "node": "Create Google Calendar Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Parse Event with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Parse Event with AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Create Google Calendar Event": {
      "main": [
        [
          {
            "node": "Send Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}