{
  "name": "Handle Gmail reply-based scheduling with Google Calendar and GPT-4o-mini",
  "nodes": [
    {
      "id": "85250e5d-ebdb-48ad-9d31-d0cb6bdba315",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        0
      ]
    },
    {
      "id": "718737fa-c29a-42a0-9e31-42d9db85b7e9",
      "name": "Sample Input",
      "type": "n8n-nodes-base.set",
      "position": [
        208,
        0
      ]
    },
    {
      "id": "42932d59-aa99-4811-932c-ad3d765707bf",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        416,
        0
      ]
    },
    {
      "id": "c089808a-bb75-4222-a4c0-54cf44e62819",
      "name": "Prepare Calendar Payload",
      "type": "n8n-nodes-base.set",
      "position": [
        768,
        0
      ]
    },
    {
      "id": "a2130e8b-a3bd-49f0-a0f5-7836edd7fb1d",
      "name": "Get availability in a calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        976,
        0
      ]
    },
    {
      "id": "1533ceca-cbf2-40f8-8ea8-07d5c6909606",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1184,
        0
      ]
    },
    {
      "id": "515f53f5-e5b0-44d0-af8c-5fc880fd93da",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1440,
        -80
      ]
    },
    {
      "id": "593abbaf-1371-4bff-ba81-971c7fcedf8d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -656
      ],
      "parameters": {
        "width": 800,
        "height": 432,
        "content": "## 📅 Smart Calendar Scheduling Workflow\n\nWhat this workflow does:\nThis workflow automatically checks Google Calendar availability and either creates a new event or sends a notification email if the ti"
      }
    },
    {
      "id": "79271e2b-ed4d-4604-be1d-04e0b9042e3d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        -144
      ],
      "parameters": {
        "width": 432,
        "height": 336,
        "content": "## Trigger & Input\nTrigger & input layer.\nStarts the workflow via webhook or test input.\nProvides initial data to the system.\n\n"
      }
    },
    {
      "id": "676d1d08-135a-4e4f-8b20-2f5316a30834",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        -144
      ],
      "parameters": {
        "width": 528,
        "height": 336,
        "content": "## AI & Data Preparation \nAI processing and data preparation.\nGenerates text and formats calendar payload.\nPrepares clean scheduling data.\n"
      }
    },
    {
      "id": "6425b9a1-c9a7-4d4f-b77c-7eab2b1e149b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        944,
        -144
      ],
      "parameters": {
        "width": 432,
        "height": 336,
        "content": "## Availability Decision \nAvailability check and decision logic.\nChecks if the time slot is free.\nRoutes the workflow based on the result.\n"
      }
    },
    {
      "id": "bc0fec80-0b96-4c7b-a44c-4909a374c805",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1408,
        -224
      ],
      "parameters": {
        "width": 256,
        "height": 512,
        "content": "## Final Action\nFinal action layer.\nCreates a calendar event or sends a notification email.\nCompletes the workflow.\n"
      }
    },
    {
      "id": "8c789449-402b-4ca7-b215-df7b90205544",
      "name": "Build Alternative Slots",
      "type": "n8n-nodes-base.set",
      "position": [
        1440,
        96
      ]
    },
    {
      "id": "fa1d5a39-5708-472f-92f6-7f94d2017ccc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        320
      ],
      "parameters": {
        "width": 2128,
        "height": 400,
        "content": "## Reply Handling (Optional Extension)\nThis section demonstrates how email replies can be handled\nas an extension to the main scheduling workflow in production.\n\nThis workflow showcases an end-to-end,"
      }
    },
    {
      "id": "cfee87c2-7ca5-470f-8842-18d742861a8a",
      "name": "Gmail Trigger (User Reply)",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        416,
        448
      ]
    },
    {
      "id": "8fb39df9-e27a-4d80-9235-7d8ef3f43a84",
      "name": "Normalize Incoming Reply",
      "type": "n8n-nodes-base.set",
      "position": [
        640,
        448
      ]
    },
    {
      "id": "eda359d7-e258-43c5-802e-b0a8fdd97790",
      "name": "Check Selected Option (1 or 2)",
      "type": "n8n-nodes-base.if",
      "position": [
        848,
        448
      ]
    },
    {
      "id": "61917f89-bc25-4ff7-9299-4afc33a94203",
      "name": "Prepare Confirmed Slot Data",
      "type": "n8n-nodes-base.set",
      "position": [
        1056,
        352
      ]
    },
    {
      "id": "403f331f-a4c2-48fc-9550-ee9ac303521c",
      "name": "Prepare Alternative Request",
      "type": "n8n-nodes-base.set",
      "position": [
        1056,
        544
      ]
    },
    {
      "id": "10cda059-c8da-427e-b1e8-22b1ef91f52c",
      "name": "Is Valid Confirmation",
      "type": "n8n-nodes-base.if",
      "position": [
        1264,
        448
      ]
    },
    {
      "id": "f51621df-fb61-4cfe-a73a-8632f3d545fc",
      "name": "Create Calendar Event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        1472,
        352
      ]
    },
    {
      "id": "3eaa536c-184f-4c79-9265-c928e267a291",
      "name": "Send Confirmation Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1680,
        448
      ]
    },
    {
      "id": "f24283fc-e9a5-4da2-bfbc-329fa3a8f625",
      "name": "Request Alternative Slots",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1472,
        544
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build Alternative Slots",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Sample Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample Input": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Prepare Calendar Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Calendar Event": {
      "main": [
        [
          {
            "node": "Send Confirmation Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Valid Confirmation": {
      "main": [
        [
          {
            "node": "Create Calendar Event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Request Alternative Slots",
            "type": "main",
            "index": 0
          },
          {
            "node": "Build Alternative Slots",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Incoming Reply": {
      "main": [
        [
          {
            "node": "Check Selected Option (1 or 2)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Calendar Payload": {
      "main": [
        [
          {
            "node": "Get availability in a calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger (User Reply)": {
      "main": [
        [
          {
            "node": "Normalize Incoming Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Alternative Request": {
      "main": [
        [
          {
            "node": "Is Valid Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Confirmed Slot Data": {
      "main": [
        [
          {
            "node": "Is Valid Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Selected Option (1 or 2)": {
      "main": [
        [
          {
            "node": "Prepare Confirmed Slot Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Alternative Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get availability in a calendar": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}