{
  "name": "Resume Tailoring Workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "resume-tailor",
        "responseMode": "lastNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "=http://localhost:5000/api/jobs/{{ $json.body.jobId }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "options": {}
      },
      "name": "Get Job Details",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const job = $input.first().json;\nconst keywords = job.skills || [];\nconst requirements = job.requirements || [];\n\nreturn {\n  json: {\n    extractedKeywords: keywords,\n    requirements: requirements,\n    jobTitle: job.title,\n    company: job.company\n  }\n};"
      },
      "name": "Extract Keywords",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "resource": "text",
        "operation": "message",
        "modelId": "gpt-3.5-turbo",
        "messages": {
          "values": [
            {
              "role": "user",
              "content": "=Based on these job requirements: {{ $json.requirements.join(', ') }}, suggest resume improvements to highlight relevant experience."
            }
          ]
        },
        "options": {}
      },
      "name": "OpenAI Suggestions",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [
        850,
        300
      ]
    },
    {
      "parameters": {
        "url": "=http://localhost:5000/api/resume/{{ $json.resumeId }}/tailor",
        "method": "POST",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "jsonParameters": true,
        "options": {},
        "bodyParametersJson": "={{ {\"jobId\": $json.body.jobId, \"suggestions\": $json.message.content} }}"
      },
      "name": "Update Resume",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 3,
      "position": [
        1050,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Job Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Job Details": {
      "main": [
        [
          {
            "node": "Extract Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Keywords": {
      "main": [
        [
          {
            "node": "OpenAI Suggestions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Suggestions": {
      "main": [
        [
          {
            "node": "Update Resume",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}