8
n8n 中文网amn8n.com

Epic Games新免费游戏通知

高级

这是一个Other领域的自动化工作流,包含 26 个节点。主要使用 If, Set, Code, Html, Wait 等节点。 在Discord上通知Epic Games新免费游戏发布

前置要求
  • Discord Bot Token 或 Webhook
  • 可能需要目标 API 的认证凭证

分类

工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "nWdRPgjTA0iQLiSE",
  "meta": {
    "instanceId": "0474a64210dbf4997d3d0ef45d7a3ada37c6ee1bf9febb43754c2af71828b968",
    "templateCredsSetupCompleted": true
  },
  "name": "Epic Games 新免费游戏",
  "tags": [],
  "nodes": [
    {
      "id": "30e06e62-9844-4844-b9ba-08c2759729cf",
      "name": "由 Github 模型提供支持",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -600,
        75
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "896f4f15-0317-4db2-984c-01bcc0402f3e",
      "name": "提取优惠",
      "type": "n8n-nodes-base.html",
      "position": [
        60,
        0
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "dataPropertyName": "body",
        "extractionValues": {
          "values": [
            {
              "key": "container",
              "cssSelector": "[data-component*=\"OfferCard\"]:not([data-component=\"DiscoverOfferCard\"])",
              "returnArray": true,
              "returnValue": "html"
            }
          ]
        }
      },
      "retryOnFail": false,
      "typeVersion": 1.2
    },
    {
      "id": "3969b8a5-24d9-49cd-9c0a-a8ad3d49cbd6",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        500,
        -100
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "container"
      },
      "typeVersion": 1
    },
    {
      "id": "3cccc820-230b-48b3-ba3e-b5d7c1620959",
      "name": "提取标签",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c46e46d9-2e32-434b-bec1-53e7cff18f8c",
              "name": "label",
              "type": "string",
              "value": "={{ $json.container.includes(\"Free Now\") ? \"Free Now\" : $json.container.includes(\"Coming Soon\") ? \"Coming Soon\" : $json.container.includes(\"Mystery\") ? \"Mystery\" : \"\"}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ac99f6b6-b43d-49f2-9543-1c83a0abd4e5",
      "name": "准备数据",
      "type": "n8n-nodes-base.merge",
      "position": [
        940,
        -100
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "6e134e7b-87e9-416b-96fd-d7c35a896be6",
      "name": "检查是否变更",
      "type": "n8n-nodes-base.code",
      "position": [
        1160,
        -25
      ],
      "parameters": {
        "jsCode": "const nodeStaticData = $getWorkflowStaticData('node');\n\nlet lastHash = $input.all().map(item => item.json.title + item.json.label).join(',');\n\nif (nodeStaticData.lastHash == undefined || nodeStaticData.lastHash !== lastHash) {\n  nodeStaticData.lastHash = lastHash;\n  return {json: {value: true, hash: lastHash}};\n}\n\nreturn {json: {value: false}};"
      },
      "typeVersion": 2
    },
    {
      "id": "6e8c112d-4c58-4c92-bc6b-0504ec55340f",
      "name": "仅在变更时",
      "type": "n8n-nodes-base.filter",
      "position": [
        1380,
        -25
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cac341c8-c4ee-4afa-b060-26a334c96826",
              "operator": {
                "type": "boolean",
                "operation": "equals"
              },
              "leftValue": "={{ $json.value }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "513afa47-30ef-41d4-bc4e-1e2338464d89",
      "name": "成功",
      "type": "n8n-nodes-base.merge",
      "position": [
        2260,
        -100
      ],
      "parameters": {
        "mode": "chooseBranch",
        "useDataOfInput": 2
      },
      "typeVersion": 3.1
    },
    {
      "id": "29137c18-edaa-4f85-b693-6a52a15084bb",
      "name": "保存静态数据",
      "type": "n8n-nodes-base.code",
      "position": [
        2480,
        -100
      ],
      "parameters": {
        "jsCode": "const nodeStaticData = $getWorkflowStaticData('node');\n\nnodeStaticData.lastHash = $input.first().json.hash;\n\nreturn {json: {\"status\" : \"success\"}}"
      },
      "typeVersion": 2
    },
    {
      "id": "94960f95-1f2e-44f5-8493-4c4f8a37238e",
      "name": "设置重试次数",
      "type": "n8n-nodes-base.set",
      "position": [
        -380,
        75
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6726de8b-7ecf-4c8d-b34b-6f176e5c8a4e",
              "name": "retries",
              "type": "number",
              "value": "={{ $json.retries || 0 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "799a04ba-d271-4826-8d69-e3c72eaad802",
      "name": "请求间等待",
      "type": "n8n-nodes-base.wait",
      "position": [
        500,
        200
      ],
      "webhookId": "2e5fe319-d395-4779-b0cd-28f1ad252220",
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "47b3078c-6ef1-44d9-9814-e633ce4cce20",
      "name": "更新重试次数",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "01641325-e7ff-4125-9c06-b3b39df38a56",
              "name": "retries",
              "type": "number",
              "value": "={{ $('Set Retries').item.json.retries + 1 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d14bbbf8-6120-47c2-bb14-9869a941fa6b",
      "name": "如果有结果",
      "type": "n8n-nodes-base.if",
      "position": [
        280,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "5998baa9-a870-4fab-8fc3-53815165b5c0",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.container }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f06ae481-bcd8-4886-a47e-f088cb60e03b",
      "name": "等待条件",
      "type": "n8n-nodes-base.merge",
      "position": [
        1600,
        -175
      ],
      "parameters": {
        "mode": "chooseBranch"
      },
      "typeVersion": 3.1
    },
    {
      "id": "0ad18534-0be9-4f48-9b95-3bee8ce05ce2",
      "name": "错误时通知",
      "type": "n8n-nodes-base.discord",
      "position": [
        1160,
        275
      ],
      "webhookId": "2fb990b7-8200-4e19-a6ed-db61d23e6074",
      "parameters": {
        "content": "Failed to check Epic Games for new content",
        "options": {},
        "authentication": "webhook"
      },
      "typeVersion": 2
    },
    {
      "id": "e1c45b2a-064a-4c2e-a381-bf7133377fe8",
      "name": "获取 Epic Games 免费游戏页面",
      "type": "n8n-nodes-puppeteer.puppeteer",
      "position": [
        -160,
        0
      ],
      "parameters": {
        "url": "https://store.epicgames.com/en-US/free-games",
        "options": {
          "browserWSEndpoint": "ws://n8n-chrome:3000/?stealth=1&--disable-web-security=true&token=Problem-Crook4-Barstool"
        }
      },
      "retryOnFail": true,
      "typeVersion": 1
    },
    {
      "id": "67b0c1e5-84ac-4554-9464-4db3ac1f9e2e",
      "name": "如果有重试次数",
      "type": "n8n-nodes-base.if",
      "position": [
        940,
        275
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "e6664c60-c2bb-4007-beba-ce4113a97b0b",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $('Set Retries').item.json.retries }}",
              "rightValue": 5
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4ff1896d-d301-4b42-a451-ccb53bdfc291",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 260,
        "height": 360,
        "content": "由于某些原因,有时可能正确返回整个页面但免费游戏容器为空。因此我们会重复几次。"
      },
      "typeVersion": 1
    },
    {
      "id": "c101d3d3-496e-45f8-97d1-4a52c6ecc4a8",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2000,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 240,
        "content": "这有时可能会失败,因此会重复几次。"
      },
      "typeVersion": 1
    },
    {
      "id": "20c9b254-7f61-4faf-9bfb-b9caca65d128",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2220,
        -180
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 240,
        "content": "仅在确认用户收到通知时保存"
      },
      "typeVersion": 1
    },
    {
      "id": "a399a170-2e5d-45f5-b1ab-49e56c9d0561",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        -125
      ],
      "parameters": {
        "color": 5,
        "width": 180,
        "height": 260,
        "content": "保留变更的\"哈希值\",以便了解执行之间是否有任何更改。"
      },
      "typeVersion": 1
    },
    {
      "id": "63d94fcd-88ec-4c22-b503-286495bf353f",
      "name": "提取标题和图片",
      "type": "n8n-nodes-base.html",
      "position": [
        720,
        -200
      ],
      "parameters": {
        "options": {
          "trimValues": true
        },
        "operation": "extractHtmlContent",
        "dataPropertyName": "container",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "h6"
            },
            {
              "key": "image",
              "attribute": "data-image",
              "cssSelector": "img",
              "returnValue": "attribute"
            },
            {
              "key": "url",
              "attribute": "href",
              "cssSelector": "a",
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "69950114-45ea-455b-972d-73018f62cb45",
      "name": "通知 Discord",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2040,
        -175
      ],
      "parameters": {
        "url": "https://discord.com/api/webhooks/...",
        "method": "POST",
        "options": {},
        "jsonBody": "={{ $json.body }}",
        "sendBody": true,
        "specifyBody": "json"
      },
      "retryOnFail": true,
      "typeVersion": 4.2
    },
    {
      "id": "17676c5a-12dd-4589-a554-1424f343f9f5",
      "name": "准备通知",
      "type": "n8n-nodes-base.code",
      "position": [
        1820,
        -175
      ],
      "parameters": {
        "jsCode": "let embeds = [];\n\nfor (const item of $input.all()) {\n  var content = {\n    \"thumbnail\": {\n      \"url\": item.json.image\n    }\n  };\n\n  if (item.json.title.length != 0) {\n    content[\"title\"] = item.json.title;\n    content[\"url\"] = \"https://store.epicgames.com\" + item.json.url,\n    content[\"description\"] = item.json.label;\n  } else {\n    content[\"title\"] = item.json.label;\n  }\n\n  embeds.push(content);\n}\n\nconst payload = {\n  username: \"Epic Games\",\n  content: \"New games detected\",\n  avatar_url: \"https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Epic_Games_logo.svg/250px-Epic_Games_logo.svg.png\",\n  embeds: embeds\n};\n\nreturn [{json: {body: payload}}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "aefedb1f-cc94-4db7-a606-5d419e07e9da",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        35,
        -200
      ],
      "parameters": {
        "color": 5,
        "width": 150,
        "height": 360,
        "content": "如果工作流不工作,这很可能是故障点。这意味着他们在页面上更改了某些内容,CSS 选择器已更改。"
      },
      "typeVersion": 1
    },
    {
      "id": "9cc64931-29ba-40e7-adf6-43507420c4c3",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1950,
        -615
      ],
      "parameters": {
        "color": 7,
        "width": 280,
        "height": 600,
        "content": "Discord 上的通知包含嵌入内容。"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "87486a5e-7a16-4d25-ad90-72b2452bc99d",
  "connections": {
    "Success": {
      "main": [
        [
          {
            "node": "Save Static Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Extract title and image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Retries": {
      "main": [
        [
          {
            "node": "GET Epic Games Free Games page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare data": {
      "main": [
        [
          {
            "node": "Check if changed",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait for conditions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract label": {
      "main": [
        [
          {
            "node": "Prepare data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract offers": {
      "main": [
        [
          {
            "node": "If has Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Has Retries": {
      "main": [
        [
          {
            "node": "Set Retries",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Notify on error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has Results": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait between requests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Discord": {
      "main": [
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Retries": {
      "main": [
        [
          {
            "node": "If Has Retries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify on error": {
      "main": [
        []
      ]
    },
    "Check if changed": {
      "main": [
        [
          {
            "node": "Only when changed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Set Retries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only when changed": {
      "main": [
        [
          {
            "node": "Wait for conditions",
            "type": "main",
            "index": 1
          },
          {
            "node": "Success",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Wait for conditions": {
      "main": [
        [
          {
            "node": "Prepare notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare notification": {
      "main": [
        [
          {
            "node": "Notify Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait between requests": {
      "main": [
        [
          {
            "node": "Update Retries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract title and image": {
      "main": [
        [
          {
            "node": "Prepare data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GET Epic Games Free Games page": {
      "main": [
        [
          {
            "node": "Extract offers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 其他

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量26
分类1
节点类型13
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

外部链接
在 n8n.io 查看

分享此工作流