{
  "name": "Daily Kleinanzeigen used-car alerts with Apify",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "cars-schedule",
      "name": "Daily schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -620,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/actors/benthepythondev~kleinanzeigen-autos-scraper/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "{\"locationCode\":\"berlin\",\"maxPrice\":15000,\"minYear\":2015,\"maxMileage\":150000,\"fetchDetails\":true,\"maxResults\":25}",
        "options": {
          "timeout": 300000
        }
      },
      "id": "cars-apify",
      "name": "Run Used Cars Actor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -360,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const input = $input.all().map(item => item.json);\nconst rows = input.length === 1 && Array.isArray(input[0]) ? input[0] : input;\nconst cars = rows.filter(row => row && row.url).sort((a, b) => Number(a.price_eur || a.price || Infinity) - Number(b.price_eur || b.price || Infinity));\nconst lines = cars.slice(0, 25).map((row, index) => {\n  const label = [row.make, row.model].filter(Boolean).join(' ') || row.title || 'Vehicle';\n  return `${index + 1}. ${label} (${row.year || 'year unknown'})\\n${row.price_eur || row.price || '?'} EUR | ${row.mileage_km || '?'} km | ${row.fuel || 'fuel unknown'}\\n${row.city || row.location || 'Location unavailable'} | ${row.seller_name || 'Seller unavailable'}\\n${row.url}`;\n});\nreturn [{ json: { subject: `Kleinanzeigen car alert: ${cars.length} matches`, digest: lines.join('\\n\\n') || 'No cars matched the configured filters today.' } }];"
      },
      "id": "cars-digest",
      "name": "Build car digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -100,
        0
      ]
    },
    {
      "parameters": {
        "fromEmail": "alerts@example.com",
        "toEmail": "you@example.com",
        "subject": "={{ $json.subject }}",
        "emailFormat": "text",
        "text": "={{ $json.digest }}",
        "options": {}
      },
      "id": "cars-email",
      "name": "Email car alert",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        160,
        0
      ]
    }
  ],
  "connections": {
    "Daily schedule": {
      "main": [
        [
          {
            "node": "Run Used Cars Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Used Cars Actor": {
      "main": [
        [
          {
            "node": "Build car digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build car digest": {
      "main": [
        [
          {
            "node": "Email car alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "kleinanzeigen-used-car-alerts-v1",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}