{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ba6d7b9b-4bfa-4e32-8323-300de16562e1",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -416,
        -576
      ],
      "parameters": {
        "path": "f1246a4a-6f75-4b09-81f8-661665dacc37",
        "options": {},
        "httpMethod": "POST",
        "authentication": "basicAuth"
      },
      "credentials": {
        "httpBasicAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "e9b853ac-ac83-4e73-a7c5-c3c0dae58176",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -208,
        -576
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b34140c1-cf13-4e90-af7b-baad7cf596f9",
              "name": "body.personal_info.full_name",
              "type": "string",
              "value": "={{ $json.body.personal_info.full_name }}"
            },
            {
              "id": "243331f7-fd94-4614-bd75-4f8673e24591",
              "name": "body.personal_info.preferred_name",
              "type": "string",
              "value": "={{ $json.body.personal_info.preferred_name }}"
            },
            {
              "id": "58063c61-865f-4abb-9f56-9bd66edb1902",
              "name": "body.personal_info.date_of_birth",
              "type": "string",
              "value": "={{ $json.body.personal_info.date_of_birth }}"
            },
            {
              "id": "5b54a51a-ea30-404b-a555-53d82e69ff5f",
              "name": "body.personal_info.personal_email",
              "type": "string",
              "value": "={{ $json.body.personal_info.personal_email }}"
            },
            {
              "id": "0d42f21b-c984-4547-819d-e7fcb82f684f",
              "name": "body.personal_info.contact_number",
              "type": "string",
              "value": "={{ $json.body.personal_info.contact_number }}"
            },
            {
              "id": "9f63d4e0-ef5c-4746-9724-b5bb9d7b761b",
              "name": "body.personal_info.address",
              "type": "object",
              "value": "={{ $json.body.personal_info.address }}"
            },
            {
              "id": "dfa961cf-d627-4799-9c7d-a6116ad808fa",
              "name": "body.personal_info.national_id.number",
              "type": "string",
              "value": "={{ $json.body.personal_info.national_id.number }}"
            },
            {
              "id": "431008c4-ed45-4a36-8a5b-dd7139f82349",
              "name": "body.personal_info.bank_account.account_holder_name",
              "type": "string",
              "value": "={{ $json.body.personal_info.bank_account.account_holder_name }}"
            },
            {
              "id": "d8450a2e-e712-4d02-b882-2c277b2c0d47",
              "name": "body.personal_info.bank_account.account_number",
              "type": "string",
              "value": "={{ $json.body.personal_info.bank_account.account_number }}"
            },
            {
              "id": "1ef4cba5-dfb7-4d50-9247-2ba66b5f1f72",
              "name": "body.personal_info.bank_account.ifsc_code",
              "type": "string",
              "value": "={{ $json.body.personal_info.bank_account.ifsc_code }}"
            },
            {
              "id": "4bb20c1a-95a8-4ad0-b361-360804f41661",
              "name": "body.personal_info.bank_account.bank_name",
              "type": "string",
              "value": "={{ $json.body.personal_info.bank_account.bank_name }}"
            },
            {
              "id": "0b75d2d3-5ede-4f07-b65d-973ac650e258",
              "name": "body.personal_info.emergency_contact.name",
              "type": "string",
              "value": "={{ $json.body.personal_info.emergency_contact.name }}"
            },
            {
              "id": "f8d30611-1ecd-4ecc-9bad-003ec6ccbec8",
              "name": "body.personal_info.emergency_contact.relation",
              "type": "string",
              "value": "={{ $json.body.personal_info.emergency_contact.relation }}"
            },
            {
              "id": "ffd5c808-2a27-4d8d-ba00-d0fc0c2783e1",
              "name": "body.personal_info.emergency_contact.contact_number",
              "type": "string",
              "value": "={{ $json.body.personal_info.emergency_contact.contact_number }}"
            },
            {
              "id": "01c83da8-d337-402a-b49b-ff2dc45724d6",
              "name": "body.personal_info.job_info.job_title",
              "type": "string",
              "value": "={{ $json.body.personal_info.job_info.job_title }}"
            },
            {
              "id": "69445e77-93e1-454f-850f-18911aaa0b79",
              "name": "body.personal_info.job_info.department",
              "type": "string",
              "value": "={{ $json.body.personal_info.job_info.department }}"
            },
            {
              "id": "998735df-636b-4b55-901c-caf285a53fec",
              "name": "body.personal_info.job_info.manager_name",
              "type": "string",
              "value": "={{ $json.body.personal_info.job_info.manager_name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d55a72d3-5a61-4072-bd4c-6beadb2f97a2",
      "name": "Generate Offer Letter",
      "type": "n8n-nodes-pdfbro.pdfBro",
      "position": [
        288,
        -576
      ],
      "parameters": {
        "operation": "offerLetter",
        "offerJobTitle": "={{ $('Edit Fields').item.json.body.personal_info.job_info.job_title }}",
        "offerDepartment": "={{ $('Edit Fields').item.json.body.personal_info.job_info.department }}",
        "offerManagerName": "={{ $('Edit Fields').item.json.body.personal_info.job_info.manager_name }}",
        "offerCandidateName": "={{ $('Edit Fields').item.json.body.personal_info.full_name }}",
        "offerCandidateEmail": "={{ $('Edit Fields').item.json.body.personal_info.personal_email }}",
        "offerCandidateAddress": "={{ $('Edit Fields').item.json.body.personal_info.address.street }} {{ $('Edit Fields').item.json.body.personal_info.address.city }}, {{ $('Edit Fields').item.json.body.personal_info.address.state }}, {{ $('Edit Fields').item.json.body.personal_info.address.zip_code }}, {{ $('Edit Fields').item.json.body.personal_info.address.country }}",
        "offerPaymentFrequency": "monthly",
        "offerCandidatePreferredName": "={{ $('Edit Fields').item.json.body.personal_info.preferred_name }}"
      },
      "typeVersion": 1
    },
    {
      "id": "80f9fd09-e2a0-4193-9b2a-ca43c783afa4",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -400,
        160
      ],
      "parameters": {
        "filters": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c690a85a-1394-48f2-aeea-a2a16a380b9e",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        304,
        336
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d23021a-4628-4923-90c6-33ae3543455c",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -192,
        160
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.From.includes('<') ? $json.From.match(/<([^>]+)>/)[1] : $json.From }}",
              "lookupColumn": "personal_email"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit?usp=drivesdk",
          "cachedResultName": "Employee DB"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6aaae1a7-6225-4d5b-9854-30a13ec84d82",
      "name": "Send a message1",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1344,
        128
      ],
      "parameters": {
        "sendTo": "={{ $('Get row(s) in sheet').item.json.personal_email }}",
        "message": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    /* Client-specific styles */\n    body, table, td, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }\n    table, td { mso-table-lspace: 0pt; mso-table-rspace: 0pt; }\n    img { -ms-interpolation-mode: bicubic; }\n\n    /* Reset styles */\n    img { border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; }\n    table { border-collapse: collapse !important; }\n    body { height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; background-color: #f4f6f8; }\n  </style>\n</head>\n<body style=\"background-color: #f4f6f8; margin: 0; padding: 0;\">\n\n  <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n    <tr>\n      <td align=\"center\" style=\"padding: 40px 10px;\">\n        \n        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"600\" style=\"background-color: #ffffff; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); overflow: hidden;\">\n          \n          <tr>\n            <td bgcolor=\"#4F46E5\" style=\"padding: 30px; text-align: center; background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);\">\n              <h1 style=\"color: #ffffff; margin: 0; font-size: 24px; font-weight: 700; letter-spacing: 1px;\">WELCOME TO THE TEAM</h1>\n            </td>\n          </tr>\n\n          <tr>\n            <td style=\"padding: 40px 40px 20px 40px;\">\n              <p style=\"color: #333333; font-size: 16px; line-height: 24px; margin-bottom: 20px;\">\n                Hi there,\n              </p>\n              <p style=\"color: #555555; font-size: 16px; line-height: 24px; margin-bottom: 30px;\">\n                We are thrilled to have you on board! To get you started with our internal tools and workplace setup, we have generated your temporary access credentials.\n              </p>\n\n              <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"background-color: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px;\">\n                <tr>\n                  <td style=\"padding: 20px;\">\n                    \n                    <p style=\"margin: 0 0 5px 0; color: #888888; font-size: 12px; text-transform: uppercase; font-weight: bold;\">Work Email</p>\n                    <p style=\"margin: 0 0 20px 0; color: #111827; font-size: 16px; font-family: monospace; font-weight: 600;\">\n                      {{ $json.primaryEmail }}\n                    </p>\n\n                    <p style=\"margin: 0 0 5px 0; color: #888888; font-size: 12px; text-transform: uppercase; font-weight: bold;\">Temporary Password</p>\n                    <p style=\"margin: 0; color: #111827; font-size: 18px; font-family: monospace; letter-spacing: 1px; background-color: #ffffff; padding: 10px; border: 1px dashed #d1d5db; border-radius: 4px; display: inline-block;\">\n                      {{ $('Code in JavaScript').item.json.id }}\n                    </p>\n\n                  </td>\n                </tr>\n              </table>\n\n              <p style=\"margin-top: 30px; padding: 15px; background-color: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; font-size: 14px; line-height: 20px; border-radius: 4px;\">\n                <strong>Security Notice:</strong> Upon your first login, you will be required to change this password to something personal and secure.\n              </p>\n\n              <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"margin-top: 30px;\">\n                <tr>\n                  <td align=\"center\">\n                    <a href=\"#\" style=\"background-color: #111827; color: #ffffff; padding: 14px 25px; border-radius: 6px; text-decoration: none; font-weight: bold; font-size: 16px; display: inline-block;\">Log In to Workplace</a>\n                  </td>\n                </tr>\n              </table>\n\n            </td>\n          </tr>\n\n          <tr>\n            <td style=\"padding: 30px; background-color: #f9fafb; text-align: center; border-top: 1px solid #eeeeee;\">\n              <p style=\"color: #9ca3af; font-size: 12px; margin: 0;\">\n                &copy; 2026 Company Name. All rights reserved.<br>\n                If you have trouble logging in, please contact IT Support.\n              </p>\n            </td>\n          </tr>\n        </table>\n        \n      </td>\n    </tr>\n  </table>\n\n</body>\n</html>",
        "options": {},
        "subject": "Inviting you to our Workspace"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "2489330d-9949-462e-892f-ad836000c46c",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        896,
        128
      ],
      "parameters": {
        "jsCode": "// 1. Get timestamp base (approx 8 chars)\nconst timePart = Date.now().toString(36);\n\n// 2. Get random base to fill the rest\nconst randomPart = Math.random().toString(36).substring(2);\n\n// 3. Combine and trim to exactly 16 characters\nconst finalValue = (timePart + randomPart).substring(0, 16);\n\n// 4. Return in strict n8n format\nreturn [\n  {\n    json: {\n      id: finalValue\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "7b7773f5-2d23-4eb6-b36c-cc5ca8a6db44",
      "name": "Update row in sheet1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1584,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "personal_email": "={{ $('Get row(s) in sheet').item.json.personal_email }}",
            "workplace_acc_created?": "yes"
          },
          "schema": [
            {
              "id": "full_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "full_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "preferred_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "preferred_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date_of_birth",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "date_of_birth",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personal_email",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "personal_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "contact_number",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "contact_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.street",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address.street",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.city",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address.city",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.state",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address.state",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.zip_code",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address.zip_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.country",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "address.country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "national_id.number",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "national_id.number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.account_holder_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "bank_account.account_holder_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.account_number",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "bank_account.account_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.ifsc_code",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "bank_account.ifsc_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.bank_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "bank_account.bank_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "emergency_contact.name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.relation",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "emergency_contact.relation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.contact_number",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "emergency_contact.contact_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.job_title",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_info.job_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.department",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_info.department",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.manager_name",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "job_info.manager_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "workplace_acc_created?",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "workplace_acc_created?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "personal_email"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit?usp=drivesdk",
          "cachedResultName": "Employee DB"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "9b85c9b0-7cf7-4d9d-a73e-d04155d1a2e0",
      "name": "check OL status",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        304,
        144
      ],
      "parameters": {
        "text": "=Check if the mail is an acceptance of offer letter from the candidate or not. respond with \"yes\" if it is an acceptance and if it's any other scenario just respond with \"no\"\n\nEmail Subject: {{ $('Gmail Trigger').item.json.Subject }}\nEmail Body: {{ $('Gmail Trigger').item.json.snippet }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "6d22910e-33d4-41d6-94a0-6bf31d580944",
      "name": "check for acceptance of OL",
      "type": "n8n-nodes-base.if",
      "position": [
        624,
        144
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8e0064ba-91d4-4c1c-8e09-79ebd0f75d80",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "yes"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "8650d586-4a34-4dfa-bf01-b2ee9dc606d9",
      "name": "Send Offer letter via mail",
      "type": "n8n-nodes-base.gmail",
      "position": [
        528,
        -576
      ],
      "parameters": {
        "sendTo": "={{ $('Edit Fields').item.json.body.personal_info.personal_email }}",
        "message": "=<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Offer Letter</title>\n  <style>\n    body {\n      font-family: Arial, sans-serif;\n      line-height: 1.6;\n      color: #333333;\n      margin: 0;\n      padding: 0;\n      background-color: #f7f7f7;\n    }\n    .container {\n      max-width: 600px;\n      margin: 30px auto;\n      background-color: #ffffff;\n      padding: 30px;\n      border-radius: 8px;\n      box-shadow: 0 2px 8px rgba(0,0,0,0.1);\n    }\n    h1 {\n      color: #2c3e50;\n    }\n    p {\n      margin-bottom: 20px;\n    }\n    .button {\n      display: inline-block;\n      background-color: #007BFF;\n      color: #ffffff;\n      padding: 12px 20px;\n      text-decoration: none;\n      border-radius: 5px;\n      font-weight: bold;\n    }\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <h1>Congratulations, {{ $('Edit Fields').item.json.body.personal_info.full_name }}!</h1>\n    <p>We are excited to offer you the position of <strong>{{ $('Edit Fields').item.json.body.personal_info.job_info.job_title }}</strong> at our company.</p>\n    <p>Please find your official offer letter attached with this email. Review it carefully and let us know if you have any questions.</p>\n    <p>We look forward to welcoming you to the team!</p>\n    <p>\n      <a href=\"YOUR_OFFER_LETTER_LINK_HERE\" class=\"button\">View Offer Letter</a>\n    </p>\n    <p>Best regards,<br>The HR Team</p>\n  </div>\n</body>\n</html>\n",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {}
            ]
          },
          "appendAttribution": false
        },
        "subject": "Offer Letter"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "da66a609-6c28-49e0-8842-6de7bd560b67",
      "name": "Save Candidates Details to DB",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        32,
        -576
      ],
      "parameters": {
        "columns": {
          "value": {
            "full_name": "={{ $json.body.personal_info.full_name }}",
            "address.city": "={{ $json.body.personal_info.address.city }}",
            "address.state": "={{ $json.body.personal_info.address.state }}",
            "date_of_birth": "={{ $json.body.personal_info.date_of_birth }}",
            "address.street": "={{ $json.body.personal_info.address.street }}",
            "contact_number": "={{ $json.body.personal_info.contact_number }}",
            "personal_email": "={{ $json.body.personal_info.personal_email }}",
            "preferred_name": "={{ $json.body.personal_info.preferred_name }}",
            "address.country": "={{ $json.body.personal_info.address.country }}",
            "address.zip_code": "={{ $json.body.personal_info.address.zip_code }}",
            "job_info.job_title": "={{ $json.body.personal_info.job_info.job_title }}",
            "national_id.number": "={{ $json.body.personal_info.national_id.number }}",
            "job_info.department": "={{ $json.body.personal_info.job_info.department }}",
            "job_info.manager_name": "={{ $json.body.personal_info.job_info.manager_name }}",
            "bank_account.bank_name": "={{ $json.body.personal_info.bank_account.bank_name }}",
            "bank_account.ifsc_code": "={{ $json.body.personal_info.bank_account.ifsc_code }}",
            "emergency_contact.name": "={{ $json.body.personal_info.emergency_contact.name }}",
            "workplace_acc_created?": "no",
            "emergency_contact.relation": "={{ $json.body.personal_info.emergency_contact.relation }}",
            "bank_account.account_number": "={{ $json.body.personal_info.bank_account.account_number }}",
            "bank_account.account_holder_name": "={{ $json.body.personal_info.bank_account.account_holder_name }}",
            "emergency_contact.contact_number": "={{ $json.body.personal_info.emergency_contact.contact_number }}"
          },
          "schema": [
            {
              "id": "full_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "full_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "preferred_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "preferred_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date_of_birth",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "date_of_birth",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "personal_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "personal_email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "contact_number",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "contact_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.street",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address.street",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.city",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address.city",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.state",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address.state",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.zip_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address.zip_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "address.country",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "address.country",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "national_id.number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "national_id.number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.account_holder_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "bank_account.account_holder_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.account_number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "bank_account.account_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.ifsc_code",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "bank_account.ifsc_code",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "bank_account.bank_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "bank_account.bank_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "emergency_contact.name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.relation",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "emergency_contact.relation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "emergency_contact.contact_number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "emergency_contact.contact_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.job_title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_info.job_title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.department",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_info.department",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "job_info.manager_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "job_info.manager_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "workplace_acc_created?",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "workplace_acc_created?",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "contact_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ahZKF-HznTfeLpvUDdywRAW_1MNv8TOG-QFlAoOapVk/edit?usp=drivesdk",
          "cachedResultName": "Employee DB"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "cb1a8381-bafd-487c-88d7-b171d2c034a5",
      "name": "Filter Only Candidate Emails",
      "type": "n8n-nodes-base.if",
      "position": [
        16,
        160
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "95587623-fd1b-469d-9816-a9650c4a1ca9",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json['workplace_acc_created?'] }}",
              "rightValue": "yes"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "0e31f6e7-5be5-4013-8bf0-277e98e972d4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -880
      ],
      "parameters": {
        "width": 512,
        "height": 672,
        "content": "## 1. Automated Offer Letter Creation and Sending\n\nThis intake engine automates the candidate-to-employee transition by eliminating manual document generation.\n\n### How it Works\n* **Intake:** A Webhook captures candidate data (personal info, bank details, and job specifics) from external sources.\n* **Processing:** An Edit Fields node parses the data to ensure variables are correctly mapped.\n* **Storage:** Candidate details are automatically saved to a central Google Sheets \"Employee DB\".\n* **Generation:** The PDFBro node creates a personalized PDF offer letter based on the specific job title and department.\n* **Delivery:** A Gmail node attaches the PDF and sends a customized congratulatory email.\n\n### Setup Steps\n* **Webhook:** Set up a POST method in n8n with Basic Auth for secure JSON payloads.\n* **Database:** Connect a Google Service Account to your \"Employee DB\" spreadsheet.\n* **Template:** Map `full_name` and `job_title` placeholders in the PDFBro node.\n* **Email:** Link your HR Gmail via OAuth2 and configure the HTML body.\n\nNote: This workflow needs a community node named \"n8n-nodes-pdfbro\""
      },
      "typeVersion": 1
    },
    {
      "id": "7ac41975-7e22-47a0-b546-ea4f755a5a5d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -160
      ],
      "parameters": {
        "width": 512,
        "height": 688,
        "content": "## 2. Offer Letter Acceptance Verifier & Work Account Creator\n\nThis intelligent workflow monitors replies and automatically provisions corporate access upon acceptance.\n\n### How it Works\n* **Monitoring:** A Gmail Trigger polls the inbox every minute for new candidate replies.\n* **Verification:** A Google Sheets node checks if the sender exists in the DB and remains onboarded.\n* **AI Analysis:** Google Gemini analyzes the email to confirm if the candidate accepted the offer.\n* **Security:** A JavaScript node generates a unique 16-character temporary password.\n* **Provisioning:** The Google Workspace node creates the account, forcing a password change on first login.\n* **Notification:** The system emails credentials to the candidate and updates the DB status.\n\n### Setup Steps\n* **AI:** Connect your Google Gemini API key to the AI Agent node.\n* **Admin:** Authorize the Workspace node with \"User Management\" privileges.\n* **Logic:** Set the JS node to output a `json.id` for password generation.\n* **Filter:** Configure an IF node to check `workplace_acc_created?` to prevent duplicate accounts."
      },
      "typeVersion": 1
    },
    {
      "id": "803a8882-0d33-4a05-a9cf-46af121dd968",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        -656
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 288,
        "content": "## Candidate Details Procurement"
      },
      "typeVersion": 1
    },
    {
      "id": "72c23658-a3a0-4805-b36e-d1cfd8140182",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        -656
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 288,
        "content": "## Offer Letter Creation and sending email"
      },
      "typeVersion": 1
    },
    {
      "id": "cbf0211c-e270-4377-8cba-5b7bab8d1010",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -416,
        64
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 288,
        "content": "## Strict Verification for candidates email"
      },
      "typeVersion": 1
    },
    {
      "id": "533031c8-ba14-46bd-b715-56bb607d59d7",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 448,
        "content": "## AI based Offer Letter Acceptance checker"
      },
      "typeVersion": 1
    },
    {
      "id": "e3494e3e-cf39-46c1-ac2d-d4ad5d5e62dd",
      "name": "Create a user",
      "type": "n8n-nodes-base.gSuiteAdmin",
      "position": [
        1120,
        128
      ],
      "parameters": {
        "domain": "blankarray.com",
        "lastName": "={{ $('Get row(s) in sheet').item.json.full_name.split(' - ')[0].split(' ')[1] }}",
        "password": "YOUR_CREDENTIAL_HERE",
        "username": "=vaar1",
        "firstName": "={{ $('Get row(s) in sheet').item.json.full_name.split(' - ')[0].split(' ')[0] }}",
        "additionalFields": {
          "changePasswordAtNextLogin": true
        }
      },
      "credentials": {
        "gSuiteAdminOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "784ff229-512e-4060-a471-b7138897961f",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        864,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 288,
        "content": "## Creates temporary passsword and create internal work account and send those details via email"
      },
      "typeVersion": 1
    },
    {
      "id": "c6727139-f845-404b-8567-5219e2569b38",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1488,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 288,
        "height": 288,
        "content": "## Change the status of work account delivery"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Save Candidates Details to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create a user": {
      "main": [
        [
          {
            "node": "Send a message1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message1": {
      "main": [
        [
          {
            "node": "Update row in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "check OL status": {
      "main": [
        [
          {
            "node": "check for acceptance of OL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Create a user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Filter Only Candidate Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Offer Letter": {
      "main": [
        [
          {
            "node": "Send Offer letter via mail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "check OL status",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "check for acceptance of OL": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Filter Only Candidate Emails": {
      "main": [
        [
          {
            "node": "check OL status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Candidates Details to DB": {
      "main": [
        [
          {
            "node": "Generate Offer Letter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}