{
  "name": "1. Auto-fetch AU Jobs",
  "nodes": [
    {
      "parameters": {},
      "id": "1",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "Keywords",
              "value": "Data Analyst"
            },
            {
              "name": "DaysToFetch",
              "value": "10"
            },
            {
              "name": "MaxPages",
              "value": "10"
            }
          ]
        },
        "options": {}
      },
      "id": "5",
      "name": "Job Search Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "let allJobs = [];\nlet keywords = $json.Keywords || 'Data Analyst';\nlet daterange = $json.DaysToFetch || '10';\nlet maxPages = parseInt($json.MaxPages) || 10;\n\nfor (let page = 1; page <= maxPages; page++) {\n  // classification=6281 restricts results specifically to Information & Communication Technology\n  let url = `https://www.seek.com.au/api/jobsearch/v5/search?siteKey=AU-Main&sourcesystem=houston&where=All%20Australia&classification=6281&keywords=${encodeURIComponent(keywords)}&daterange=${daterange}&page=${page}`;\n  \n  try {\n    let data;\n    if (typeof fetch !== 'undefined') {\n      let response = await fetch(url);\n      data = await response.json();\n    } else if (this.helpers && this.helpers.httpRequest) {\n      data = await this.helpers.httpRequest({ method: 'GET', url: url, json: true });\n    } else if (this.helpers && this.helpers.request) {\n      data = await this.helpers.request({ method: 'GET', uri: url, json: true });\n    } else {\n      throw new Error('No HTTP helper available in this n8n environment');\n    }\n    \n    if (data && data.data && data.data.length > 0) {\n      allJobs.push(...data.data);\n    } else {\n      break;\n    }\n  } catch (e) {\n    return [{ json: { error: e.message, url: url } }];\n  }\n}\n\nreturn allJobs.map(job => ({ json: job }));"
      },
      "id": "2",
      "name": "Fetch Jobs (SEEK API)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        300
      ]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "create",
        "databaseId": {
          "__rl": true,
          "value": "34712819-3fc4-8199-8d57-db17c97631c7",
          "mode": "id"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Job Title|title",
              "textContent": "={{ $json.title }}"
            },
            {
              "key": "Company|rich_text",
              "textContent": "={{ $json.companyName || ($json.advertiser && $json.advertiser.description) || 'Confidential' }}"
            },
            {
              "key": "Location|rich_text",
              "textContent": "={{ $json.locations && $json.locations.length > 0 ? $json.locations[0].label : 'Australia' }}"
            },
            {
              "key": "Status|select",
              "selectValue": "Inbox"
            },
            {
              "key": "Job Link|url",
              "urlValue": "={{ 'https://www.seek.com.au/job/' + $json.id }}"
            },
            {
              "key": "Rationale|rich_text",
              "textContent": "={{ $json.teaser }}"
            }
          ]
        }
      },
      "id": "4",
      "name": "Save to Notion",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [
        600,
        300
      ]
    }
  ],
  "connections": {
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Job Search Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Job Search Settings": {
      "main": [
        [
          {
            "node": "Fetch Jobs (SEEK API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Jobs (SEEK API)": {
      "main": [
        [
          {
            "node": "Save to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}