{
  "name": "Recruitment Screening Workflow",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Candidate Application",
        "formDescription": "Submit your resume for screening.",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Full Name",
              "fieldType": "text",
              "requiredField": true
            },
            {
              "fieldLabel": "Email",
              "fieldType": "email",
              "requiredField": true
            },
            {
              "fieldLabel": "Resume (PDF)",
              "fieldType": "file",
              "requiredField": true
            },
            {
              "fieldLabel": "Job Applied For",
              "fieldType": "text",
              "requiredField": true
            }
          ]
        }
      },
      "name": "Candidate Intake Form",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [
        240,
        300
      ],
      "notes": "This is the public-facing form. n8n hosts this automatically once activated."
    },
    {
      "parameters": {
        "url": "={{ $env.SCORING_API_URL }}",
        "method": "POST",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "resume_file",
              "value": "={{ $json['Resume (PDF)'] }}"
            },
            {
              "name": "jd_text",
              "value": "={{ $json['Job Applied For'] }}"
            },
            {
              "name": "prompt_version",
              "value": "v3"
            }
          ]
        }
      },
      "name": "Call Scoring API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        300
      ],
      "notes": "POSTs to a small local Flask/FastAPI wrapper around llm/scorer.py.\nSee n8n/README.md for the wrapper API contract."
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.match_score }}",
              "operation": "largerEqual",
              "value2": 70
            }
          ]
        }
      },
      "name": "Score >= Threshold?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        680,
        300
      ],
      "notes": "Threshold of 70 is a placeholder - tune based on your eval results."
    },
    {
      "parameters": {
        "fromEmail": "hiring@yourcompany.example",
        "toEmail": "={{ $('Candidate Intake Form').item.json['Email'] }}",
        "subject": "Interview Invitation - Next Steps",
        "text": "Hi {{ $('Candidate Intake Form').item.json['Full Name'] }},\n\nThanks for applying! We'd like to invite you to schedule an interview slot: [SCHEDULING LINK]\n\nBest,\nHiring Team"
      },
      "name": "Send Shortlist Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        900,
        220
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": "={{ $env.HIRING_LOG_SHEET_ID }}",
        "sheetName": "Candidates",
        "columns": {
          "value": {
            "Name": "={{ $('Candidate Intake Form').item.json['Full Name'] }}",
            "Email": "={{ $('Candidate Intake Form').item.json['Email'] }}",
            "Score": "={{ $json.match_score }}",
            "Status": "Shortlisted"
          }
        }
      },
      "name": "Log to Sheet (Shortlisted)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        900,
        380
      ],
      "notes": "Swap for an Excel node if logging directly to the UiPath-produced Excel file instead."
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": "={{ $env.HIRING_LOG_SHEET_ID }}",
        "sheetName": "Candidates",
        "columns": {
          "value": {
            "Name": "={{ $('Candidate Intake Form').item.json['Full Name'] }}",
            "Email": "={{ $('Candidate Intake Form').item.json['Email'] }}",
            "Score": "={{ $json.match_score }}",
            "Status": "Not Shortlisted"
          }
        }
      },
      "name": "Log to Sheet (Rejected)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        900,
        460
      ]
    }
  ],
  "connections": {
    "Candidate Intake Form": {
      "main": [
        [
          {
            "node": "Call Scoring API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Scoring API": {
      "main": [
        [
          {
            "node": "Score >= Threshold?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score >= Threshold?": {
      "main": [
        [
          {
            "node": "Send Shortlist Email",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Sheet (Shortlisted)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log to Sheet (Rejected)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}