{
  "name": "Codzienny raport z API",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "30 7 * * 1-5"
            }
          ]
        }
      },
      "name": "Codziennie 7:30",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://api.twojafirma.pl/zamowienia?od={{ $now.minus({days:1}).toFormat('yyyy-LL-dd') }}",
        "options": {}
      },
      "name": "Pobierz dane",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\nconst suma = items.reduce((s, i) => s + (Number(i.json.kwota) || 0), 0);\nreturn [{ json: { liczba: items.length, suma: suma.toFixed(2) } }];"
      },
      "name": "Policz",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "fromEmail": "n8n@twojafirma.pl",
        "toEmail": "szef@twojafirma.pl",
        "subject": "=Raport dzienny: {{ $json.liczba }} zamówień, {{ $json.suma }} zł",
        "emailFormat": "text",
        "text": "=Zamówień wczoraj: {{ $json.liczba }}\nSuma: {{ $json.suma }} zł",
        "options": {}
      },
      "name": "Wyślij raport",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        720,
        0
      ]
    }
  ],
  "connections": {
    "Codziennie 7:30": {
      "main": [
        [
          {
            "node": "Pobierz dane",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pobierz dane": {
      "main": [
        [
          {
            "node": "Policz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Policz": {
      "main": [
        [
          {
            "node": "Wyślij raport",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Europe/Warsaw"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "agentflow.pl/n8n/szablony"
  },
  "pinData": {}
}