{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5756a95d-b6ff-4a78-b4c6-7ad6bc8733b8",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -544,
        -16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "daysInterval": 4
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0698ceea-1ea3-4606-a905-d13d6effb299",
      "name": "Create a row",
      "type": "n8n-nodes-base.supabase",
      "position": [
        560,
        16
      ],
      "parameters": {
        "tableId": "ping",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "created_at",
              "fieldValue": "={{ $now }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c0084d94-d281-4de2-842d-2a1367024c05",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -544,
        176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a7230917-3e63-4dae-b49a-9d602275e0b4",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        -304,
        0
      ],
      "parameters": {
        "jsCode": "return Array.from({ length: 25 }, () => ({\n  json: {\n    value: 1\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "826f8668-07d9-457f-b762-3539680e5647",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        32,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "851b0d53-ce1a-44ca-bb8a-f4c0724569af",
      "name": "Code in JavaScript1",
      "type": "n8n-nodes-base.code",
      "position": [
        240,
        16
      ],
      "parameters": {
        "jsCode": "return $input.all().map(item => {\n  return {\n    json: {\n      ...item.json,\n      seconds: Math.floor(Math.random() * (60 - 20 + 1)) + 20\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "2ca743c9-5595-4468-85f3-53ce577074d0",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        384,
        16
      ],
      "parameters": {
        "amount": "={{ $json.seconds }}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "53cbc8a7-2a96-46cb-89f7-a3aa0a417e3f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -672,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 544,
        "content": "## Trigger and batch setup\n\nStarts the workflow on a schedule or manually, then generates 25 items to drive the ping loop."
      },
      "typeVersion": 1
    },
    {
      "id": "b19145c5-f94b-4d3e-8c3c-8d0f42d8eb86",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 864,
        "height": 544,
        "content": "## Randomised ping loop\n\nIterates over each item, waits a random interval between 20 and 60 seconds, then writes a row to Supabase."
      },
      "typeVersion": 1
    },
    {
      "id": "a2ae8bde-11e1-40b0-bf67-da741cd03a94",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        -32
      ],
      "parameters": {
        "color": 3,
        "height": 224,
        "content": "## Warning"
      },
      "typeVersion": 1
    },
    {
      "id": "cf5f1bf0-9403-4072-bb62-f186690b990e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1472,
        -240
      ],
      "parameters": {
        "width": 752,
        "height": 608,
        "content": "## Supabase free plan keep-alive\n\n### How it works\n\n1. Schedule Trigger fires every 4 days to prevent Supabase from pausing the project due to inactivity.\n2. A JavaScript code node generates 25 identical items to drive a loop of database writes.\n3. Loop Over Items processes one item at a time, cycling through the full batch.\n4. A second code node assigns a random wait duration between 20 and 60 seconds to each iteration.\n5. The Wait node pauses execution for the randomised interval to simulate organic activity.\n6. The Supabase node inserts a row with the current timestamp into the `ping` table.\n\n### Setup\n\n- [ ] Add your Supabase credentials to the **Create a row** node (Supabase API)\n- [ ] Create a table named `ping` in your Supabase project with a `created_at` column\n- [ ] Activate the workflow so the schedule runs automatically\n\n### Customization\n\nAdjust the interval in Schedule Trigger if 4 days is too infrequent for your project. Change the loop count in the first code node to write more or fewer rows per run."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Create a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a row": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}