{
  "name": "HR Job Form Processor",
  "nodes": [
    {
      "id": "a1b2c3d4-1111-4111-8111-111111111101",
      "name": "Watch Form Responses",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 4,
      "position": [
        0,
        0
      ],
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "\u0627\u0633\u062a\u062c\u0627\u0628\u0627\u062a \u0627\u0644\u0641\u0648\u0631\u0645",
          "mode": "name"
        },
        "event": "rowAdded",
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 5,
              "unit": "minutes"
            }
          ]
        },
        "options": {}
      },
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a1b2c3d4-2222-4222-8222-222222222202",
      "name": "Extract Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        0
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1a1b1c1-0001-4001-8001-000000000001",
              "name": "company",
              "value": "={{ $json['\u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u0629'].toString().trim() }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0002-4002-8002-000000000002",
              "name": "title",
              "value": "={{ $json['\u0627\u0644\u0645\u0633\u0645\u0649 \u0627\u0644\u0648\u0638\u064a\u0641\u064a'].toString().trim() }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0003-4003-8003-000000000003",
              "name": "field",
              "value": "={{ $json['\u0627\u0644\u0645\u062c\u0627\u0644'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0004-4004-8004-000000000004",
              "name": "city",
              "value": "={{ $json['\u0627\u0644\u0645\u062f\u064a\u0646\u0629'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0005-4005-8005-000000000005",
              "name": "jobType",
              "value": "={{ $json['\u0646\u0648\u0639 \u0627\u0644\u0634\u063a\u0644'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0006-4006-8006-000000000006",
              "name": "salary",
              "value": "={{ $json['\u0627\u0644\u0631\u0627\u062a\u0628'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0007-4007-8007-000000000007",
              "name": "contact",
              "value": "={{ $json['\u0637\u0631\u064a\u0642\u0629 \u0627\u0644\u062a\u0648\u0627\u0635\u0644 \u0623\u0648 \u0631\u0627\u0628\u0637 \u0627\u0644\u062a\u0642\u062f\u064a\u0645'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0008-4008-8008-000000000008",
              "name": "description",
              "value": "={{ $json['\u0648\u0635\u0641 \u0627\u0644\u0648\u0638\u064a\u0641\u0629'] ?? '' }}",
              "type": "string"
            },
            {
              "id": "f1a1b1c1-0009-4009-8009-000000000009",
              "name": "spreadsheetId",
              "value": "YOUR_SPREADSHEET_ID",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "a1b2c3d4-3333-4333-8333-333333333303",
      "name": "Read Organized Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        480,
        0
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "\u0627\u0644\u0648\u0638\u0627\u064a\u0641 \u0627\u0644\u0645\u0646\u0638\u0645\u0629",
          "mode": "name"
        },
        "filtersUI": {},
        "options": {}
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a1b2c3d4-4444-4444-8444-444444444404",
      "name": "Check Duplicate",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        720,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Get the new job data from the Extract Fields node\nconst newCompany = ($('Extract Fields').item.json.company || '').toLowerCase().trim();\nconst newTitle = ($('Extract Fields').item.json.title || '').toLowerCase().trim();\n\n// Get all existing rows from the organized sheet\nconst existingRows = $input.all();\n\nlet isDuplicate = false;\nfor (const row of existingRows) {\n  const existingCompany = (row.json['\u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u0629'] || '').toString().toLowerCase().trim();\n  const existingTitle = (row.json['\u0627\u0644\u0645\u0633\u0645\u0649 \u0627\u0644\u0648\u0638\u064a\u0641\u064a'] || '').toString().toLowerCase().trim();\n  if (existingCompany === newCompany && existingTitle === newTitle) {\n    isDuplicate = true;\n    break;\n  }\n}\n\n// Pass all original field data forward with the duplicate flag\nreturn [{\n  json: {\n    ...$('Extract Fields').item.json,\n    isDuplicate\n  }\n}];"
      }
    },
    {
      "id": "a1b2c3d4-5555-4555-8555-555555555505",
      "name": "Is Duplicate?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        960,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "cond-0001-4001-8001-000000000001",
              "leftValue": "={{ $json.isDuplicate }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "a1b2c3d4-6666-4666-8666-666666666606",
      "name": "Skip - Duplicate",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1200,
        -80
      ],
      "parameters": {}
    },
    {
      "id": "a1b2c3d4-7777-4777-8777-777777777707",
      "name": "Append to Organized Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1200,
        80
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "\u0627\u0644\u0648\u0638\u0627\u064a\u0641 \u0627\u0644\u0645\u0646\u0638\u0645\u0629",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "\u0627\u0644\u062a\u0627\u0631\u064a\u062e": "={{ DateTime.now().setZone('Africa/Cairo').toFormat('yyyy-MM-dd') }}",
            "\u0627\u0633\u0645 \u0627\u0644\u0634\u0631\u0643\u0629": "={{ $json.company }}",
            "\u0627\u0644\u0645\u0633\u0645\u0649 \u0627\u0644\u0648\u0638\u064a\u0641\u064a": "={{ $json.title }}",
            "\u0627\u0644\u0645\u062c\u0627\u0644": "={{ $json.field }}",
            "\u0627\u0644\u0645\u062f\u064a\u0646\u0629": "={{ $json.city }}",
            "\u0646\u0648\u0639 \u0627\u0644\u0634\u063a\u0644": "={{ $json.jobType }}",
            "\u0627\u0644\u0631\u0627\u062a\u0628": "={{ $json.salary }}",
            "\u0627\u0644\u062a\u0648\u0627\u0635\u0644": "={{ $json.contact }}",
            "\u0627\u0644\u0648\u0635\u0641": "={{ $json.description }}",
            "\u0627\u0644\u062d\u0627\u0644\u0629": "active"
          },
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Watch Form Responses": {
      "main": [
        [
          {
            "node": "Extract Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Fields": {
      "main": [
        [
          {
            "node": "Read Organized Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Organized Sheet": {
      "main": [
        [
          {
            "node": "Check Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Duplicate": {
      "main": [
        [
          {
            "node": "Is Duplicate?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Duplicate?": {
      "main": [
        [
          {
            "node": "Skip - Duplicate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append to Organized Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    {
      "name": "hr-service",
      "id": ""
    }
  ]
}