{
  "name": "Sellf: Refund Request Alert \u2192 Telegram",
  "nodes": [
    {
      "parameters": {
        "content": "## Sellf: Refund Alert \u2014 Konfiguracja\n\n**1. Sellf API \u2014 URL + klucz**\nW node \"Check Pending Refunds\" zmie\u0144 domen\u0119:\n`https://yourdomain.com` \u2192 Twoja domena Sellf.\nW n8n \u2192 Credentials \u2192 HTTP Header Auth \u2192 dodaj:\n`X-Api-Key: sf_live_xxx` (klucz z Sellf admin \u2192 Settings \u2192 API).\n\n**2. Telegram Bot**\nn8n \u2192 Credentials \u2192 Telegram API \u2192 wpisz Bot Token\n(utw\u00f3rz bota przez @BotFather).\nW node \"Send to Telegram\" ustaw `YOUR_CHAT_ID`\n(u\u017cyj @userinfobot aby pozna\u0107 swoje Chat ID).\n\n**3. Cz\u0119stotliwo\u015b\u0107 sprawdzania**\nDomy\u015blnie co 15 minut. Zmie\u0144 w node \"Every 15 Minutes\".",
        "height": 300,
        "width": 380,
        "color": 4
      },
      "id": "note-1",
      "name": "Konfiguracja",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -420,
        100
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "cron-1",
      "name": "Every 15 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://yourdomain.com/api/v1/refund-requests?status=pending",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "id": "http-1",
      "name": "Check Pending Refunds (Sellf API)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        260,
        300
      ],
      "notes": "TODO: Configure HTTP Header Auth with Sellf API key (X-API-Key: sf_live_xxx). Update domain URL."
    },
    {
      "parameters": {
        "jsCode": "const response = $input.first().json;\nconst refunds = response.data || response.refund_requests || response || [];\n\nif (!Array.isArray(refunds) || refunds.length === 0) return [];\n\nconst lines = refunds.map(r =>\n  `\u2022 ${r.customer_email || r.email || 'N/A'} \u2014 ${r.product_name || r.product || 'N/A'} (${r.amount ? r.amount/100 : '?'} ${r.currency || ''})`\n).join('\\n');\n\nconst msg = `\u26a0\ufe0f *Pending Refund Requests: ${refunds.length}*\\n\\n${lines}\\n\\n\ud83d\udc49 Sprawd\u017a w panelu admina`;\n\nreturn [{ json: { message: msg, count: refunds.length } }];"
      },
      "id": "code-1",
      "name": "Format Alert",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "YOUR_CHAT_ID",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "id": "tg-1",
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        760,
        300
      ],
      "notes": "TODO: Configure Telegram Bot credentials and set YOUR_CHAT_ID."
    }
  ],
  "connections": {
    "Every 15 Minutes": {
      "main": [
        [
          {
            "node": "Check Pending Refunds (Sellf API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Pending Refunds (Sellf API)": {
      "main": [
        [
          {
            "node": "Format Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Alert": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "htZNMuiK4WS01HWe"
}