{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "336b2a72-50e8-4e0f-a621-e2c8e5fad881",
      "name": "Create an event",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        3984,
        1936
      ],
      "parameters": {
        "end": "={{ $json.Due_Date.toDateTime().plus({ hours: 1 }).toISO() }}",
        "start": "={{ $json.Due_Date }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_CALENDAR_ID",
          "cachedResultName": "n8n"
        },
        "additionalFields": {
          "description": "={{ $json.Task_Name }}"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "ea832095-5aae-49bc-962f-ac501c2ff897",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        3760,
        2064
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "15207622-619c-43d9-8800-fef9aad05f81",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('Check Availability').item.json.available }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "3938a3d5-f8be-40a5-bc63-ab4834420a91",
      "name": "Get Task",
      "type": "n8n-nodes-base.notionTrigger",
      "position": [
        3088,
        2064
      ],
      "parameters": {
        "event": "pagedUpdatedInDatabase",
        "simple": false,
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_NOTION_DATABASE_ID",
          "cachedResultUrl": "https://www.notion.so/3358ea89341280aab826fd90d7f85931",
          "cachedResultName": "Tasks Tracker"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "67707a7a-caff-46f5-bae7-e1285b64d137",
      "name": "Check Availability",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        3312,
        2064
      ],
      "parameters": {
        "options": {},
        "timeMax": "={{ $json.properties['Due date'].date.start.toDateTime().plus(1, 'hours').toISO() }}",
        "timeMin": "={{ $json.properties['Due date'].date.start }}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_CALENDAR_ID",
          "cachedResultName": "n8n"
        },
        "resource": "calendar"
      },
      "typeVersion": 1.3
    },
    {
      "id": "db2b9128-8595-454d-a6fd-6281f2161ddb",
      "name": "Record",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3536,
        2064
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Get Task').item.json.id }}",
            "Due_Date": "={{ $('Get Task').item.json.properties['Due date'].date.start }}",
            "Priority": "={{ $('Get Task').item.json.properties.Priority.select.name }}",
            "Task_Name": "={{ $('Get Task').item.json.properties['Task name'].title[0].text.content }}",
            "Created_By": "={{ $('Get Task').item.json.created_by.id }}",
            "Avaliabilty": "0",
            "Database_ID": "={{ $('Get Task').item.json.parent.database_id }}",
            "Created_Time": "={{ $('Get Task').item.json.created_time }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_Time",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created_Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_By",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created_By",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Database_ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Database_ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Task_Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Task_Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Priority",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Priority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Due_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Avaliabilty",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Avaliabilty",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Notion Calender Pipeline"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e25a5ebc-5104-460d-b071-05f27bb4298c",
      "name": "Send Error",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3984,
        2224
      ],
      "parameters": {
        "sendTo": "YOUR_GMAIL_RECIPIENT_EMAIL",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <style>\n        body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; line-height: 1.6; color: #333333; margin: 0; padding: 0; }\n        .container { max-width: 600px; margin: 20px auto; padding: 20px; border: 1px solid #e0e0e0; border-radius: 8px; }\n        .header { border-bottom: 2px solid #f4f4f4; padding-bottom: 10px; margin-bottom: 20px; }\n        .title { color: #d93025; font-size: 20px; font-weight: bold; }\n        .details-box { background-color: #f9f9f9; padding: 15px; border-radius: 6px; margin: 20px 0; border-left: 4px solid #d93025; }\n        .label { font-weight: bold; color: #555555; text-transform: uppercase; font-size: 12px; }\n        .footer { font-size: 12px; color: #888888; margin-top: 30px; text-align: center; }\n        .button { background-color: #000000; color: #ffffff; padding: 12px 20px; text-decoration: none; border-radius: 5px; display: inline-block; margin-top: 10px; }\n    </style>\n</head>\n<body>\n    <div class=\"container\">\n        <div class=\"header\">\n            <div class=\"title\">\u26a0\ufe0f Calendar Conflict Detected</div>\n        </div>\n        \n        <p>Hi there,</p>\n        \n        <p>While syncing your <strong>Notion</strong> tasks, we found a scheduling conflict on your Google Calendar. The following task cannot be scheduled at the requested time:</p>\n\n        <div class=\"details-box\">\n            <div class=\"label\">Notion Task</div>\n            <div style=\"margin-bottom: 10px; font-size: 16px;\">{{ $('Get Task').item.json.properties['Task name'].title[0].plain_text }}\n</div>\n            \n            <div class=\"label\">Scheduled Time</div>\n            <div style=\"font-size: 16px;\">\n</div>{{ $('Get Task').item.json.properties['Due date'].date.start }}\n        </div>\n\n        <p>Please visit your Notion database to adjust the time, or check your Google Calendar to clear the existing appointment.</p>\n        \n        <a href=\"{{ $('Get Task').item.json.url }} \" class=\"button\">Open Notion</a>\n\n        <div class=\"footer\">\n            Sent automatically via your n8n workflow.\n        </div>\n    </div>\n</body>\n</html>",
        "options": {},
        "subject": "Your Task clashes with existing plans"
      },
      "typeVersion": 2.2
    },
    {
      "id": "15dc57c4-9b30-45c0-8202-045af5185a6c",
      "name": "Update Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4192,
        1936
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Get Task').item.json.id }}",
            "Avaliabilty": "=True"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_Time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Created_Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_By",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Created_By",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Database_ID",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Database_ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Task_Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Task_Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Priority",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Priority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due_Date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Due_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Avaliabilty",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Avaliabilty",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Notion Calender Pipeline"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "514f07c4-fb8d-4055-81b5-0b8dbedbb047",
      "name": "Update Status1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4192,
        2224
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $('Get Task').item.json.id }}",
            "Avaliabilty": "False"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_Time",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Created_Time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_By",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Created_By",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Database_ID",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Database_ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Task_Name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Task_Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Priority",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Priority",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due_Date",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Due_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Avaliabilty",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Avaliabilty",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_GOOGLE_SHEETS_DOCUMENT_ID",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/YOUR_GOOGLE_SHEETS_DOCUMENT_ID/edit?usp=drivesdk",
          "cachedResultName": "Notion Calender Pipeline"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9eec72c1-b292-4661-a41e-46f6cd918fbb",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        1840
      ],
      "parameters": {
        "width": 480,
        "height": 576,
        "content": "## Notion Task \u2192 Google Calendar Sync\n\n### How it works\nThis workflow automatically syncs tasks from your Notion database to Google Calendar. When a task is created or updated, the workflow checks if the selected time slot is available in your calendar. It logs the task data into Google Sheets for tracking and then uses a conditional check to determine the next step.\n\nIf the time slot is available, the workflow creates a new calendar event and updates the status as successful. If there is a conflict, it sends an email notification and updates the record as failed. This ensures you never double-book your schedule and always have visibility into sync status.\n\n### Setup steps\n1. Connect your Notion, Google Calendar, Google Sheets, and Gmail accounts.\n2. Select your Notion database and ensure it includes a date field.\n3. Configure the Google Calendar node with your target calendar.\n4. Map the Google Sheets columns correctly (ID, Task Name, Due Date, Status).\n5. Set the IF node to check if no events exist (availability = true).\n6. Customize the Gmail node recipient and message if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "d138dfa5-46b3-4ec1-a6aa-a150c91b3653",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3056,
        1840
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 576,
        "content": "## Step 1: Fetch & Check\nTrigger + calendar availability check"
      },
      "typeVersion": 1
    },
    {
      "id": "d68a90e0-a95b-4b95-8c1c-443311872134",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3488,
        1840
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 576,
        "content": "## Step 2: Log & Decide\nStore data and evaluate availability"
      },
      "typeVersion": 1
    },
    {
      "id": "40e1f7b3-a568-40b2-875f-174c51e4d990",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3936,
        1840
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 272,
        "content": "## Step 3: Create Event\nAdd event and mark as synced"
      },
      "typeVersion": 1
    },
    {
      "id": "71fdf13f-2143-420c-be11-671c53eb0b8c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3936,
        2128
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 288,
        "content": "## Step 4: Handle Conflict\nSend alert and mark as failed"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Create an event",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Record": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Task": {
      "main": [
        [
          {
            "node": "Check Availability",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Error": {
      "main": [
        [
          {
            "node": "Update Status1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create an event": {
      "main": [
        [
          {
            "node": "Update Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Availability": {
      "main": [
        [
          {
            "node": "Record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}