{
  "name": "Employee Onboarding Orchestrator",
  "nodes": [
    {
      "id": "sn-overview", "name": "Overview", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [-240, -500],
      "parameters": { "content": "## Employee Onboarding Orchestrator\nVersion 1.0.0 — 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 — alerts the manager if tasks are incomplete — then sends a Day 30 completion message.\n\nOnly credentials need to be configured. All parameters, prompts, and logic are ready to use.", "height": 260, "width": 680, "color": 7 }
    },
    {
      "id": "sn-prereqs", "name": "Prerequisites", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [460, -500],
      "parameters": { "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}", "height": 260, "width": 520, "color": 5 }
    },
    {
      "id": "sn-setup", "name": "Setup Required", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [1000, -500],
      "parameters": { "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", "height": 260, "width": 520, "color": 3 }
    },
    {
      "id": "sn-how", "name": "How It Works", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [1540, -500],
      "parameters": { "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", "height": 260, "width": 500, "color": 4 }
    },
    {
      "id": "n-webhook", "name": "New Employee Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 2,
      "position": [0, 100],
      "webhookId": "onboarding-001",
      "parameters": { "httpMethod": "POST", "path": "onboarding", "responseMode": "responseNode", "options": {} }
    },
    {
      "id": "sni-payload", "name": "Build Payload note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [245, -35],
      "parameters": { "content": "Validates required fields and builds a clean structured payload", "height": 60, "width": 250 }
    },
    {
      "id": "n-payload", "name": "Build Payload", "type": "n8n-nodes-base.code", "typeVersion": 2,
      "position": [260, 100],
      "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}}];"
      }
    },
    {
      "id": "sni-google", "name": "Provision Google note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [505, -35],
      "parameters": { "content": "Creates Google Workspace account via Admin Directory API", "height": 60, "width": 270 }
    },
    {
      "id": "n-google", "name": "Provision Google Account", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2,
      "position": [520, 100],
      "parameters": {
        "method": "POST",
        "url": "https://admin.googleapis.com/admin/directory/v1/users",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api",
        "sendBody": true,
        "contentType": "json",
        "body": "={{ JSON.stringify({ primaryEmail: $json.employee_email, name: { givenName: $json.first_name, familyName: $json.last_name }, password: $json.temp_password, changePasswordAtNextLogin: true, orgUnitPath: $json.org_unit }) }}",
        "options": { "response": { "response": { "neverError": true } } }
      },
      "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "sni-slack1", "name": "Welcome Slack note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [765, -35],
      "parameters": { "content": "Posts welcome message to #general channel", "height": 60, "width": 250 }
    },
    {
      "id": "n-slack-welcome", "name": "Post Welcome Slack", "type": "n8n-nodes-base.slack", "typeVersion": 2.3,
      "position": [780, 100],
      "parameters": {
        "resource": "message", "operation": "post",
        "channel": "C00GENERAL000",
        "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, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "sni-notion", "name": "Create Notion note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [1025, -35],
      "parameters": { "content": "Creates onboarding page with 5-task checklist in Notion database", "height": 60, "width": 280 }
    },
    {
      "id": "n-notion", "name": "Create Notion Onboarding Page", "type": "n8n-nodes-base.notion", "typeVersion": 2.2,
      "position": [1040, 100],
      "parameters": {
        "resource": "page", "operation": "create",
        "databaseId": { "__rl": true, "value": "YOUR_ONBOARDING_DB_ID", "mode": "id" },
        "title": "=Onboarding: {{ $('Build Payload').item.json.employee_name }}",
        "propertiesUi": {
          "propertyValues": [
            { "key": "Employee Email|email", "emailValue": "={{ $('Build Payload').item.json.employee_email }}" },
            { "key": "Department|select", "selectValue": "={{ $('Build Payload').item.json.department }}" },
            { "key": "Start Date|date", "dateValue": "={{ $('Build Payload').item.json.start_date }}" },
            { "key": "Manager|email", "emailValue": "={{ $('Build Payload').item.json.manager_email }}" },
            { "key": "Status|select", "selectValue": "In Progress" }
          ]
        },
        "blockUi": {
          "blockValues": [
            { "type": "to_do", "textContent": "Complete IT setup and laptop configuration", "checked": false },
            { "type": "to_do", "textContent": "Read and sign the employee handbook", "checked": false },
            { "type": "to_do", "textContent": "Complete mandatory compliance training", "checked": false },
            { "type": "to_do", "textContent": "Schedule 1:1 with manager", "checked": false },
            { "type": "to_do", "textContent": "Set up all required software accounts", "checked": false }
          ]
        }
      },
      "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "n-email", "name": "Send Welcome Email", "type": "n8n-nodes-base.gmail", "typeVersion": 2.1,
      "position": [1300, 100],
      "parameters": {
        "sendTo": "={{ $('Build Payload').item.json.employee_email }}",
        "subject": "=Welcome to the team, {{ $('Build Payload').item.json.first_name }}!",
        "emailType": "html",
        "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": {}
      },
      "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "sni-wait7", "name": "Wait 7 Days note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [1545, -35],
      "parameters": { "content": "Pauses workflow execution for exactly 7 days", "height": 60, "width": 220 }
    },
    {
      "id": "n-wait7", "name": "Wait 7 Days", "type": "n8n-nodes-base.wait", "typeVersion": 1.1,
      "position": [1560, 100],
      "webhookId": "wait-7d-001",
      "parameters": { "resume": "timeInterval", "unit": "days", "amount": 7, "options": {} }
    },
    {
      "id": "sni-check", "name": "Check Tasks note", "type": "n8n-nodes-base.stickyNote", "typeVersion": 1,
      "position": [1805, -35],
      "parameters": { "content": "Queries Notion for tasks with Status = Done for this employee", "height": 60, "width": 270 }
    },
    {
      "id": "n-check-tasks", "name": "Check Completed Tasks", "type": "n8n-nodes-base.notion", "typeVersion": 2.2,
      "position": [1820, 100],
      "parameters": {
        "resource": "databasePage", "operation": "getAll",
        "databaseId": { "__rl": true, "value": "YOUR_ONBOARDING_DB_ID", "mode": "id" },
        "returnAll": false, "limit": 10,
        "filterJson": "={{ JSON.stringify({ filter: { and: [ { property: 'Employee Email', email: { equals: $('Build Payload').item.json.employee_email } }, { property: 'Status', select: { equals: 'Done' } } ] } }) }}",
        "options": {}
      },
      "retryOnFail": true, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "n-if-tasks", "name": "3+ Tasks Complete?", "type": "n8n-nodes-base.if", "typeVersion": 2.2,
      "position": [2080, 100],
      "parameters": {
        "conditions": {
          "options": { "typeValidation": "loose" },
          "conditions": [{ "id": "c1", "leftValue": "={{ $items().length }}", "rightValue": 3, "operator": { "type": "number", "operation": "gte" } }],
          "combinator": "and"
        }
      }
    },
    {
      "id": "n-wait30", "name": "Wait Until Day 30", "type": "n8n-nodes-base.wait", "typeVersion": 1.1,
      "position": [2340, -80],
      "webhookId": "wait-30d-001",
      "parameters": { "resume": "timeInterval", "unit": "days", "amount": 23, "options": {} }
    },
    {
      "id": "n-day30", "name": "Day 30 Completion Message", "type": "n8n-nodes-base.slack", "typeVersion": 2.3,
      "position": [2600, -80],
      "parameters": {
        "resource": "message", "operation": "post",
        "channel": "C00MANAGERS000",
        "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, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    },
    {
      "id": "n-alert", "name": "Alert Manager — Incomplete Tasks", "type": "n8n-nodes-base.slack", "typeVersion": 2.3,
      "position": [2340, 320],
      "parameters": {
        "resource": "message", "operation": "post",
        "channel": "C00MANAGERS000",
        "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, "maxTries": 3, "waitBetweenTries": 2000, "onError": "continueErrorOutput"
    }
  ],
  "connections": {
    "New Employee Webhook":          { "main": [[{ "node": "Build Payload",                    "type": "main", "index": 0 }]] },
    "Build Payload":                 { "main": [[{ "node": "Provision Google Account",          "type": "main", "index": 0 }]] },
    "Provision Google Account":      { "main": [[{ "node": "Post Welcome Slack",                "type": "main", "index": 0 }]] },
    "Post Welcome Slack":            { "main": [[{ "node": "Create Notion Onboarding Page",     "type": "main", "index": 0 }]] },
    "Create Notion Onboarding Page": { "main": [[{ "node": "Send Welcome Email",                "type": "main", "index": 0 }]] },
    "Send Welcome Email":            { "main": [[{ "node": "Wait 7 Days",                       "type": "main", "index": 0 }]] },
    "Wait 7 Days":                   { "main": [[{ "node": "Check Completed Tasks",             "type": "main", "index": 0 }]] },
    "Check Completed Tasks":         { "main": [[{ "node": "3+ Tasks Complete?",                "type": "main", "index": 0 }]] },
    "3+ Tasks Complete?": {
      "main": [
        [{ "node": "Wait Until Day 30",               "type": "main", "index": 0 }],
        [{ "node": "Alert Manager — Incomplete Tasks","type": "main", "index": 0 }]
      ]
    },
    "Wait Until Day 30": { "main": [[{ "node": "Day 30 Completion Message", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "settings": { "executionOrder": "v1", "saveManualExecutions": true, "callerPolicy": "workflowsFromSameOwner" },
  "staticData": null,
  "tags": ["HR", "Onboarding", "Slack", "Notion", "Gmail"],
  "triggerCount": 1,
  "active": false
}
