{
  "name": "Monitor file changes with Google Drive push notifications",
  "nodes": [
    {
      "id": "d8c73782-4560-4cce-bd59-767defcf3317",
      "name": "Set Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -2576,
        320
      ]
    },
    {
      "id": "e3f4a25d-f75a-49f3-b935-8822e9465f87",
      "name": "Get StartPageToken",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1856,
        144
      ]
    },
    {
      "id": "0fe67ac8-2166-42bc-be0d-9cb99b9091b2",
      "name": "Register Webhook",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1680,
        144
      ]
    },
    {
      "id": "caefc780-c8e4-47c9-a8ce-4656e0f73264",
      "name": "Save Registration to WorkflowStaticData",
      "type": "n8n-nodes-base.code",
      "position": [
        -1504,
        144
      ]
    },
    {
      "id": "655de901-1a33-4bd3-b2b7-441f5ec9f4ec",
      "name": "Is Valid Request?",
      "type": "n8n-nodes-base.if",
      "position": [
        -816,
        304
      ]
    },
    {
      "id": "bfc39f92-6196-47f2-947c-05e728bb4853",
      "name": "Invalid Request",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -592,
        400
      ]
    },
    {
      "id": "03d5afa2-42eb-4a08-a387-8291bed5245a",
      "name": "Get Changes List",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -592,
        224
      ]
    },
    {
      "id": "6484466f-868b-480b-b022-753a4cd19738",
      "name": "Change Events to Items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -192,
        656
      ]
    },
    {
      "id": "36530836-1816-4483-a2b5-6bb98ea31e2c",
      "name": "Filter Changed Events",
      "type": "n8n-nodes-base.filter",
      "position": [
        0,
        656
      ]
    },
    {
      "id": "94b0b1e2-2bc5-4de2-a32c-4f28b71806e9",
      "name": "Get Registration From WorkflowStaticData",
      "type": "n8n-nodes-base.code",
      "position": [
        -1008,
        304
      ]
    },
    {
      "id": "ed3fc6b5-a952-4805-be6e-359b6d54e7a9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2880,
        0
      ],
      "parameters": {
        "width": 1552,
        "height": 640,
        "content": "## 1. Register a Google Drive Notification Channel (Webhook)\n[Learn more about Google Drive Notification Channels](https://developers.google.com/workspace/drive/api/guides/push)\n\nWith Push Notificatio"
      }
    },
    {
      "id": "e573fe58-f2fb-4c92-bd88-2dfc473e5392",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2800,
        320
      ]
    },
    {
      "id": "2d48f008-c590-4e53-9569-611be082d5c6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        0
      ],
      "parameters": {
        "width": 896,
        "height": 640,
        "content": "## 2. Listening For Push Notifications\n[Learn more about Receiving Google Drive Push Notifications](https://developers.google.com/workspace/drive/api/guides/push#receive-notifications)\n\nOnce the Googl"
      }
    },
    {
      "id": "2a02d923-bd2d-48b3-975d-a03949eb50dc",
      "name": "Get Files Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        192,
        656
      ]
    },
    {
      "id": "193af0b7-26b7-4ef4-b727-f222f58dc323",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        0
      ],
      "parameters": {
        "width": 720,
        "height": 416,
        "content": "## 3. Update LastPageToken For Next Push Notification\n[Learn more about WorkflowStaticData](https://docs.n8n.io/code/cookbook/builtin/get-workflow-static-data/)\n\nThe page token is like a \"cursor\" and "
      }
    },
    {
      "id": "44bae3f1-ac15-4313-a229-733921c80660",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        448
      ],
      "parameters": {
        "width": 720,
        "height": 416,
        "content": "## 4. Post-Filter the Changes List\nThe **changes list** contains events for the entire drive and can't be pre-filtered by folder. It is therefore important to post-filter the changes list to ensure yo"
      }
    },
    {
      "id": "cbaee96d-e408-4c02-b05c-14a8d5348d56",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        64,
        208
      ],
      "parameters": {
        "width": 384,
        "height": 144,
        "content": "### ⚠️ Only Works In Production Mode!\nTo use workflowStaticData, the workflow must be run in production mode and not editor mode.\nIf you need this to work in both modes, consider switching to another "
      }
    },
    {
      "id": "2cbebd1f-a927-40b1-989f-8e960669de51",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3552,
        -416
      ],
      "parameters": {
        "width": 608,
        "height": 1344,
        "content": "## Watch for Google Drive File Changes with Google Push Notifications!\n\n**Tired of being let down by the Google Drive Trigger? Rather not exhaust system resources by polling every minute? Then this wo"
      }
    },
    {
      "id": "719e5e52-7424-409e-b9cf-dc746f8af3f7",
      "name": "Do Something With These Files!",
      "type": "n8n-nodes-base.noOp",
      "position": [
        496,
        656
      ]
    },
    {
      "id": "902b64b1-0acf-4922-8ffe-a4114e6a2fdd",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2016,
        352
      ],
      "parameters": {
        "width": 608,
        "height": null,
        "content": "\n### Renewing the Notification Channel\n* All Notifications Channels have a maximum active duration of 1 week.\n* To renew an existing notification channel, you can simply call the `changes.watch` API ("
      }
    },
    {
      "id": "5e7ca713-097e-4e50-9ca3-6c5faaea1a02",
      "name": "Save NextPageToken to WorkflowStaticData",
      "type": "n8n-nodes-base.code",
      "position": [
        -160,
        224
      ]
    },
    {
      "id": "e2972a38-5c2f-40b5-965b-4ab7bc10df6a",
      "name": "Get Registration",
      "type": "n8n-nodes-base.code",
      "position": [
        -2400,
        320
      ]
    },
    {
      "id": "12893d4d-0a38-4f1c-b5d5-fc5d76c4889c",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2624,
        272
      ],
      "parameters": {
        "width": 192,
        "height": 304,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n### ⚠️ Edit me!\nAdd your details here and the template will do the rest."
      }
    },
    {
      "id": "24fd55eb-d91f-413d-97e8-636e4e19c494",
      "name": "First Run? Click Here!",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -2800,
        704
      ]
    },
    {
      "id": "947ad96f-d564-4943-9deb-cc93a92c63fb",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3552,
        960
      ],
      "parameters": {
        "width": 608,
        "height": 336,
        "content": "![](https://cdn.subworkflow.ai/n8n-templates/banner_595x311.png#full-width)"
      }
    },
    {
      "id": "bdfbaa00-65f0-4392-86d0-2213301737a9",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1216,
        304
      ]
    },
    {
      "id": "e06f30f0-9eaf-4098-bbd7-7ed6fbf3a2b9",
      "name": "Subworkflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -2800,
        464
      ]
    },
    {
      "id": "2e74455d-d95a-4575-afe4-e57c2da3e9d3",
      "name": "Stop Any Existing Notifications",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -2224,
        320
      ]
    },
    {
      "id": "466e4f97-c801-43f5-a90f-3a493e47d912",
      "name": "Register Notification Channel",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -2592,
        704
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Registration From WorkflowStaticData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Variables": {
      "main": [
        [
          {
            "node": "Get Registration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Changes List": {
      "main": [
        [
          {
            "node": "Save NextPageToken to WorkflowStaticData",
            "type": "main",
            "index": 0
          },
          {
            "node": "Change Events to Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Registration": {
      "main": [
        [
          {
            "node": "Stop Any Existing Notifications",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Register Webhook": {
      "main": [
        [
          {
            "node": "Save Registration to WorkflowStaticData",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Files Details": {
      "main": [
        [
          {
            "node": "Do Something With These Files!",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Valid Request?": {
      "main": [
        [
          {
            "node": "Get Changes List",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get StartPageToken": {
      "main": [
        [
          {
            "node": "Register Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Subworkflow Trigger": {
      "main": [
        [
          {
            "node": "Set Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Changed Events": {
      "main": [
        [
          {
            "node": "Get Files Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change Events to Items": {
      "main": [
        [
          {
            "node": "Filter Changed Events",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "First Run? Click Here!": {
      "main": [
        [
          {
            "node": "Register Notification Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stop Any Existing Notifications": {
      "main": [
        [
          {
            "node": "Get StartPageToken",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Registration From WorkflowStaticData": {
      "main": [
        [
          {
            "node": "Is Valid Request?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}