{
  "name": "AI HRD Screening Automation",
  "nodes": [
    {
      "parameters": {
        "downloadAttachments": true,
        "options": {
          "forceReconnect": 30,
          "trackLastMessageId": true
        }
      },
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 2.1,
      "position": [
        -912,
        64
      ],
      "id": "dfa7cc57-beb2-41a6-89be-754c11317dd6",
      "name": "Email Trigger (IMAP)",
      "credentials": {
        "imap": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "pdf",
        "binaryPropertyName": "attachment_0",
        "options": {}
      },
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1.1,
      "position": [
        -704,
        64
      ],
      "id": "46001bab-3f0e-4861-bf2d-2cfd06d20021",
      "name": "Extract from File"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ {\n  model: \"llama-3.3-70b-versatile\",\n  messages: [\n    {\n      role: \"user\",\n      content: \"Kamu adalah asisten HRD yang bertugas screening CV pelamar untuk posisi \" + $('Edit Fields').item.json.posisi + \".\\n\\nKriteria yang dicari:\\n\" + $('Edit Fields').item.json.kriteria + \"\\n\\nBerikut isi CV pelamar:\\n\" + $('Extract from File').item.json.text + \"\\n\\nTolong berikan analisa dalam format PERSIS seperti ini (jangan ubah urutan/label):\\nNama: [nama lengkap pelamar]\\nSkor: [angka 0-100]\\nAlasan: [alasan singkat]\\nRekomendasi: [LANJUT atau TOLAK]\"\n    }\n  ]\n} }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.4,
      "position": [
        -288,
        64
      ],
      "id": "d56fce54-61a5-4946-b356-1a8e2c52ccc5",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "1be8268a-c37e-437b-8d6d-2ecfd9cad5c1",
              "leftValue": "={{ $json.choices[0].message.content }}",
              "rightValue": "LANJUT",
              "operator": {
                "type": "string",
                "operation": "contains"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        -80,
        64
      ],
      "id": "e8a265e8-88a1-4ee2-9c3f-225e29970299",
      "name": "If"
    },
    {
      "parameters": {
        "fromEmail": "hrdscreening.demo@gmail.com",
        "toEmail": "={{ $('Email Trigger (IMAP)').item.json.from.split('<')[1].split('>')[0] }}",
        "subject": "Undangan Interview - Junior Frontend Developer",
        "emailFormat": "text",
        "text": "Halo, terima kasih sudah melamar. CV Anda lolos screening awal, kami akan menghubungi untuk jadwal interview.",
        "options": {}
      },
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        128,
        -32
      ],
      "id": "d9c68f71-b23c-4ad3-bcb7-edc7a958266e",
      "name": "Send an Email",
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "fromEmail": "hrdscreening.demo@gmail.com",
        "toEmail": "={{ $('Email Trigger (IMAP)').item.json.from.split('<')[1].split('>')[0] }}",
        "subject": "Update Lamaran - Junior Frontend Developer",
        "emailFormat": "text",
        "text": "Halo, terima kasih atas ketertarikan Anda melamar posisi ini. Setelah kami tinjau, kualifikasi Anda belum sesuai dengan kebutuhan saat ini. Kami akan menyimpan CV Anda untuk kesempatan lain di masa depan",
        "options": {}
      },
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        128,
        160
      ],
      "id": "0a85a6fc-8b17-479c-8123-3b35c0777c4a",
      "name": "Send an Email1",
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "dbef27a4-c387-41af-945c-1daeb2955f9a",
              "name": "posisi",
              "value": "Junior Frontend Developer",
              "type": "string"
            },
            {
              "id": "cbf1aec7-d5fe-476f-a17e-895f6af5b323",
              "name": "kriteria",
              "value": "- Menguasai React.js atau framework frontend modern - Berpengalaman membangun aplikasi web (project pribadi/portfolio dihitung) - Familiar dengan integrasi API - Komunikatif dan mau belajar",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -496,
        64
      ],
      "id": "d69788fb-fab4-4f10-a081-6747f7d9a8f5",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs",
          "mode": "list",
          "cachedResultName": "HRD Screening Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Tanggal": "={{ $now }}",
            "Nama Pelamar": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Nama:\\s*(.+)/)?.[1]?.trim() || 'N/A' }}",
            "Email": "={{ $('Email Trigger (IMAP)').item.json.from.split('<')[1].split('>')[0] }}",
            "Posisi": "={{ $('Edit Fields').item.json.posisi }}",
            "Rekomendasi": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Rekomendasi:\\s*(\\w+)/)?.[1] || 'N/A' }}",
            "Skor": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Skor:\\s*(\\d+)/)?.[1] || 'N/A' }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Tanggal",
              "displayName": "Tanggal",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nama Pelamar",
              "displayName": "Nama Pelamar",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Posisi",
              "displayName": "Posisi",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Skor",
              "displayName": "Skor",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Rekomendasi",
              "displayName": "Rekomendasi",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        336,
        -32
      ],
      "id": "c4734347-e7e1-4860-bf8f-c8eb6436db72",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs",
          "mode": "list",
          "cachedResultName": "HRD Screening Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1cR7m0mmIgjoNhRIrL7ZEVWiDjlCx1q_d5LLwrGUnTqs/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Tanggal": "={{ $now }}",
            "Nama Pelamar": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Nama:\\s*(.+)/)?.[1]?.trim() || 'N/A' }}",
            "Email": "={{ $('Email Trigger (IMAP)').item.json.from.split('<')[1].split('>')[0] }}",
            "Posisi": "={{ $('Edit Fields').item.json.posisi }}",
            "Rekomendasi": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Rekomendasi:\\s*(\\w+)/)?.[1] || 'N/A' }}",
            "Skor": "={{ $('HTTP Request').item.json.choices[0].message.content.match(/Skor:\\s*(\\d+)/)?.[1] || 'N/A' }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Tanggal",
              "displayName": "Tanggal",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nama Pelamar",
              "displayName": "Nama Pelamar",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Email",
              "displayName": "Email",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Posisi",
              "displayName": "Posisi",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Skor",
              "displayName": "Skor",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Rekomendasi",
              "displayName": "Rekomendasi",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        336,
        160
      ],
      "id": "2ccdfec3-5955-4e9d-946e-3c25ead722ad",
      "name": "Append row in sheet2",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Email Trigger (IMAP)": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Send an Email",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send an Email1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send an Email": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send an Email1": {
      "main": [
        [
          {
            "node": "Append row in sheet2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "75f3b16a-414e-4f7a-b34b-94a698def934",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodeGroups": [],
  "id": "r4P7r6PdwOpvk0Ox",
  "tags": []
}