{
  "name": "Weekly eBay sold comps → Google Sheet + Slack (eBay Sold Listings Comps AI)",
  "nodes": [
    {
      "parameters": {
        "rule": {"interval": [{"field": "weeks", "triggerAtDay": [1], "triggerAtHour": 8}]}
      },
      "id": "a1f0c0de-0001-4000-8000-000000000001",
      "name": "Every Monday 8:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/rich_minds~ebay-sold-comps-ai/run-sync-get-dataset-items?timeout=3600",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "{\"keywords\": [\"nintendo switch oled\", \"ps5 slim disc\"], \"daysToScrape\": 7, \"maxSoldPerKeyword\": 50, \"shippingCost\": 15, \"targetProfit\": 40, \"maxDiscoveryChargeUsd\": 1, \"dedupeStoreName\": \"my-weekly-comps\"}",
        "options": {"timeout": 3700000}
      },
      "id": "a1f0c0de-0002-4000-8000-000000000002",
      "name": "Run eBay Sold Listings Comps AI",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [240, 0],
      "notes": "Header auth credential: name 'Authorization', value 'Bearer <YOUR_APIFY_TOKEN>'. Returns only the NEW clean comps of the week (cross-run memory)."
    },
    {
      "parameters": {
        "operation": "appendOrUpdate",
        "documentId": {"__rl": true, "mode": "url", "value": "<YOUR_GOOGLE_SHEET_URL>"},
        "sheetName": {"__rl": true, "mode": "name", "value": "comps"},
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "dedupeKey": "={{ $json.dedupeKey }}",
            "keyword": "={{ $json.keyword }}",
            "title": "={{ $json.title }}",
            "unitPrice": "={{ $json.unitPrice }}",
            "currency": "={{ $json.currency }}",
            "conditionBucket": "={{ $json.conditionBucket }}",
            "endedAt": "={{ $json.endedAt }}",
            "priceVsMedianPct": "={{ $json.priceVsMedianPct }}",
            "score": "={{ $json.score }}",
            "url": "={{ $json.url }}"
          },
          "matchingColumns": ["dedupeKey"]
        },
        "options": {}
      },
      "id": "a1f0c0de-0003-4000-8000-000000000003",
      "name": "Upsert into Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [480, 0],
      "notes": "Import docs/img/sheets-comps-template.csv as the 'comps' tab first — the header row matches these columns."
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.apify.com/v2/acts/rich_minds~ebay-sold-comps-ai/runs/last/key-value-store/records/DIGEST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {"response": {"response": {"responseFormat": "text"}}}
      },
      "id": "a1f0c0de-0004-4000-8000-000000000004",
      "name": "Read the DIGEST",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [720, 0],
      "executeOnce": true
    },
    {
      "parameters": {
        "method": "POST",
        "url": "<YOUR_SLACK_INCOMING_WEBHOOK_URL>",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: $json.data }) }}",
        "options": {}
      },
      "id": "a1f0c0de-0005-4000-8000-000000000005",
      "name": "Post the median per keyword to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [960, 0]
    }
  ],
  "connections": {
    "Every Monday 8:00": {"main": [[{"node": "Run eBay Sold Listings Comps AI", "type": "main", "index": 0}]]},
    "Run eBay Sold Listings Comps AI": {"main": [[{"node": "Upsert into Google Sheet", "type": "main", "index": 0}]]},
    "Upsert into Google Sheet": {"main": [[{"node": "Read the DIGEST", "type": "main", "index": 0}]]},
    "Read the DIGEST": {"main": [[{"node": "Post the median per keyword to Slack", "type": "main", "index": 0}]]}
  },
  "settings": {"executionOrder": "v1"}
}