{
  "id": "1MooCR3AWTb9vbeV",
  "name": "Find the best Roblox Servers to Play",
  "tags": [],
  "nodes": [
    {
      "id": "958cc977-b2d7-4e3e-849e-470897399132",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        0,
        0
      ],
      "parameters": {
        "path": "brsf",
        "options": {},
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "7b96b246-ed40-465f-96ee-f2676abab1b7",
      "name": "Error #1",
      "type": "n8n-nodes-base.set",
      "position": [
        416,
        64
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "deae7573-f160-4879-b14f-77be7120c798",
              "name": "success",
              "type": "boolean",
              "value": false
            },
            {
              "id": "576c5067-0967-4144-962c-903c668f26a4",
              "name": "result",
              "type": "string",
              "value": "Error #1: Place ID is not set. You must use the query parameter \"plid\" in the URL. Example: \"?plid=123456789\""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6f07cf01-22c0-49f9-b33d-bc3785db6292",
      "name": "Respond with Error #1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        592,
        64
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.5
    },
    {
      "id": "a8f69798-fd63-4be6-b913-49fc43c9299c",
      "name": "Place ID Set?",
      "type": "n8n-nodes-base.if",
      "position": [
        208,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "b8331bbf-fb7b-4383-b429-a6a89bf3f4a9",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.query.plid }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "bd08f184-2ea9-4610-9933-3350ac81ca71",
      "name": "Auto Config",
      "type": "n8n-nodes-base.set",
      "position": [
        416,
        -96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "a22d9172-262f-4a27-be2f-dcc0ef3c0dfa",
              "name": "plid",
              "type": "string",
              "value": "={{ $json.query.plid }}"
            },
            {
              "id": "d3368253-4c20-4ebe-82bb-ab36f2085d14",
              "name": "act",
              "type": "string",
              "value": "={{ $if($json.act,$json.act,\"most\") }}"
            },
            {
              "id": "a25efee8-a024-4891-9a2b-d148cb885d57",
              "name": "mode",
              "type": "string",
              "value": "={{ $if($json.query.mode, $json.query.mode,\"auto\") }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d08ba9eb-d38f-45f7-a671-cd7df96d29b2",
      "name": "Fetch Public Servers",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        592,
        -96
      ],
      "parameters": {
        "url": "=https://games.roblox.com/v1/games/{{ $json.plid }}/servers/Public",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "cursor"
            },
            {
              "name": "sortOrder",
              "value": "={{ $if($json.act == \"least\",\"Asc\",\"Desc\") }}"
            },
            {
              "name": "excludeFullGames",
              "value": "true"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "cache-control",
              "value": "no-cache"
            },
            {
              "name": "origin",
              "value": "https://www.roblox.com"
            },
            {
              "name": "referer",
              "value": "https://www.roblox.com/"
            },
            {
              "name": "sec-ch-ua",
              "value": "\"Chromium\";v=\"139\", \"Not;A=Brand\";v=\"99\""
            },
            {
              "name": "sec-fetch-mode",
              "value": "cors"
            },
            {
              "name": "sec-fetch-site",
              "value": "same-site"
            },
            {
              "name": "user-agent",
              "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "3b99acc6-230f-4cf7-bf88-07fd41d9e782",
      "name": "Filter For The Best",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        -96
      ],
      "parameters": {
        "jsCode": "const input = items[0].json; \nconst servers = input.data;\n\nconst mode = $('Auto Config').first().json.mode || \"auto\"; \n\nif (!servers || servers.length === 0) {\n  return { \n    success: false, \n    result: \"No servers found for this Place ID.\" \n  };\n}\n\nlet bestServer = servers[0];\n\nfor (let i = 1; i < servers.length; i++) {\n  const current = servers[i];\n  \n  if (mode === \"ping\") {\n    if (current.ping < bestServer.ping) {\n      bestServer = current;\n    }\n  } \n  else if (mode === \"latency\") {\n    if (current.ping < bestServer.ping) {\n      bestServer = current;\n    } else if (current.ping === bestServer.ping) {\n      if (current.fps > bestServer.fps) {\n        bestServer = current;\n      }\n    }\n  } \n  else {\n    const pingDiff = current.ping - bestServer.ping;\n    \n    if (pingDiff < -5) {\n      bestServer = current;\n    } else if (Math.abs(pingDiff) <= 5) {\n      if (current.playing > bestServer.playing) {\n        bestServer = current;\n      }\n    }\n  }\n}\n\nreturn {\n  success: true,\n  selected_mode: mode,\n  best_server_id: bestServer.id,\n  stats: {\n    ping: bestServer.ping,\n    fps: Math.round(bestServer.fps * 100) / 100,\n    players: bestServer.playing,\n    maxPlayers: bestServer.maxPlayers\n  },\n  all_details: bestServer\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "a4c75e95-fdd8-4251-b915-55da919f3352",
      "name": "Respond with Success",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1424,
        -32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.5
    },
    {
      "id": "20811785-435c-4455-afe3-6812f4500500",
      "name": "Success",
      "type": "n8n-nodes-base.set",
      "position": [
        1216,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "39e13503-08fd-4c66-b2b2-ca1ad8566481",
              "name": "success",
              "type": "boolean",
              "value": true
            },
            {
              "id": "830ee81a-b493-457d-b03a-bdde9b1ad184",
              "name": "result",
              "type": "string",
              "value": "=roblox://experiences/start?placeId={{ $('Auto Config').item.json.plid }}&gameInstanceId={{ $json.best_server_id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "47986606-ccf8-4c54-b39c-39eddb6ac36f",
      "name": "Auto Redirect?",
      "type": "n8n-nodes-base.if",
      "position": [
        992,
        -96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "396de655-c0c0-4ad4-8e83-5fbcd055ff0e",
              "operator": {
                "type": "boolean",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('Webhook').item.json.query.ar }}",
              "rightValue": ""
            },
            {
              "id": "1d820f68-a95f-4b7d-a193-cd599373dc83",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('Webhook').item.json.query.ar }}",
              "rightValue": ""
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.3
    },
    {
      "id": "8c4c0029-5a44-484d-acf5-cb5996d925f1",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1216,
        -176
      ],
      "parameters": {
        "options": {},
        "redirectURL": "=https://www.roblox.com/games/start?placeId={{ $('Auto Config').item.json.plid }}&instanceId={{ $json.best_server_id }}",
        "respondWith": "redirect"
      },
      "typeVersion": 1.5
    },
    {
      "id": "9699e09f-bfd2-4249-bf3d-7722cfa993bd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -224
      ],
      "parameters": {
        "width": 448,
        "height": 464,
        "content": "# Best Roblox Server Finder\nThis workflow helps gamers find the best Roblox server so that you can have a smooth Experience playing the game of your choice.\n\n## Setup\nNo Setup is Required. Having your Roblox Cookies are optional.\n\n\n\n\n\n\n\n\n\n\n\n## Example Usage:\n`https://YOUR_INSTANCE.com/brsf?plid=1234567890&mode=auto&ar=true`"
      },
      "typeVersion": 1
    },
    {
      "id": "d196df99-adba-41d6-975d-64ce65f40a75",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        -176
      ],
      "parameters": {
        "color": 3,
        "width": 160,
        "content": "Keep in mind, authorization is **not required!**"
      },
      "typeVersion": 1
    },
    {
      "id": "819763e4-dfc4-4d43-8844-72151bb67c37",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -368
      ],
      "parameters": {
        "color": 5,
        "height": 400,
        "content": "# Modes\n- Ping Mode: Purely selects the lowest numerical ping.\n- Latency Mode: Lowest ping + Highest FPS as a tie-breaker.\n- Auto Mode: If pings are within 5ms of each other, it prioritizes the server with the most players to ensure the game isn't \"dead.\""
      },
      "typeVersion": 1
    },
    {
      "id": "92787057-6fca-4f50-a855-5ba62ea2fc7c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        -224
      ],
      "parameters": {
        "width": 384,
        "height": 336,
        "content": "# Response Format\n```json\n{\n  \"succsess\":true,\n  \"result\":\"roblox:// Deeplink\"\n}\n```"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "219e0ea4-535d-4b68-8937-063e9435194a",
  "connections": {
    "Success": {
      "main": [
        [
          {
            "node": "Respond with Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Place ID Set?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error #1": {
      "main": [
        [
          {
            "node": "Respond with Error #1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto Config": {
      "main": [
        [
          {
            "node": "Fetch Public Servers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Place ID Set?": {
      "main": [
        [
          {
            "node": "Auto Config",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error #1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Auto Redirect?": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter For The Best": {
      "main": [
        [
          {
            "node": "Auto Redirect?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Public Servers": {
      "main": [
        [
          {
            "node": "Filter For The Best",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}