{
  "id": "QJrdfFS3mctGWzAf",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "School Admission Tracker",
  "tags": [],
  "nodes": [
    {
      "id": "186ec75a-37fe-468f-9761-b88507f22756",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -112,
        96
      ],
      "parameters": {
        "options": {},
        "batchSize": 1
      },
      "typeVersion": 2
    },
    {
      "id": "2f356275-ef2f-4590-be1d-9876a8fa14fd",
      "name": "Clean HTML",
      "type": "n8n-nodes-base.code",
      "position": [
        432,
        64
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const html = $json[\"data\"] || $json[\"body\"] || \"\";\n\n// Strip script/style tags and HTML tags\nconst cleaned = html\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, \"\")\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, \"\")\n  .replace(/<\\/?[^>]+(>|$)/g, \" \")\n  .replace(/\\s+/g, \" \")\n  .trim();\n\nreturn {\n  cleaned_text: cleaned,\n  school: $json.school,\n  url: $json.url\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "05100044-4996-4bcb-ab49-fe0c08391e3b",
      "name": "Continue Loop",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1392,
        80
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "ce34f0fb-32e9-496a-9a4a-d1b0cbdaab6a",
      "name": "Send email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        1200,
        -16
      ],
      "parameters": {
        "html": "=This is email notification email to inform you that school admission has open for  {{ $json.school }} class {{ $json.classes }}\n\nHere is my reasoning for the above conclusion:\n{{ $json.reason }}",
        "options": {},
        "subject": "=\u201cAdmissions Open at {{  $json.school }}",
        "toEmail": "user@example.com",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a5dd63ff-f12d-4ad3-87c4-89f118d89418",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1040,
        64
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7c67f6c0-dd32-4208-89c9-6f8ac274185d",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.admissions_open }}",
              "rightValue": "yes"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "94b9a5b3-d027-483f-bc73-774bd0f4317a",
      "name": "Get Website Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        64,
        -48
      ],
      "parameters": {
        "url": "={{$json[\"url\"]}}",
        "options": {}
      },
      "typeVersion": 3,
      "alwaysOutputData": false
    },
    {
      "id": "49519bff-a0dd-4f89-80ff-0d52e9bd755f",
      "name": "Append school Name",
      "type": "n8n-nodes-base.merge",
      "position": [
        256,
        64
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.2
    },
    {
      "id": "721a9019-379d-47bf-90b5-26c6d43c95d7",
      "name": "Are admissions Open",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        640,
        64
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an AI that detects school admission openings for year 2026-2027 for Pre-nursery with age criteria as 3 year+ as on Mar, 2026(optional). Analyze the following cleaned webpage text and return ONLY this JSON:\n{\n  \"admissions_open\": \"yes/no\",\n  \"school:: {{ $json.school }}\n  \"reason\": \"\",\n  \"classes\": \"\"\n}\nPage content:\n{{ $json[\"cleaned_text\"] }} "
            }
          ]
        }
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "14ff1a3f-0030-4808-9420-562d6ce865ba",
      "name": "Parse LLM response",
      "type": "n8n-nodes-base.code",
      "position": [
        912,
        64
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "let txt = $json.content.parts[0].text || \"\";\n\ntxt = txt.replace(/```json/gi, \"\")\n         .replace(/```/g, \"\")\n         .trim();\n\nlet parsed;\n\ntry {\n  parsed = JSON.parse(txt);\n} catch (e) {\n  parsed = {\n    admissions_open: \"no\",\n    reason: \"Gemini JSON parse failed\",\n    raw: txt\n  };\n}\n\nreturn parsed;"
      },
      "typeVersion": 2
    },
    {
      "id": "ef2eb8a2-c8ad-4051-9bbc-7f2c3c14ac8f",
      "name": "Shortlisted Schools",
      "type": "n8n-nodes-base.code",
      "position": [
        -320,
        96
      ],
      "parameters": {
        "jsCode": "return [\n  { school: \"Sanskriti School\", url: \"https://www.sanskritischool.edu.in/\"},\n  { school: \"DPS Mathura Road\", url: \"https://www.dpsmathuraroad.org/admission.php\" },\n  { school: \"Sardar Patel Vidyalaya\", url: \"https://spvdelhi.org/\" }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "1cb56620-95dd-4c0d-b723-98d5a53a1abc",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -240
      ],
      "parameters": {
        "width": 384,
        "height": 656,
        "content": "## School Admission Tracker via Web Scraping\n[Guide](https://docs.n8n.io/workflows/components/sticky-notes/)\n\n**How it works**\n**For each shortlisted school **, perform the following: \n1. Get the website content.\n2. Clean the HTML content \n3. LLM parses the text to detect school admission openings for year 2026-2027 for Pre-nursery. Based on LLM response:\na. If **yes**, then trigger an email notifying the school for which admissions are open.\nb. Else continue for next school.\n\n\n**How to setup**\n- Add Gemini API key within \"Are admissions open\" node\n- Add SMTP account credentials within \"Send Email\" node\n- Add From-Email and To-Email within \"Send Email\" node\n\n\n**Customize**\n- Update the school list within \"Shortlisted Schools\" node.\n- Modify \"Are admissions open\" node for respective year/ class. \n"
      },
      "typeVersion": 1
    },
    {
      "id": "fc7a91ff-4f65-4425-a899-b418c6fe1499",
      "name": "Daily Trigger",
      "type": "n8n-nodes-base.cron",
      "position": [
        -496,
        96
      ],
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "custom",
              "cronExpression": "0 0 * * *"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0573867a-3aa1-42b9-b18e-b62a620bdf50",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -144,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 704,
        "height": 480,
        "content": "## 1. Get School's Website Contents\n"
      },
      "typeVersion": 1
    },
    {
      "id": "789be24f-1209-420b-bc26-c9382a3c3489",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 752,
        "height": 480,
        "content": "## 2. Detect school admissions opening & trigger Alert \n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "873f3d8f-839e-44f5-94fe-5d3fbf0adc1c",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Send email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Continue Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean HTML": {
      "main": [
        [
          {
            "node": "Are admissions Open",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send email": {
      "main": [
        [
          {
            "node": "Continue Loop",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Continue Loop": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger": {
      "main": [
        [
          {
            "node": "Shortlisted Schools",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "Get Website Content",
            "type": "main",
            "index": 0
          },
          {
            "node": "Append school Name",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Append school Name": {
      "main": [
        [
          {
            "node": "Clean HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse LLM response": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Are admissions Open": {
      "main": [
        [
          {
            "node": "Parse LLM response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Website Content": {
      "main": [
        [
          {
            "node": "Append school Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shortlisted Schools": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}