{
  "name": "Daily Kleinanzeigen property alerts with Apify",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "property-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-immobilien-scraper/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "contentType": "raw",
        "rawContentType": "application/json",
        "body": "{\"offerType\":\"rent-apartment\",\"locationCode\":\"berlin\",\"minRooms\":2,\"minSqm\":50,\"maxPrice\":2500,\"fetchDetails\":true,\"maxResults\":25}",
        "options": {
          "timeout": 300000
        }
      },
      "id": "property-apify",
      "name": "Run Property 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 properties = rows.filter(row => row && row.url).sort((a, b) => Number(a.warm_rent_eur || a.cold_rent_eur || a.price || Infinity) - Number(b.warm_rent_eur || b.cold_rent_eur || b.price || Infinity));\nconst lines = properties.slice(0, 25).map((row, index) => {\n  const price = row.warm_rent_eur || row.cold_rent_eur || row.price;\n  return `${index + 1}. ${row.title || 'Property'}\\n${price ? `${price} EUR` : 'Price unavailable'} | ${row.rooms || '?'} rooms | ${row.living_space_sqm || '?'} m2\\n${row.location || row.city || 'Location unavailable'}\\n${row.url}`;\n});\nreturn [{ json: { subject: `Kleinanzeigen property alert: ${properties.length} matches`, digest: lines.join('\\n\\n') || 'No properties matched the configured filters today.' } }];"
      },
      "id": "property-digest",
      "name": "Build property 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": "property-email",
      "name": "Email property alert",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        160,
        0
      ]
    }
  ],
  "connections": {
    "Daily schedule": {
      "main": [
        [
          {
            "node": "Run Property Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Property Actor": {
      "main": [
        [
          {
            "node": "Build property digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build property digest": {
      "main": [
        [
          {
            "node": "Email property alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "kleinanzeigen-property-alerts-v1",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}