{
  "name": "BWF_Crawler",
  "nodes": [
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.18.200.198:8080/get-draw-data",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tournament_name\": {{ $json.tmt_name.toJsonString() }},\n  \"tournament_url\": {{ $json.tmt_url.toJsonString() }}, \n  \"tournament_id\":  \"{{ $json.tmt_id}}\"\n  \n}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        176,
        -400
      ],
      "id": "6c38ebb5-bae7-484a-a3ee-c30e6bf8f511",
      "name": "Get Max Round",
      "retryOnFail": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=tmt_name: {{ $json.tmt_name }}",
        "hasOutputParser": true,
        "options": {
          "systemMessage": "You will receive a badminton tournament name (tmt_name).\n\nYour task is to clean the name by removing ONLY:\n1. The year (e.g., 2025, 2024, 2019, etc., including years inside parentheses).\n2. Sponsorship or organizer names (examples: HSBC, TotalEnergies, Yonex, Toyota, Daihatsu, Petronas, Badminton Asia, AQUASPRINGS etc.).\n3. Do NOT modify any other part of the name. Do NOT translate, rename, or remove any valid parts of the tournament name.\n\nImportant rules:\n- Keep regions, country names, rounds, \"Open\", \"Championships\", etc.\n- Keep anything that is part of the actual tournament identity.\n- After cleaning, output only the updated tournament name string, with no explanations and no quotation marks.\n\nOutput format:\n- Only the cleaned name as plain text, nothing else.\n\nExample:\nInput: Badminton Asia West Asia Regional Championships 2025 (Individual)\nOutput: Badminton Asia West Asia Regional Championships (Individual)"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        -464,
        -400
      ],
      "id": "dfdd4ad1-1a81-46a4-8a56-5218447ccc2d",
      "name": "AI Agent2",
      "retryOnFail": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsonSchemaExample": "[\n    {\n        \"tournament_name\": \"Bahrain 2025 Asian Youth Games\"\n    },\n    {\n        \"tournament_name\": \"Mangalore India International Challenge\"\n    },\n    {\n        \"tournament_name\": \"HYLO Open\"\n    },\n    {\n        \"tournament_name\": \"Lithuanian U17 International\"\n    }\n]",
        "autoFix": true
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.2,
      "position": [
        -288,
        -224
      ],
      "id": "3f4de270-14e4-4603-b010-2feaf3f5301d",
      "name": "Structured Output Parser2"
    },
    {
      "parameters": {
        "content": "# AI Agent for tmt name convert",
        "height": 536,
        "width": 684,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -592,
        -528
      ],
      "id": "abbe6441-3e59-4840-82bf-8ee5dfceda50",
      "name": "Sticky Note11"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -464,
        -128
      ],
      "id": "d711b23f-97f7-4319-bd45-c668dde07c91",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -832,
        -624
      ],
      "id": "ce1c71ce-21af-43ec-b1d2-c9fc15dfb4c9",
      "name": "Loop Over Items1",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const output = $input.first().json.tournaments;\nreturn output;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1040,
        -624
      ],
      "id": "9ccbb55e-6238-4222-9dad-626dfbe3a6a9",
      "name": "Code3",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -1488,
        -624
      ],
      "id": "b03a5aaf-b995-4d13-8ebc-0185a352e2a9",
      "name": "Schedule Trigger1",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "url": "http://10.18.200.198:8080/get-tournament-list",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1248,
        -624
      ],
      "id": "7bd33d8a-e7fa-4ef9-8da3-d018acb5e962",
      "name": "Crawl /calendar1",
      "retryOnFail": false
    },
    {
      "parameters": {
        "content": "# Crawl calendar",
        "height": 736,
        "width": 224
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1312,
        -864
      ],
      "typeVersion": 1,
      "id": "0fcdb635-bc53-45f0-8294-0ae1d7d08974",
      "name": "Sticky Note13"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1488,
        -464
      ],
      "id": "3f90ccda-27e6-46de-828f-6166b3fa188d",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "jsCode": "const orig_data = $(\"Loop Over Items1\").all(); // \u539f\u59cb\u8cc7\u6599\u9663\u5217\nconst input_data = $input.all();               // \u4f60\u63d0\u4f9b\u7684 $input\n\n// \u5047\u8a2d orig_data.length === input_data.length\uff0c\u5c0d\u61c9\u66f4\u65b0\nconst updated_data = orig_data.map((item, index) => {\n    const new_name = input_data[index].json.output[0].tournament_name;\n    return {\n        ...item.json,\n        tmt_name: new_name\n    };\n});\n\nreturn updated_data.map(d => ({ json: d }));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -96,
        -400
      ],
      "id": "21ca9a07-07b1-450e-be82-9b64193364ae",
      "name": "Code"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "1c2016f9-d6c6-484f-9e0f-4da0ab3bf4bc",
              "leftValue": "={{ $json.body.draw_data }}",
              "rightValue": "",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        416,
        -400
      ],
      "id": "632084af-9cb9-41e0-bb6b-11b71ee3c535",
      "name": "If draw_data not empty"
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "={{$workflow.id}}",
          "mode": "id"
        },
        "workflowInputs": {
          "mappingMode": "defineBelow",
          "value": {},
          "matchingColumns": [],
          "schema": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        },
        "options": {
          "waitForSubWorkflow": false
        }
      },
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.2,
      "position": [
        912,
        -416
      ],
      "id": "ea29cbc5-0a3c-4183-8010-9d02309e2b9d",
      "name": "Execute Workflow",
      "alwaysOutputData": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        -1472,
        256
      ],
      "id": "90998cd5-a402-4275-94d6-cdb11cde8441",
      "name": "When Executed by Another Workflow",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const output = [{\n  \"tmt_id\": $input.first().json.body.tournament_id,\n  \"tmt_name\": $input.first().json.body.draw_data.league_name,\n  \"tmt_level\": $('Code').first().json.tmt_level,\n  \"tmt_url\": $('Code').first().json.tmt_url,\n  \"tmt_code\": $('Code').first().json.tmt_code,\n  \"draw_data\":$input.first().json.body.draw_data\n}]\n\nreturn output"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        656,
        -416
      ],
      "id": "e1b238e5-84e9-4d24-9060-bcbb40729f16",
      "name": "Code1"
    },
    {
      "parameters": {
        "jsCode": "const dates = [\n  new Date(new Date().toISOString().split('T')[0] + 'T00:00:00Z').toISOString().split('T')[0],\n  new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().split('T')[0]\n];\n\nreturn dates.map(d => ({ json: { date: d } }));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -1264,
        256
      ],
      "id": "e375ee49-1a1b-4b29-b4bb-cda81837bdc1",
      "name": "Code4"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -1056,
        256
      ],
      "id": "8d28302c-6b95-492d-854a-2812d0a6482e",
      "name": "Loop Over Items2"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "3459e0fe-a6a9-429f-903d-96751615d1ab",
              "leftValue": "={{ $json.matches }}",
              "rightValue": "",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -624,
        320
      ],
      "id": "dbf1e56b-4558-4d37-913b-d9370af2de47",
      "name": "If has matches"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.18.200.198:8080/match-info",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tmt_id\": {{ $('When Executed by Another Workflow').first().json.tmt_id }},\n  \"tmt_level\": {{ $('When Executed by Another Workflow').first().json.tmt_level.toJsonString() }},\n  \"tmt_name\": {{ $('When Executed by Another Workflow').first().json.tmt_name.toJsonString() }},\n  \"draw_data\": {{ $('When Executed by Another Workflow').first().json.draw_data.toJsonString() }},\n  \"matches_data\": {{ $json.matches.toJsonString() }}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -384,
        304
      ],
      "id": "9cacc7fc-4046-4939-91ce-ea60b3ac38b5",
      "name": "Mapping current round",
      "retryOnFail": true,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const draw_data = $('When Executed by Another Workflow').first().json.draw_data;\nconst matches = $input.first().json.matches_data;\n\n// \u904e\u6ffe\u6389\u4efb\u4e00\u968a player1 \u7f3a\u5931\u7684\u6bd4\u8cfd\nconst filteredInput = matches.filter(match => match.player_home_1_id && match.player_away_1_id);\n\nfunction snake(input) {\n  return input.replace(/[A-Z]/g, letter => \"_\" + letter.toLowerCase());\n}\n\nreturn filteredInput.map(item => {\n  const row = item;\n\n  const converted = {};\n\n  // \u2b50 \u5148\u628a\u6240\u6709 Key \u8f49\u6210 snake_case\n  Object.keys(row).forEach(k => {\n    converted[snake(k)] = row[k];\n  });\n\n  // \u2b50 \u5f37\u5236 league_id \u70ba integer\n  if (converted.league_id !== undefined) {\n    converted.league_id = parseInt(converted.league_id, 10);\n  }\n\n  // \u2b50 \u8986\u5beb/\u65b0\u589e\u6b04\u4f4d\n  converted.is_active = true;\n  converted.status = false;\n\n  // \u2b50 \u66ff\u63db player null name / country \u8b8a\u7a7a\u5b57\u4e32\uff08\u66f4\u4e7e\u6de8\uff09\n  if (converted.player_home_2_name == null) converted.player_home_2_name = \"\";\n  if (converted.player_away_2_name == null) converted.player_away_2_name = \"\";\n  if (converted.player_home_2_country == null) converted.player_home_2_country = \"\";\n  if (converted.player_away_2_country == null) converted.player_away_2_country = \"\";\n\n  return converted;\n});"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -160,
        288
      ],
      "id": "a5984797-c677-4717-ab53-11fad4f4942a",
      "name": "Process Data"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1e12tGeDypDF5Yd6lENLwaOHL6wLnZySQlA_hJ6vkF2o",
          "mode": "list",
          "cachedResultName": "BWF",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1e12tGeDypDF5Yd6lENLwaOHL6wLnZySQlA_hJ6vkF2o/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "test",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": [
            {
              "id": "datetime",
              "displayName": "datetime",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "local_datetime",
              "displayName": "local_datetime",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "IANA_timezone",
              "displayName": "IANA_timezone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "league_id",
              "displayName": "league_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "league_name",
              "displayName": "league_name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "league_level",
              "displayName": "league_level",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "age_category",
              "displayName": "age_category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_player1",
              "displayName": "home_player1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_player2",
              "displayName": "home_player2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_country1",
              "displayName": "home_country1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_country2",
              "displayName": "home_country2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_player1",
              "displayName": "away_player1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_player2",
              "displayName": "away_player2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_country1",
              "displayName": "away_country1",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_country2",
              "displayName": "away_country2",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "court",
              "displayName": "court",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "mode",
              "displayName": "mode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "map_mode",
              "displayName": "map_mode",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "round",
              "displayName": "round",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "current_round",
              "displayName": "current_round",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "max_round",
              "displayName": "max_round",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "level",
              "displayName": "level",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_player1_id",
              "displayName": "home_player1_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "home_player2_id",
              "displayName": "home_player2_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_player1_id",
              "displayName": "away_player1_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "away_player2_id",
              "displayName": "away_player2_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "current_round",
              "displayName": "current_round",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "match_number",
              "displayName": "match_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "league_level",
              "displayName": "league_level",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        32,
        288
      ],
      "id": "202b2c0b-59bf-47ec-8935-f8decc8ac811",
      "name": "Append row in sheet",
      "retryOnFail": true,
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "const draw_data = $('When Executed by Another Workflow').first().json.draw_data;\nconst matches = $input.first().json.matches_data;\n\n// \u904e\u6ffe\u6389\u4efb\u4e00\u968a player1 \u7f3a\u5931\u7684\u6bd4\u8cfd\nconst filteredInput = matches.filter(match => match.player_home_1_id && match.player_away_1_id);\n\n\nfunction toCamel(input) {\n  return input.replace(/_([a-z0-9])/g, (_, letter) => letter.toUpperCase());\n}\n\nconst events = filteredInput.map(item => {\n  const row = item;\n\n  const converted = {};\n\n  // \u2b50 \u5148\u628a\u6240\u6709 Key \u8f49\u6210 camelCase\n  Object.keys(row).forEach(k => {\n    converted[toCamel(k)] = row[k];\n  });\n\n  // \u2b50 \u5f37\u5236 league_id \u70ba integer\n  if (converted.leagueId !== undefined) {\n    converted.leagueId = parseInt(converted.leagueId, 10);\n  }\n\n  // \u2b50 \u8986\u5beb/\u65b0\u589e\u6b04\u4f4d\n  converted.isActive = true;\n  converted.status = false;\n  converted.kickoffTime = new Date(converted.kickoffTime).toISOString();\n\n  // \u2b50 \u66ff\u63db player null name / country \u8b8a\u7a7a\u5b57\u4e32\uff08\u66f4\u4e7e\u6de8\uff09\n  if (converted.playerHome2Name == null) converted.playerHome2Name = \"\";\n  if (converted.playerAway2Name == null) converted.playerAway2Name = \"\";\n  if (converted.playerHome2Country == null) converted.playerHome2Country = \"\";\n  if (converted.playerAway2Country == null) converted.playerAway2Country = \"\";\n\n  return converted;\n});\n\n// \u2705 \u6700\u5f8c\u5305\u6210 events\nreturn { json: { events } };\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -192,
        528
      ],
      "id": "d27436fe-b3b4-479c-840f-b5e23c2a45cf",
      "name": "Preprocess",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://eventcollectingservice.kl.starixuat.com/BWF/events",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "events",
              "value": "={{ $json.events }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        0,
        528
      ],
      "id": "bbd34eb2-49a1-4503-8a40-77de67f3c008",
      "name": "Call BWF/events API",
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://10.18.200.198:8080/day-matches",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"tmt_code\": {{ $('When Executed by Another Workflow').item.json.tmt_code.toJsonString() }},\n  \"url\": {{ $('When Executed by Another Workflow').item.json.tmt_url.toJsonString() }},\n  \"date\": {{ $json.date.toJsonString() }}\n}",
        "options": {
          "timeout": 120000
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -832,
        320
      ],
      "id": "c373764e-bc2e-4f8d-a700-2d166df98909",
      "name": "Get matches",
      "retryOnFail": true,
      "maxTries": 2,
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "jsCode": "return [{ json: { done: true } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        208,
        528
      ],
      "id": "79560340-6d0e-4db4-9037-d94aa89e4d64",
      "name": "Code in JavaScript"
    }
  ],
  "connections": {
    "Get Max Round": {
      "main": [
        [
          {
            "node": "If draw_data not empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent2": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser2": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent2",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Structured Output Parser2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "AI Agent2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code3": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "Crawl /calendar1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Crawl /calendar1": {
      "main": [
        [
          {
            "node": "Code3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Crawl /calendar1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Get Max Round",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If draw_data not empty": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Code4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code4": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items2": {
      "main": [
        [],
        [
          {
            "node": "Get matches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has matches": {
      "main": [
        [
          {
            "node": "Mapping current round",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mapping current round": {
      "main": [
        [
          {
            "node": "Preprocess",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Data": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Preprocess": {
      "main": [
        [
          {
            "node": "Call BWF/events API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call BWF/events API": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get matches": {
      "main": [
        [
          {
            "node": "If has matches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Loop Over Items2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "timezone": "Asia/Taipei",
    "callerPolicy": "workflowsFromSameOwner",
    "availableInMCP": false
  },
  "versionId": "5592bfde-328f-450a-a2cf-1d1d53fb1485",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "AolgH9uMbv0HcR1k",
  "tags": []
}