{
  "name": "Job Alert Automation",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 6
            }
          ]
        }
      },
      "id": "trigger",
      "name": "Every 6 Hours",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "=http://easycv:3000/api/jobs/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "keywords",
              "value": "={{ $json.user_keywords }}"
            },
            {
              "name": "location",
              "value": "={{ $json.user_location }}"
            },
            {
              "name": "remote",
              "value": "={{ $json.remote_preference }}"
            }
          ]
        },
        "options": {}
      },
      "id": "search-jobs",
      "name": "Search Job APIs",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.jobs.length }}",
              "operation": "larger",
              "value2": 0
            }
          ]
        }
      },
      "id": "has-new-jobs",
      "name": "Has New Jobs?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "url": "=http://easycv:3000/api/jobs/match",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "jobs",
              "value": "={{ $json.jobs }}"
            }
          ]
        }
      },
      "id": "match-profile",
      "name": "Match Against Profile",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        850,
        200
      ]
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.matchScore }}",
              "operation": "largerEqual",
              "value2": 70
            }
          ]
        }
      },
      "id": "high-match",
      "name": "Match Score >= 70?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1050,
        200
      ]
    },
    {
      "parameters": {
        "fromEmail": "easycv@yourdomain.com",
        "toEmail": "={{ $json.user_email }}",
        "subject": "\ud83c\udfaf New Job Match: {{ $json.job_title }} at {{ $json.company }}",
        "text": "We found a job that matches your profile!\n\n**{{ $json.job_title }}**\n{{ $json.company }} - {{ $json.location }}\n\nMatch Score: {{ $json.matchScore }}%\n\n{{ $json.description_preview }}\n\nView and apply: {{ $json.job_url }}\n\n---\nGenerate a tailored CV: http://localhost:3000/generate?job={{ $json.job_id }}"
      },
      "id": "send-email",
      "name": "Send Email Alert",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        1250,
        100
      ]
    },
    {
      "parameters": {
        "url": "=http://easycv:3000/api/jobs",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "job",
              "value": "={{ $json }}"
            },
            {
              "name": "source",
              "value": "n8n-automation"
            }
          ]
        }
      },
      "id": "save-job",
      "name": "Save to EasyCV",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        1250,
        300
      ]
    }
  ],
  "connections": {
    "Every 6 Hours": {
      "main": [
        [
          {
            "node": "Search Job APIs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Job APIs": {
      "main": [
        [
          {
            "node": "Has New Jobs?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has New Jobs?": {
      "main": [
        [
          {
            "node": "Match Against Profile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Match Against Profile": {
      "main": [
        [
          {
            "node": "Match Score >= 70?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Match Score >= 70?": {
      "main": [
        [
          {
            "node": "Send Email Alert",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Save to EasyCV",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "easycv",
    "job-search",
    "automation"
  ]
}