{
  "name": "06 - Employee Onboarding Automation System",
  "nodes": [
    {
      "id": "node-1",
      "name": "Webhook - New Employee",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "parameters": { "httpMethod": "POST", "path": "new-employee", "responseMode": "responseNode" }
    },
    {
      "id": "node-2",
      "name": "Code - Prepare Employee Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [480, 300],
      "parameters": {
        "jsCode": "const emp = $input.first().json;\nconst first = emp.first_name || '';\nconst last = emp.last_name || '';\nreturn [{ json: {\n  first_name: first, last_name: last,\n  full_name: `${first} ${last}`.trim(),\n  work_email: emp.work_email || `${first.toLowerCase()}.${last.toLowerCase()}@yourcompany.com`,\n  personal_email: emp.personal_email || emp.work_email,\n  department: emp.department || 'General',\n  job_title: emp.job_title || 'Team Member',\n  start_date: emp.start_date || new Date().toISOString().split('T')[0],\n  manager_email: emp.manager_email || 'manager@yourcompany.com',\n  temp_password: `Welcome${Math.random().toString(36).slice(-6).toUpperCase()}!`\n} }];"
      }
    },
    {
      "id": "node-3",
      "name": "Slack - Invite to Workspace",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [720, 160],
      "credentials": { "slackApi": { "id": "YOUR_SLACK_CREDENTIAL_ID", "name": "Slack account" } },
      "parameters": {
        "resource": "message",
        "operation": "send",
        "channel": { "__rl": true, "value": "#general", "mode": "name" },
        "text": "=👋 Please welcome *{{ $json.full_name }}* to the team!\n\n*Role:* {{ $json.job_title }}\n*Department:* {{ $json.department }}\n*Start Date:* {{ $json.start_date }}\n\nSay hi and help them feel at home! 🎉",
        "otherOptions": {}
      }
    },
    {
      "id": "node-4",
      "name": "Notion - Create Onboarding Page",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2.2,
      "position": [720, 300],
      "credentials": { "notionApi": { "id": "YOUR_NOTION_CREDENTIAL_ID", "name": "Notion account" } },
      "parameters": {
        "resource": "databasePage",
        "operation": "create",
        "databaseId": { "__rl": true, "value": "YOUR_ONBOARDING_DATABASE_ID", "mode": "id" },
        "title": "={{ $json.full_name }} — Onboarding Guide",
        "propertiesUi": {
          "propertyValues": [
            { "key": "Department", "type": "select", "selectValue": "={{ $json.department }}" },
            { "key": "Start Date", "type": "date", "dateValue": "={{ $json.start_date }}" },
            { "key": "Status", "type": "select", "selectValue": "In Progress" }
          ]
        }
      }
    },
    {
      "id": "node-5",
      "name": "Google Calendar - Schedule 30-day Check-in",
      "type": "n8n-nodes-base.googleCalendar",
      "typeVersion": 1.3,
      "position": [720, 440],
      "credentials": { "googleCalendarOAuth2Api": { "id": "YOUR_GOOGLE_CALENDAR_CREDENTIAL_ID", "name": "Google Calendar account" } },
      "parameters": {
        "resource": "event",
        "operation": "create",
        "calendarId": { "__rl": true, "value": "primary", "mode": "list", "cachedResultName": "primary" },
        "start": "={{ new Date(new Date($json.start_date).getTime() + 30*24*60*60*1000).toISOString() }}",
        "end": "={{ new Date(new Date($json.start_date).getTime() + 30*24*60*60*1000 + 30*60*1000).toISOString() }}",
        "additionalFields": {
          "summary": "=30-Day Check-in: {{ $json.full_name }}",
          "description": "=Monthly check-in with {{ $json.full_name }} ({{ $json.job_title }}) to review onboarding progress.",
          "attendees": "={{ $json.work_email }},{{ $json.manager_email }}"
        }
      }
    },
    {
      "id": "node-6",
      "name": "Gmail - Send Welcome Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [960, 160],
      "credentials": { "gmailOAuth2": { "id": "YOUR_GMAIL_CREDENTIAL_ID", "name": "Gmail account" } },
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $json.personal_email }}",
        "subject": "=Welcome to the team, {{ $json.first_name }}! 🎉 Your Day 1 Guide",
        "message": "=<h2>Welcome aboard, {{ $json.first_name }}!</h2><p>We're thrilled to have you join as <strong>{{ $json.job_title }}</strong> in <strong>{{ $json.department }}</strong>.</p><h3>Your Credentials:</h3><p>📧 Work Email: <strong>{{ $json.work_email }}</strong><br>🔑 Temp Password: <strong>{{ $json.temp_password }}</strong> (change on first login)</p><h3>What's Ready:</h3><ul><li>✅ Your Notion onboarding guide</li><li>✅ Slack workspace invitation</li><li>✅ 30-day check-in scheduled</li></ul><p>Start date: <strong>{{ $json.start_date }}</strong>. We can't wait!</p>",
        "options": { "isHtml": true }
      }
    },
    {
      "id": "node-7",
      "name": "Gmail - Notify Manager",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [960, 440],
      "credentials": { "gmailOAuth2": { "id": "YOUR_GMAIL_CREDENTIAL_ID", "name": "Gmail account" } },
      "parameters": {
        "resource": "message",
        "operation": "send",
        "sendTo": "={{ $json.manager_email }}",
        "subject": "=Your new hire {{ $json.full_name }} is all set!",
        "message": "=Hi! {{ $json.full_name }}'s onboarding is complete.\n\n✅ Slack invitation sent\n✅ Notion onboarding page created\n✅ 30-day check-in scheduled\n✅ Welcome email sent\n\nWork email: {{ $json.work_email }}\nStart date: {{ $json.start_date }}\n\nPlease reach out before Day 1!",
        "options": {}
      }
    },
    {
      "id": "node-8",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [1200, 300],
      "parameters": { "respondWith": "json", "responseBody": "={\n  \"status\": \"success\",\n  \"employee\": \"{{ $json.full_name }}\",\n  \"work_email\": \"{{ $json.work_email }}\"\n}" }
    }
  ],
  "connections": {
    "Webhook - New Employee": { "main": [[{ "node": "Code - Prepare Employee Data", "type": "main", "index": 0 }]] },
    "Code - Prepare Employee Data": {
      "main": [[
        { "node": "Slack - Invite to Workspace", "type": "main", "index": 0 },
        { "node": "Notion - Create Onboarding Page", "type": "main", "index": 0 },
        { "node": "Google Calendar - Schedule 30-day Check-in", "type": "main", "index": 0 }
      ]]
    },
    "Slack - Invite to Workspace": { "main": [[{ "node": "Gmail - Send Welcome Email", "type": "main", "index": 0 }]] },
    "Notion - Create Onboarding Page": { "main": [[{ "node": "Gmail - Notify Manager", "type": "main", "index": 0 }]] },
    "Google Calendar - Schedule 30-day Check-in": { "main": [[{ "node": "Respond to Webhook", "type": "main", "index": 0 }]] },
    "Gmail - Send Welcome Email": { "main": [[{ "node": "Respond to Webhook", "type": "main", "index": 0 }]] },
    "Gmail - Notify Manager": { "main": [[{ "node": "Respond to Webhook", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "active": false,
  "tags": [{ "name": "Portfolio" }, { "name": "HR" }, { "name": "Onboarding" }]
}
