{
  "name": "TaskToAgent - Free game alert",
  "nodes": [
    {
      "parameters": {
        "content": "## Free game alert\nEvery 3 hours: Epic free games + GamerPower giveaways, posts only new ones to Discord.\n\n1. Discord: Server settings > Integrations > Webhooks > New > Copy URL.\n2. Paste it in **Post to Discord** (URL field).\n3. Activate. Note: the first run posts everything currently free.\n\nIsThereAnyDeal wishlist prices: see the Python version.",
        "height": 300,
        "width": 420
      },
      "id": "a35f5e0b-0e7a-51ed-9350-632e1899d64f",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -460,
        -260
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 3
            }
          ]
        }
      },
      "id": "b24a015f-9349-5759-9a5e-97c346f9c00d",
      "name": "Schedule",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://www.gamerpower.com/api/giveaways?type=game&platform=pc",
        "options": {}
      },
      "id": "442438c4-89d2-577d-8965-1f4cb48c5064",
      "name": "GamerPower giveaways",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        -100
      ]
    },
    {
      "parameters": {
        "url": "https://store-site-backend-static.ak.epicgames.com/freeGamesPromotions?locale=en-US&country=US",
        "options": {}
      },
      "id": "7d1e5d5d-5c3b-5e04-89a3-bd21889621bb",
      "name": "Epic free games",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "return $input.all().map(i => ({ json: { id: 'gp:' + i.json.id, title: i.json.title, url: i.json.open_giveaway_url, note: `FREE (worth ${i.json.worth}) on ${i.json.platforms}, ends ${i.json.end_date}` } }));"
      },
      "id": "cfb1a83c-0faa-5632-97f0-829a7b4ce710",
      "name": "Format GamerPower",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        -100
      ]
    },
    {
      "parameters": {
        "jsCode": "const now = new Date(); const out = [];\nfor (const g of $json.data.Catalog.searchStore.elements) {\n  for (const b of (g.promotions?.promotionalOffers || [])) for (const o of b.promotionalOffers) {\n    if (new Date(o.startDate) <= now && now <= new Date(o.endDate) && o.discountSetting?.discountPercentage === 0) {\n      const slug = g.productSlug || g.catalogNs?.mappings?.[0]?.pageSlug || '';\n      out.push({ json: { id: 'epic:' + g.id, title: g.title, url: slug ? `https://store.epicgames.com/p/${slug}` : 'https://store.epicgames.com/free-games', note: `FREE on Epic until ${o.endDate}` } });\n    }\n  }\n}\nreturn out;"
      },
      "id": "fbd881c8-2ea4-5fd3-8500-b9e6d15beeca",
      "name": "Format Epic",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        440,
        100
      ]
    },
    {
      "parameters": {},
      "id": "27fde2ae-5b13-5b8c-8918-d7008b3459f7",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "operation": "removeItemsRepeatedInPreviousExecutions",
        "dedupeValue": "={{ $json.id }}",
        "options": {}
      },
      "id": "79ff30c5-8ee1-5579-88b1-22cbb3bea879",
      "name": "Only new",
      "type": "n8n-nodes-base.removeDuplicates",
      "typeVersion": 2,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "PASTE_YOUR_DISCORD_WEBHOOK_URL",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ username: \"Free Game Alert\", content: \"🎮 **\" + $json.title + \"** - \" + $json.note + \"\\n\" + $json.url }) }}",
        "options": {
          "batching": {
            "batch": {
              "batchSize": 1,
              "batchInterval": 1000
            }
          }
        }
      },
      "id": "41d8dcae-f787-50d1-b23e-3e19d2d91255",
      "name": "Post to Discord",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        0
      ]
    }
  ],
  "connections": {
    "Schedule": {
      "main": [
        [
          {
            "node": "GamerPower giveaways",
            "type": "main",
            "index": 0
          },
          {
            "node": "Epic free games",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GamerPower giveaways": {
      "main": [
        [
          {
            "node": "Format GamerPower",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Epic free games": {
      "main": [
        [
          {
            "node": "Format Epic",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format GamerPower": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Epic": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Only new",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only new": {
      "main": [
        [
          {
            "node": "Post to Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "https://tasktoagent.com/agents/"
  },
  "tags": []
}