{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "eadabcf2-059a-4624-8642-25f798604dcd",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        17600,
        5408
      ],
      "parameters": {
        "color": 7,
        "width": 680,
        "height": 484,
        "content": "## Employee Onboarding Orchestrator\nVersion 1.0.0 \u2014 HR\n\nAutomates the complete Day 0-30 onboarding sequence. Provisions a Google Workspace account, sends a Slack welcome, creates a Notion onboarding page with a 5-task checklist, and sends a welcome email. Checks task completion at Day 7 \u2014 alerts the manager if tasks are incomplete \u2014 then sends a Day 30 completion message.\n\nOnly credentials need to be configured. All parameters, prompts, and logic are ready to use."
      },
      "typeVersion": 1
    },
    {
      "id": "8ac7a181-a2e1-4f2f-8732-739dbf76d05d",
      "name": "Prerequisites",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18304,
        5408
      ],
      "parameters": {
        "color": 5,
        "width": 520,
        "height": 484,
        "content": "## Prerequisites\n- Google Workspace Admin SDK\n  (Google OAuth2 with admin.directory.user.create scope)\n- Slack Bot token with chat:write scope\n- Notion integration token with database access\n- Gmail OAuth2 credential\n\nWebhook payload (JSON POST):\n{\n  \"employee_name\": \"Jane Smith\",\n  \"employee_email\": \"jane@company.com\",\n  \"manager_email\": \"mgr@company.com\",\n  \"department\": \"Engineering\",\n  \"start_date\": \"2025-04-01\",\n  \"employee_id\": \"EMP-0042\"\n}"
      },
      "typeVersion": 1
    },
    {
      "id": "a0938ca8-04ef-42cc-9e71-985df02d99c8",
      "name": "Setup Required",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18848,
        5408
      ],
      "parameters": {
        "color": 3,
        "width": 520,
        "height": 484,
        "content": "## Setup Required\n1. Provision Google Account\n   Set Google OAuth2 credential\n2. Post Welcome Slack + Alert Manager\n   Set Slack credential\n   Replace C00GENERAL000 with real channel ID\n   Replace C00MANAGERS000 with real channel ID\n3. Create Notion Onboarding Page\n   Set Notion credential\n   Replace YOUR_ONBOARDING_DB_ID with real DB ID\n4. Check Completed Tasks\n   Same Notion credential and DB ID\n5. Send Welcome Email\n   Set Gmail credential"
      },
      "typeVersion": 1
    },
    {
      "id": "35c7dec4-af86-4b20-b5f4-2c08aeb14997",
      "name": "How It Works",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19392,
        5408
      ],
      "parameters": {
        "color": 4,
        "width": 500,
        "height": 484,
        "content": "## How It Works\n1. HR system sends a POST to the webhook\n   with the new employee details\n2. Google Workspace account is provisioned\n   with a temporary password\n3. Welcome message posted to #general\n4. Notion page created with 5-task checklist\n5. Welcome email sent with login details\n   and checklist summary\n6. Execution pauses 7 days\n7. Notion queried for tasks with Status = Done\n8. Fewer than 3 done: manager alert posted\n   3 or more done: execution pauses 23 more\n   days then sends Day 30 completion message"
      },
      "typeVersion": 1
    },
    {
      "id": "541332e4-356a-452d-9fbe-583e06afb872",
      "name": "New Employee Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        17840,
        6112
      ],
      "parameters": {
        "path": "onboarding",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "537d4372-24cd-4a3d-a5eb-b682844df5f8",
      "name": "Build Payload note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18000,
        5984
      ],
      "parameters": {
        "width": 250,
        "height": 60,
        "content": "Validates required fields and builds a clean structured payload"
      },
      "typeVersion": 1
    },
    {
      "id": "b8667aee-34ab-4c98-8b40-7fdbbeef178b",
      "name": "Build Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        18112,
        6112
      ],
      "parameters": {
        "jsCode": "const body = $json.body || $json;\nconst required = ['employee_name','employee_email','manager_email','department','start_date','employee_id'];\nfor (const f of required) {\n  if (!body[f]) throw new Error(`Missing required field: ${f}`);\n}\nconst parts = body.employee_name.trim().split(' ');\nreturn [{ json: {\n  employee_id:    body.employee_id,\n  employee_name:  body.employee_name.trim(),\n  first_name:     parts[0],\n  last_name:      parts.slice(1).join(' ') || parts[0],\n  employee_email: body.employee_email.toLowerCase().trim(),\n  manager_email:  body.manager_email.toLowerCase().trim(),\n  department:     body.department.trim(),\n  start_date:     body.start_date,\n  temp_password:  `Onboard@${body.employee_id}!`,\n  org_unit:       `/Departments/${body.department.trim()}`\n}}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7c4beb5f-de41-4575-b703-446f36bb19f7",
      "name": "Provision Google note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18304,
        5984
      ],
      "parameters": {
        "width": 270,
        "height": 60,
        "content": "Creates Google Workspace account via Admin Directory API"
      },
      "typeVersion": 1
    },
    {
      "id": "696bf943-055b-4ea6-9c2d-5a76f352a989",
      "name": "Provision Google Account",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        18368,
        6112
      ],
      "parameters": {
        "url": "https://admin.googleapis.com/admin/directory/v1/users",
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "neverError": true
            }
          }
        },
        "sendBody": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "nodeCredentialType": "googleOAuth2Api"
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "7d033aef-fb0c-49b7-8fed-84c12cf8c3b8",
      "name": "Welcome Slack note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18592,
        5984
      ],
      "parameters": {
        "width": 250,
        "height": 60,
        "content": "Posts welcome message to #general channel"
      },
      "typeVersion": 1
    },
    {
      "id": "1cdd894f-3923-4bfb-a744-f741093fefbf",
      "name": "Post Welcome Slack",
      "type": "n8n-nodes-base.slack",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        18624,
        6096
      ],
      "parameters": {
        "text": "=Welcome to the team, *{{ $('Build Payload').item.json.employee_name }}*! They are joining the *{{ $('Build Payload').item.json.department }}* team on {{ $('Build Payload').item.json.start_date }}.",
        "otherOptions": {
          "mrkdwn": true
        }
      },
      "retryOnFail": true,
      "typeVersion": 2.3,
      "waitBetweenTries": 2000
    },
    {
      "id": "05037c2e-e341-45e7-bf52-26e6bd8b3446",
      "name": "Create Notion note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        18880,
        5984
      ],
      "parameters": {
        "width": 280,
        "height": 60,
        "content": "Creates onboarding page with 5-task checklist in Notion database"
      },
      "typeVersion": 1
    },
    {
      "id": "4bed5373-c230-4beb-b592-aef144f5b447",
      "name": "Create Notion Onboarding Page",
      "type": "n8n-nodes-base.notion",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        18912,
        6080
      ],
      "parameters": {
        "title": "=Onboarding: {{ $('Build Payload').item.json.employee_name }}",
        "pageId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "blockUi": {
          "blockValues": [
            {
              "type": "to_do",
              "textContent": "Complete IT setup and laptop configuration"
            },
            {
              "type": "to_do",
              "textContent": "Read and sign the employee handbook"
            },
            {
              "type": "to_do",
              "textContent": "Complete mandatory compliance training"
            },
            {
              "type": "to_do",
              "textContent": "Schedule 1:1 with manager"
            },
            {
              "type": "to_do",
              "textContent": "Set up all required software accounts"
            }
          ]
        },
        "options": {}
      },
      "retryOnFail": true,
      "typeVersion": 2.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "a199944b-34ab-4cbc-a7cd-7e8a328b2e69",
      "name": "Send Welcome Email",
      "type": "n8n-nodes-base.gmail",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        19152,
        6064
      ],
      "parameters": {
        "sendTo": "={{ $('Build Payload').item.json.employee_email }}",
        "message": "=<h2>Welcome, {{ $('Build Payload').item.json.first_name }}!</h2><p>We are thrilled to have you join the <strong>{{ $('Build Payload').item.json.department }}</strong> team.</p><h3>Your login details</h3><p><strong>Email:</strong> {{ $('Build Payload').item.json.employee_email }}<br><strong>Temporary password:</strong> {{ $('Build Payload').item.json.temp_password }}<br>Please change your password on first login.</p><h3>Your first-week checklist</h3><ul><li>Complete IT setup and laptop configuration</li><li>Read and sign the employee handbook</li><li>Complete mandatory compliance training</li><li>Schedule a 1:1 with your manager</li><li>Set up all required software accounts</li></ul><p>Your onboarding page in Notion has been created. Your manager will share access shortly.</p>",
        "options": {},
        "subject": "=Welcome to the team, {{ $('Build Payload').item.json.first_name }}!"
      },
      "retryOnFail": true,
      "typeVersion": 2.1,
      "waitBetweenTries": 2000
    },
    {
      "id": "2633ac53-d4a9-4566-899d-f692d4e92bfc",
      "name": "Wait 7 Days note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19360,
        5952
      ],
      "parameters": {
        "width": 220,
        "height": 60,
        "content": "Pauses workflow execution for exactly 7 days"
      },
      "typeVersion": 1
    },
    {
      "id": "0de37003-31b0-4cc4-94b4-043cd3fad4ac",
      "name": "Wait 7 Days",
      "type": "n8n-nodes-base.wait",
      "position": [
        19424,
        6048
      ],
      "parameters": {
        "unit": "days",
        "amount": 7
      },
      "typeVersion": 1.1
    },
    {
      "id": "a64c0c42-821a-4264-ab77-f4fdc04efaa2",
      "name": "Check Tasks note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        19648,
        5952
      ],
      "parameters": {
        "width": 270,
        "height": 60,
        "content": "Queries Notion for tasks with Status = Done for this employee"
      },
      "typeVersion": 1
    },
    {
      "id": "d727625f-543d-49e4-a88f-226e0504860c",
      "name": "Check Completed Tasks",
      "type": "n8n-nodes-base.notion",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        19680,
        6048
      ],
      "parameters": {
        "limit": 10,
        "options": {},
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_ONBOARDING_DB_ID"
        }
      },
      "retryOnFail": true,
      "typeVersion": 2.2,
      "waitBetweenTries": 2000
    },
    {
      "id": "6d6cc602-e05b-4640-84ca-66123f0b614c",
      "name": "3+ Tasks Complete?",
      "type": "n8n-nodes-base.if",
      "position": [
        19920,
        6096
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c1",
              "operator": {
                "type": "number",
                "operation": "gte"
              },
              "leftValue": "={{ $items().length }}",
              "rightValue": 3
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ad88bf2a-e25c-4ff4-b6a5-8a96149f356c",
      "name": "Wait Until Day 30",
      "type": "n8n-nodes-base.wait",
      "position": [
        20192,
        5936
      ],
      "parameters": {
        "unit": "days",
        "amount": 23
      },
      "typeVersion": 1.1
    },
    {
      "id": "c0a8d7f8-b325-4d94-90c7-863a705c3283",
      "name": "Day 30 Completion Message",
      "type": "n8n-nodes-base.slack",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        20448,
        5936
      ],
      "parameters": {
        "text": "=*{{ $('Build Payload').item.json.employee_name }}* has completed their 30-day onboarding in the *{{ $('Build Payload').item.json.department }}* department. All tasks marked complete.",
        "otherOptions": {
          "mrkdwn": true
        }
      },
      "retryOnFail": true,
      "typeVersion": 2.3,
      "waitBetweenTries": 2000
    },
    {
      "id": "5d422142-8527-4757-937e-8ff59fbf8608",
      "name": "Alert Manager \u2014 Incomplete Tasks",
      "type": "n8n-nodes-base.slack",
      "onError": "continueErrorOutput",
      "maxTries": 3,
      "position": [
        20192,
        6336
      ],
      "parameters": {
        "text": "=*Action required:* {{ $('Build Payload').item.json.employee_name }} has fewer than 3 onboarding tasks completed after 7 days.\n\nEmployee: {{ $('Build Payload').item.json.employee_email }}\nDepartment: {{ $('Build Payload').item.json.department }}\nStart date: {{ $('Build Payload').item.json.start_date }}\n\nPlease follow up directly.",
        "otherOptions": {
          "mrkdwn": true
        }
      },
      "retryOnFail": true,
      "typeVersion": 2.3,
      "waitBetweenTries": 2000
    }
  ],
  "connections": {
    "Wait 7 Days": {
      "main": [
        [
          {
            "node": "Check Completed Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Payload": {
      "main": [
        [
          {
            "node": "Provision Google Account",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait Until Day 30": {
      "main": [
        [
          {
            "node": "Day 30 Completion Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3+ Tasks Complete?": {
      "main": [
        [
          {
            "node": "Wait Until Day 30",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Alert Manager \u2014 Incomplete Tasks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post Welcome Slack": {
      "main": [
        [
          {
            "node": "Create Notion Onboarding Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Welcome Email": {
      "main": [
        [
          {
            "node": "Wait 7 Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Employee Webhook": {
      "main": [
        [
          {
            "node": "Build Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Completed Tasks": {
      "main": [
        [
          {
            "node": "3+ Tasks Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Provision Google Account": {
      "main": [
        [
          {
            "node": "Post Welcome Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Notion Onboarding Page": {
      "main": [
        [
          {
            "node": "Send Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}