{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "1sFdjPm5ThEp7IX7gCfKalzPf7Tv2Y6JgABA8A5eph0c",
          "mode": "list",
          "cachedResultName": "AI Appointment Booking Form (Responses)",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sFdjPm5ThEp7IX7gCfKalzPf7Tv2Y6JgABA8A5eph0c/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 1965201089,
          "mode": "list",
          "cachedResultName": "Form Responses 1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1sFdjPm5ThEp7IX7gCfKalzPf7Tv2Y6JgABA8A5eph0c/edit#gid=1965201089"
        },
        "event": "rowAdded",
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        -816,
        -48
      ],
      "id": "9afd3bba-1ce9-4dff-8796-ed7c486888f1",
      "name": "Google Sheets Trigger",
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "calendar": {
          "__rl": true,
          "value": "akarshraj01052006@gmail.com",
          "mode": "list",
          "cachedResultName": "akarshraj01052006@gmail.com"
        },
        "start": "={{ DateTime.fromFormat($('Edit Fields').item.json.appointmentDateTime, \"M/d/yyyy h:mm a\").toISO() }}",
        "end": "={{ DateTime.fromFormat($('Edit Fields').item.json.appointmentDateTime, \"M/d/yyyy h:mm a\").plus({ hours: 1 }).toISO() }}",
        "additionalFields": {
          "description": "=Name: {{ $('Google Sheets Trigger').item.json['Full Name'] }}  Email: {{ $('Google Sheets Trigger').item.json['Email Address'] }}  Phone: {{ $('Google Sheets Trigger').item.json['Phone Number'] }}  Reason:{{ $('Google Sheets Trigger').item.json['Reason for Appointment'] }} }}",
          "summary": "=Appointment - Appointment - {{ $('Google Sheets Trigger').item.json['Full Name'] }}"
        }
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        128,
        -176
      ],
      "id": "39610a0e-21a8-4f14-848e-4750010b8628",
      "name": "Create an event",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Google Sheets Trigger').item.json['Email Address'] }}",
        "subject": "Appointment Confirmation",
        "message": "={{ $json.content.parts[0].text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        656,
        -176
      ],
      "id": "98994635-e25b-45e1-8005-403f0e846798",
      "name": "Send a message",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-flash-preview"
        },
        "messages": {
          "values": [
            {
              "content": "=Generate a professional appointment confirmation email.\n\nCustomer Name: {{ $('Google Sheets Trigger').item.json['Full Name'] }}\nAppointment Date: {{ $('Google Sheets Trigger').item.json['Preferred Date'] }}\nAppointment Time: {{ $('Google Sheets Trigger').item.json['Preferred Time'] }}\n\nKeep the email friendly and professional.\n\nDo not include a subject line.\nReturn only the email body."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.2,
      "position": [
        336,
        -176
      ],
      "id": "2cb54b0d-e5b2-482c-9f39-05441c07b041",
      "name": "Message a model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "calendar",
        "calendar": {
          "__rl": true,
          "value": "akarshraj01052006@gmail.com",
          "mode": "list",
          "cachedResultName": "akarshraj01052006@gmail.com"
        },
        "timeMin": "={{ DateTime.fromFormat($json.appointmentDateTime, \"M/d/yyyy h:mm a\").toISO() }}",
        "timeMax": "={{ DateTime.fromFormat($json.appointmentDateTime, \"M/d/yyyy h:mm a\").plus({ hours: 1 }).toISO() }}",
        "options": {}
      },
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [
        -352,
        -48
      ],
      "id": "42327a56-84b5-4b5a-be7c-d9ddbcd10f87",
      "name": "Get availability in a calendar",
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 3
          },
          "conditions": [
            {
              "id": "bb88cb2f-ba50-489d-8f39-587fbfe0bac1",
              "leftValue": "={{$json.available}}",
              "rightValue": "true",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -160,
        -48
      ],
      "id": "98422026-7efa-472e-879f-503669339bab",
      "name": "If"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-flash-preview"
        },
        "messages": {
          "values": [
            {
              "content": "=Generate a polite appointment unavailability email.\n\nCustomer Name: {{ $('Google Sheets Trigger').item.json['Full Name'] }}\n\nInform the customer that the selected appointment slot is already booked.\nAsk them to select another date or time.\n\nKeep the tone professional and friendly.\n\nReturn only the email body."
            }
          ]
        },
        "builtInTools": {},
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "typeVersion": 1.2,
      "position": [
        96,
        144
      ],
      "id": "4080eeaf-6c7a-424f-9a7a-4ef5391faee6",
      "name": "Message a model1",
      "retryOnFail": true,
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "={{ $('Google Sheets Trigger').item.json['Email Address'] }}",
        "subject": "Appointment Slot Unavailable",
        "message": "={{ $json.content.parts[0].text }}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        480,
        144
      ],
      "id": "eed186a8-450c-4012-8a99-794e153e655e",
      "name": "Send a message1",
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "212da1a6-5e8c-4b83-a6f8-d9f04b83c427",
              "name": "appointmentDateTime",
              "value": "={{ $json[\"Preferred Date\"] + \" \" + $json[\"Preferred Time\"] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -576,
        -48
      ],
      "id": "da75757f-b652-41d9-8bc8-1e1610f6a918",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get availability in a calendar": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Message a model1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model1": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Get availability in a calendar",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "37a8c122-d869-4437-8040-814d999a9b64",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "OndJK5lK4Q15yoL1",
  "tags": []
}