{
  "name": "SoftGlaze: scheduled warm-up (Beta)",
  "nodes": [
    {
      "parameters": {
        "content": "## SoftGlaze scheduled warm-up (Beta)\n\nEvery day at 10:00 this takes up to 5 stopped profiles from one group, those launched least first, and starts the Cookie Warmer on them, one at a time, on its default mix of sites.\n\n1. In SoftGlaze, create an **automation token** (Owner): Operate scope, limited to the group, with **start_warmer** pre-approved. Read-only tools need no approval.\n2. Use that token in both SoftGlaze nodes. Change `8080` if your port is different.\n3. Set the group name in **Stopped profiles in the group** (replace `CHANGE_ME`).\n\nWarm up only your own accounts and test profiles; see the acceptable use policy. Follow the run in SoftGlaze, or with get_run_status.\n\nBeta: not yet run against a live SoftGlaze. Guide: browser.softglaze.com/docs/ai-agents#n8n",
        "height": 340,
        "width": 520
      },
      "id": "02c2b0e7-adb2-41b4-98e0-016119d670fb",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -360
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 10
            }
          ]
        }
      },
      "id": "a39204fb-4db2-429e-baa4-17be67ac6fa8",
      "name": "Every day at 10:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:8080/api/v1/tools/list_profiles",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{ \"group\": \"CHANGE_ME\", \"status\": \"stopped\", \"pageSize\": 100 }",
        "options": {
          "timeout": 130000
        }
      },
      "id": "5596b6c0-d65c-4471-a82e-409e1e942286",
      "name": "Stopped profiles in the group",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Picks up to MAX stopped profiles, those launched least first, and builds the\n// start_warmer arguments. MAX matches an automation token's default profiles per call.\nconst MAX = 5;\nconst profiles = ($input.first().json.data || {}).profiles || [];\nconst chosen = profiles\n  .filter((p) => !p.running && p.browser === 'Chromium')\n  .sort((a, b) => (a.launchCount || 0) - (b.launchCount || 0))\n  .slice(0, MAX);\nif (!chosen.length) return [];\nreturn [{ json: { names: chosen.map((p) => p.name), args: { profileIds: chosen.map((p) => p.id), concurrency: 1 } } }];"
      },
      "id": "36bf217e-46fa-417e-9a9d-7bcff49a1d31",
      "name": "Pick up to 5",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://127.0.0.1:8080/api/v1/tools/start_warmer",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.args) }}",
        "options": {
          "timeout": 130000
        }
      },
      "id": "adca17e7-b316-46fc-b53e-505792475020",
      "name": "Start the warm-up",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ]
    }
  ],
  "connections": {
    "Every day at 10:00": {
      "main": [
        [
          {
            "node": "Stopped profiles in the group",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Stopped profiles in the group": {
      "main": [
        [
          {
            "node": "Pick up to 5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick up to 5": {
      "main": [
        [
          {
            "node": "Start the warm-up",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
