{
  "name": "CV parsing and candidate scoring into a sheet",
  "nodes": [
    {
      "parameters": {
        "content": "## CV parsing and candidate scoring into a sheet\n\nPortfolio demo only. This workflow is an original example for demonstration. It is not client work and it does not represent a deployment for any customer.\n\nRun **Run demo** to execute the offline rules engine. The live branch is used only when the incoming item sets `demo` to false and the placeholder credentials have been replaced.",
        "height": 220,
        "width": 520,
        "color": 4
      },
      "id": "fd0cb938-6c14-48f3-a6b2-ababa76ae2e1",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -40
      ]
    },
    {
      "parameters": {},
      "id": "860117e3-980d-4ed2-b1d0-719994c24773",
      "name": "Run demo",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        40,
        280
      ],
      "notes": "CLI and the n8n editor start here. An empty manual run loads the bundled sample.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "cv-parsing-candidate-scoring",
        "authentication": "none",
        "responseMode": "lastNode",
        "responseData": "firstEntryJson",
        "options": {}
      },
      "id": "485afd44-2b6a-416d-9080-68aa536052e7",
      "name": "Inbound webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        40,
        460
      ],
      "notes": "POST JSON to this path. Include demo:false only after credentials are connected.",
      "notesInFlow": true,
      "webhookId": "f9bb31a7-d2c1-42fb-bb85-9e8b27995d39"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "event": "messageReceived",
        "simple": true
      },
      "id": "676b1a36-bc5a-4374-8625-f7dd51ca9736",
      "name": "Gmail trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        40,
        640
      ],
      "credentials": {
        "gmailOAuth2": {
          "id": "PLACEHOLDER_GMAILOAUTH2",
          "name": "Gmail account"
        }
      },
      "notes": "Polls the mailbox once credentials replace the placeholder. Tests do not call Gmail.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const sample = {\n  \"demo\": true,\n  \"name\": \"Leila Haddad\",\n  \"email\": \"leila@example.com\",\n  \"role\": \"Automation engineer\",\n  \"years\": 5,\n  \"workAuth\": true,\n  \"resumeText\": \"Five years building JavaScript services, SQL reporting, and n8n workflows for HubSpot teams.\"\n};\nconst incoming = $input.first()?.json ?? {};\nconst provided = Object.keys(incoming).filter((key) => incoming[key] !== undefined && incoming[key] !== null && incoming[key] !== '');\nconst base = provided.length ? { ...sample, ...incoming } : { ...sample };\nconst flag = incoming.demo;\nbase.demo = !(flag === false || flag === 'false' || flag === 0 || flag === '0');\nreturn [{ json: base }];\n"
      },
      "id": "71fc0712-4e9d-4daa-bc14-19d387330e9c",
      "name": "Normalize input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        340,
        360
      ],
      "notes": "Merges the request over the bundled sample. demo stays true unless the caller explicitly turns it off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nconst produced = (() => {\n\nconst text = String(item.resumeText || item.cv || '').toLowerCase();\nconst must = ['javascript', 'sql'];\nconst nice = ['n8n', 'hubspot'];\nconst haveMust = must.filter((skill) => text.includes(skill));\nconst haveNice = nice.filter((skill) => text.includes(skill));\nconst experience = Number(item.years || (text.match(/(\\d+)\\s+\\+?\\s*years/) || [])[1] || 0);\nlet score = haveMust.length * 20 + haveNice.length * 8;\nif (experience >= 3) score += 15;\nif (item.workAuth === false) score -= 25;\nscore = Math.max(0, Math.min(100, score));\nconst route = haveMust.length < Math.ceil(must.length / 2) ? 'reject' : score >= 70 ? 'screen' : 'hold';\nconst record = {\n  name: item.name || 'Candidate',\n  email: item.email || '',\n  role: item.role || 'Open role',\n  score,\n  route,\n  haveMust: haveMust.join(', '),\n  haveNice: haveNice.join(', '),\n  experience,\n  title: (item.name || 'Candidate') + ' \u2014 ' + (item.role || 'role'),\n};\nreturn {\n  summary: record.name + ' scored ' + score + ' for ' + record.role + ' (' + route + ').',\n  route,\n  record,\n  slackText: route.toUpperCase() + ' ' + record.name + ' (' + score + ') for ' + record.role,\n  actions: [{ app: 'ATS', operation: route, payload: record }],\n};\n\n})();\nif (!produced || typeof produced.summary !== 'string' || !produced.summary.trim()) {\n  throw new Error('Apply rules must return a summary string');\n}\nreturn [{\n  json: {\n    ...item,\n    ...produced,\n    demo: item.demo !== false,\n  },\n}];\n"
      },
      "id": "b2d7ae0c-ddaf-4081-b72b-c31985f96172",
      "name": "Apply rules",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        620,
        360
      ],
      "notes": "Deterministic stand-in for the model or enrichment API. Replace or precede this with a live model node when you turn demo mode off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "f8d0c8f3-9279-4c8e-ae63-96dbaf160415",
              "leftValue": "={{ $json.demo }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "37e5390b-0d8d-4ed2-aef8-8016383241f5",
      "name": "Demo mode?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        360
      ],
      "notes": "True: package the offline result. False: run the credentialed apps.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nreturn [{\n  json: {\n    demo: true,\n    status: 'demo_ready',\n    workflow: 'cv-parsing-candidate-scoring',\n    summary: item.summary,\n    route: item.route ?? null,\n    record: item.record ?? {},\n    actions: item.actions ?? [],\n    slackText: item.slackText ?? item.summary,\n    notes: 'Demo mode did not call external apps. Send {\"demo\": false} after placeholder credentials are replaced.',\n  },\n}];\n"
      },
      "id": "bf4c08ac-7146-4d4d-9985-9aed9fc0d358",
      "name": "Package demo result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        180
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Candidates"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "323fafda-a8e3-4f0c-9bfe-a8a4f13e3d7d",
      "name": "Append Candidates",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1180,
        760
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "PLACEHOLDER_GOOGLESHEETSOAUTH2API",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#hiring"
        },
        "text": "={{ $json.slackText || $json.summary }}",
        "otherOptions": {}
      },
      "id": "43d890df-ed2d-4691-9529-34e1105e669e",
      "name": "Post #hiring",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1460,
        760
      ],
      "credentials": {
        "slackOAuth2Api": {
          "id": "PLACEHOLDER_SLACKOAUTH2API",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Live path\n\nReplace every `PLACEHOLDER_*` credential, then POST the sample with `\"demo\": false`.\n\nThe nodes on this branch use the `record` and `actions` fields produced by Apply rules.",
        "height": 180,
        "width": 420,
        "color": 6
      },
      "id": "0321cec8-e933-4f85-9766-7a1a155e3639",
      "name": "Live path",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        520
      ]
    }
  ],
  "connections": {
    "Run demo": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inbound webhook": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail trigger": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize input": {
      "main": [
        [
          {
            "node": "Apply rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply rules": {
      "main": [
        [
          {
            "node": "Demo mode?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Demo mode?": {
      "main": [
        [
          {
            "node": "Package demo result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append Candidates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Candidates": {
      "main": [
        [
          {
            "node": "Post #hiring",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "A resume's text is scored against must-have and nice-to-have skills. The route is screen, hold, or reject as a recommendation. The sheet is the lightweight ATS, and Slack hears about candidates worth a screen."
  },
  "active": false
}
