UK University Data Pipeline - Template

    Shared 11/20/2025

    2 views

    Visual Workflow

    JSON Code

    {
      "name": "UK University Data Pipeline - Template",
      "nodes": [
        {
          "id": "1",
          "name": "Start",
          "type": "n8n-nodes-base.manualTrigger",
          "position": [
            200,
            250
          ],
          "typeVersion": 1
        },
        {
          "id": "2",
          "name": "Fetch UCAS / Program Page",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            420,
            250
          ],
          "parameters": {
            "url": "https://example.com/api-or-program-url",
            "options": {
              "method": "GET"
            }
          },
          "typeVersion": 1
        },
        {
          "id": "3",
          "name": "Preprocess HTML / JSON",
          "type": "n8n-nodes-base.function",
          "position": [
            660,
            250
          ],
          "parameters": {
            "functionCode": "const raw = items[0].json;\n// Clean HTML/JSON before LLM\nlet html = raw.body || raw.html || raw;\nif (typeof html === 'string') {\n  html = html\n    .replace(/<script[\\s\\S]*?<\\/script>/gi, '')\n    .replace(/<style[\\s\\S]*?<\\/style>/gi, '')\n    .replace(/\\s+/g, ' ');\n}\nreturn [{ json: { cleaned: html } }];"
          },
          "typeVersion": 1
        },
        {
          "id": "4",
          "name": "OpenAI Extract (LLM)",
          "type": "n8n-nodes-base.openAi",
          "position": [
            900,
            250
          ],
          "parameters": {
            "model": "gpt-4o-mini",
            "messages": [
              {
                "role": "system",
                "content": "Extract structured program data from HTML. Return ONLY valid JSON."
              },
              {
                "role": "user",
                "content": "={{ 'HTML INPUT: ' + $json.cleaned }}"
              }
            ],
            "operation": "chatCompletion",
            "temperature": 0
          },
          "typeVersion": 2
        },
        {
          "id": "5",
          "name": "Parse LLM JSON",
          "type": "n8n-nodes-base.function",
          "position": [
            1150,
            250
          ],
          "parameters": {
            "functionCode": "let output = items[0].json;\nlet text = output.choices?.[0]?.message?.content || null;\nlet parsed;\ntry {\n  parsed = JSON.parse(text);\n} catch (e) {\n  parsed = { error: 'INVALID_JSON_FROM_LLM', raw: text };\n}\nreturn [{ json: parsed }];"
          },
          "typeVersion": 1
        },
        {
          "id": "6",
          "name": "Save to Postgres",
          "type": "n8n-nodes-base.postgres",
          "position": [
            1400,
            250
          ],
          "parameters": {
            "query": "INSERT INTO programs(data) VALUES(:data::jsonb);",
            "options": {
              "queryParams": "= { \"data\": JSON.stringify($json) }"
            },
            "operation": "executeQuery",
            "additionalFields": {}
          },
          "typeVersion": 1
        }
      ],
      "active": false,
      "versionId": "1.0.0",
      "connections": {
        "Start": {
          "main": [
            [
              {
                "node": "Fetch UCAS / Program Page",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Parse LLM JSON": {
          "main": [
            [
              {
                "node": "Save to Postgres",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "OpenAI Extract (LLM)": {
          "main": [
            [
              {
                "node": "Parse LLM JSON",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Preprocess HTML / JSON": {
          "main": [
            [
              {
                "node": "OpenAI Extract (LLM)",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Fetch UCAS / Program Page": {
          "main": [
            [
              {
                "node": "Preprocess HTML / JSON",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }