{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "41504202-bee4-4d1d-b899-b18cc5c7f090",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1072,
        -512
      ],
      "parameters": {
        "color": 4,
        "width": 524,
        "height": 1252,
        "content": "## Employee Onboarding Video to Training Clip Library \u2014 WayinVideo Find Moments + Google Drive + Sheets + Gmail\n\nFor HR teams, L&D managers, and People Operations teams who run recurring onboarding sessions and want to automatically clip and deliver specific training moments to new employees \u2014 without manually editing recordings or sending full hour-long videos. Submit the onboarding recording URL and a 4\u20136 word training topic query via the form. WayinVideo Find Moments API scans the full recording and returns up to 5 matching clips with HD 720 resolution, animated captions, and download links. Each clip is downloaded immediately (export links expire in 24 hours) and uploaded to Google Drive with a structured filename containing the employee name, department, clip index, and score. Every clip is saved to the Onboarding Clip Library Google Sheet with the Drive link. Gmail sends a personalized HTML welcome email to the new employee with the recording link and instructions to check their clips.\n\n## How it works\n- **1. Form \u2014 New Employee + Onboarding Details** collects the recording URL, employee name, email, department, start date, training topic query, and company name\n- **2. WayinVideo \u2014 Submit Find Moments** submits the URL and query \u2014 limit 5, HD 720, captions enabled, export enabled, no reframe\n- **3. Wait \u2014 90 Seconds** gives the API initial processing time\n- **4. WayinVideo \u2014 Get Clips Result** polls the find-moments results endpoint\n- **5. IF \u2014 Find Moments Complete?** checks for SUCCEEDED \u2014 if not, retries via 30-second wait\n- **7. Code \u2014 Split Each Clip** splits the clips array into one item per clip with title, export link, score, tags, description, and timestamps\n- **8. HTTP \u2014 Download Clip File** downloads each clip immediately before the export link expires\n- **9. Google Drive \u2014 Upload Clip** uploads each clip with a structured filename: EmployeeName_Department_Clip_N_Score_S.mp4\n- **10. Google Sheets \u2014 Save to Library** appends one row per clip with all 15 metadata fields including the constructed Drive link\n- **11. Gmail \u2014 Send Welcome Email** sends a personalized HTML email to the new employee with the recording URL and instructions\n\n## Set up steps\n1. In **2** and **4** \u2014 replace `YOUR_WAYINVIDEO_API_KEY`\n2. In **9. Google Drive \u2014 Upload Clip** \u2014 connect your Google Drive OAuth2 credential and replace `YOUR_GDRIVE_FOLDER_ID`\n3. In **10. Google Sheets \u2014 Save to Library** \u2014 connect your Google Sheets OAuth2 credential and replace `YOUR_GOOGLE_SHEET_ID`\n4. In **11. Gmail \u2014 Send Welcome Email** \u2014 connect your Gmail OAuth2 credential\n5. Create a Google Sheet tab named Onboarding Clip Library with columns: Employee Name, Employee Email, Department, Start Date, Company, Topic, Clip Title, Description, Timestamp, Score, Tags, Drive Link, Drive File ID, Onboarding Recording URL, Date Added\n\n## Query tips \u2014 use 4 to 6 descriptive words\nWorks: company culture and team values explanation \u2014 Works: HR policy and leave management overview \u2014 Works: tools and software walkthrough for new employees \u2014 Too vague: culture or HR or tools"
      },
      "typeVersion": 1
    },
    {
      "id": "937f7253-1618-4713-904f-cbf94a828fe1",
      "name": "Section \u2014 Form Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 296,
        "height": 388,
        "content": "## Form Input\nHR team submits the onboarding recording URL, employee name, email, department, start date, training topic query (4\u20136 descriptive words), and company name."
      },
      "typeVersion": 1
    },
    {
      "id": "08e8100b-819c-4b64-b7f5-6c466dcc3de7",
      "name": "Section \u2014 Find Moments Submit and Poll",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -96
      ],
      "parameters": {
        "color": 6,
        "width": 692,
        "height": 308,
        "content": "## WayinVideo Find Moments Submit and Poll\nSubmits the recording URL and training topic query \u2014 limit 5, HD 720, animated captions enabled, export enabled, no AI reframe. Waits 90 seconds then polls until SUCCEEDED."
      },
      "typeVersion": 1
    },
    {
      "id": "7c00ea55-c244-45b7-9351-54bf22561941",
      "name": "Section \u2014 Status Check and Retry Loop",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        528,
        -208
      ],
      "parameters": {
        "color": 6,
        "width": 292,
        "height": 644,
        "content": "## Find Moments Status Check and Retry Loop\nIF checks for SUCCEEDED status. TRUE proceeds to clip splitting. FALSE waits 30 seconds and polls again. Loop continues until results are ready."
      },
      "typeVersion": 1
    },
    {
      "id": "1b3e6c88-19d1-4792-857d-fd812bfb3f96",
      "name": "Section \u2014 Clip Split, Download, Drive Upload, and Sheet Save",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        -128
      ],
      "parameters": {
        "color": 6,
        "width": 980,
        "height": 324,
        "content": "## Clip Split, Download, Drive Upload, and Sheet Save\nSplits clips into one item each. Downloads each clip immediately before export links expire. Uploads to Google Drive with a structured filename. Saves all 15 metadata fields to Google Sheets with the constructed Drive link."
      },
      "typeVersion": 1
    },
    {
      "id": "5f8a4f46-fb41-4c78-86cc-75789bf92b21",
      "name": "Section \u2014 Gmail Welcome Email",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1920,
        -208
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 436,
        "content": "## Gmail Welcome Email\nSends a personalized HTML email to the new employee with the full recording link and instructions to check their training clips in the shared Google Sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "0fb6158d-939a-4ddd-8059-14075a47261d",
      "name": "1. Form \u2014 New Employee + Onboarding Details",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -448,
        16
      ],
      "parameters": {
        "options": {},
        "formTitle": "Employee Onboarding Clip Library Builder",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Onboarding Recording URL",
              "placeholder": "https://zoom.us/rec/xxxxxxx or YouTube/Loom link",
              "requiredField": true
            },
            {
              "fieldLabel": "New Employee Name",
              "placeholder": "e.g. Sarah Johnson",
              "requiredField": true
            },
            {
              "fieldLabel": "New Employee Email",
              "placeholder": "user@example.com",
              "requiredField": true
            },
            {
              "fieldLabel": "Department",
              "placeholder": "e.g. Marketing, Engineering, Sales, Customer Success",
              "requiredField": true
            },
            {
              "fieldLabel": "Start Date",
              "placeholder": "e.g. 2025-05-01",
              "requiredField": true
            },
            {
              "fieldLabel": "Training Topic to Extract",
              "placeholder": "e.g. company culture and team values explanation",
              "requiredField": true
            },
            {
              "fieldLabel": "Company Name",
              "placeholder": "e.g. Incrementors, Acme Corp",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Submit a new employee's details and the onboarding recording URL. AI will extract their specific training clips, upload to Drive, and email them the links automatically. Query tip: use 4-6 descriptive words \u2014 'company culture and team values', 'HR leave policy overview', 'tools and software walkthrough'"
      },
      "typeVersion": 2.2
    },
    {
      "id": "7fa18e2a-ca89-4814-9d33-0cbf8b8626a8",
      "name": "2. WayinVideo \u2014 Submit Find Moments",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -128,
        16
      ],
      "parameters": {
        "url": "https://wayinvideo-api.wayin.ai/api/v2/clips/find-moments",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_url\": \"{{ $json['Onboarding Recording URL'] }}\",\n  \"query\": \"{{ $json['Training Topic to Extract'] }}\",\n  \"project_name\": \"Onboarding \u2014 {{ $json['New Employee Name'] }} \u2014 {{ $json['Department'] }}\",\n  \"limit\": 5,\n  \"enable_export\": true,\n  \"resolution\": \"HD_720\",\n  \"enable_caption\": true,\n  \"caption_display\": \"original\",\n  \"cc_style_tpl\": \"temp-7\",\n  \"enable_ai_reframe\": false,\n  \"target_lang\": \"en\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cbac85f2-e030-47a6-9e8e-ae45ad1ea7bf",
      "name": "3. Wait \u2014 90 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        128,
        16
      ],
      "parameters": {
        "amount": 90
      },
      "typeVersion": 1.1
    },
    {
      "id": "cfa7a7db-a805-44a0-b32a-42b1817743c5",
      "name": "4. WayinVideo \u2014 Get Clips Result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        368,
        16
      ],
      "parameters": {
        "url": "=https://wayinvideo-api.wayin.ai/api/v2/clips/find-moments/results/{{ $('2. WayinVideo \u2014 Submit Find Moments').item.json.data.id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4595cc8a-ce00-4e3a-942e-b260c029cb1d",
      "name": "5. IF \u2014 Find Moments Complete?",
      "type": "n8n-nodes-base.if",
      "position": [
        608,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "status-check",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.data.status }}",
              "rightValue": "SUCCEEDED"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "70ac3a20-d6d6-42bf-88dd-b3ea42d88daf",
      "name": "6. Wait \u2014 30 Seconds Retry",
      "type": "n8n-nodes-base.wait",
      "position": [
        608,
        208
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "4ee7cd7a-1a4e-49d2-bd94-633c9e76cd1f",
      "name": "7. Code \u2014 Split Each Clip",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        0
      ],
      "parameters": {
        "jsCode": "// Split clips array into individual items\nconst clips = $json.data.clips || [];\n\nif (clips.length === 0) {\n  throw new Error('No clips found \u2014 try a more descriptive query (4-6 words). Check: https://wayin.ai/api-docs/find-moments/');\n}\n\nreturn clips.map(clip => ({\n  json: {\n    title: clip.title || 'Onboarding Clip',\n    export_link: clip.export_link || '',\n    score: clip.score || 0,\n    tags: Array.isArray(clip.tags) ? clip.tags : [],\n    desc: clip.desc || '',\n    begin_ms: clip.begin_ms || 0,\n    end_ms: clip.end_ms || 0,\n    idx: clip.idx || 0\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "9cc288e9-f2e9-405b-8a43-f5bb9b289c73",
      "name": "8. HTTP \u2014 Download Clip File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1184,
        0
      ],
      "parameters": {
        "url": "={{ $json.export_link }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "cbe94489-2753-4a85-ac03-470af90a133e",
      "name": "9. Google Drive \u2014 Upload Clip",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1424,
        0
      ],
      "parameters": {
        "name": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['New Employee Name'].replace(/ /g,'_') + '_' + $('1. Form \u2014 New Employee + Onboarding Details').item.json['Department'].replace(/ /g,'_') + '_Clip_' + ($('7. Code \u2014 Split Each Clip').item.json.idx + 1) + '_Score_' + $('7. Code \u2014 Split Each Clip').item.json.score + '.mp4' }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GDRIVE_FOLDER_ID"
        },
        "inputDataFieldName": "=data"
      },
      "typeVersion": 3
    },
    {
      "id": "1b74f017-4a80-46d2-a5f1-3777b4438720",
      "name": "10. Google Sheets \u2014 Save to Library",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1664,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Tags": "={{ $('7. Code \u2014 Split Each Clip').item.json.tags.join(', ') }}",
            "Score": "={{ $('7. Code \u2014 Split Each Clip').item.json.score }}",
            "Topic": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Training Topic to Extract'] }}",
            "Company": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Company Name'] }}",
            "Timestamp": "={{ Math.floor($('7. Code \u2014 Split Each Clip').item.json.begin_ms/1000) }}s \u2014 {{ Math.floor($('7. Code \u2014 Split Each Clip').item.json.end_ms/1000) }}s",
            "Clip Title": "={{ $('7. Code \u2014 Split Each Clip').item.json.title }}",
            "Date Added": "={{ $now.toFormat('dd MMMM yyyy HH:mm') }}",
            "Department": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Department'] }}",
            "Drive Link": "=https://drive.google.com/file/d/{{ $json.id }}/view",
            "Start Date": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Start Date'] }}",
            "Description": "={{ $('7. Code \u2014 Split Each Clip').item.json.desc }}",
            "Drive File ID": "={{ $json.id }}",
            "Employee Name": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['New Employee Name'] }}",
            "Employee Email": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['New Employee Email'] }}",
            "Onboarding Recording URL": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Onboarding Recording URL'] }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Onboarding Clip Library"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "d8cf84de-de67-41a5-acfe-cf2033955a16",
      "name": "11. Gmail \u2014 Send Welcome Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2000,
        0
      ],
      "parameters": {
        "sendTo": "={{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['New Employee Email'] }}",
        "message": "=<div style=\"font-family:Arial,sans-serif;max-width:600px;margin:0 auto;color:#222;\">\n<div style=\"background:#1a1a1a;padding:24px;text-align:center;\">\n  <h1 style=\"color:#fff;font-size:22px;margin:0;\">Your Training Clips Are Ready</h1>\n  <p style=\"color:#aaa;font-size:13px;margin:8px 0 0;\">{{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Company Name'] }} \u2014 Onboarding Library</p>\n</div>\n<div style=\"padding:24px;\">\n  <p>Hi {{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['New Employee Name'].split(' ')[0] }},</p>\n  <p>Welcome to the team! Your personalized onboarding training clips have been prepared and uploaded to Google Drive.</p>\n  <p><strong>Topic:</strong> {{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Training Topic to Extract'] }}</p>\n  <p><strong>Department:</strong> {{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Department'] }}</p>\n  <p><strong>Start Date:</strong> {{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Start Date'] }}</p>\n  <p style=\"font-size:13px;color:#555;\">Your HR team has shared your clip links in the <strong>Onboarding Clip Library</strong> Google Sheet. Please reach out to HR if you need access.</p>\n  <p><strong>Full Recording:</strong> <a href=\"{{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Onboarding Recording URL'] }}\" style=\"color:#1a1a1a;\">View Full Onboarding Session</a></p>\n</div>\n<div style=\"padding:16px 24px;background:#f9f9f9;\">\n  <p style=\"font-size:12px;color:#999;margin:0;\">Powered by WayinVideo Find Moments API \u2014 <a href=\"https://wayin.ai/api-docs/find-moments/\" style=\"color:#999;\">wayin.ai</a></p>\n</div>\n</div>",
        "options": {},
        "subject": "=Your Onboarding Training Clips Are Ready \u2014 Welcome to {{ $('1. Form \u2014 New Employee + Onboarding Details').item.json['Company Name'] }}"
      },
      "typeVersion": 2.1
    }
  ],
  "connections": {
    "3. Wait \u2014 90 Seconds": {
      "main": [
        [
          {
            "node": "4. WayinVideo \u2014 Get Clips Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7. Code \u2014 Split Each Clip": {
      "main": [
        [
          {
            "node": "8. HTTP \u2014 Download Clip File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. Wait \u2014 30 Seconds Retry": {
      "main": [
        [
          {
            "node": "4. WayinVideo \u2014 Get Clips Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8. HTTP \u2014 Download Clip File": {
      "main": [
        [
          {
            "node": "9. Google Drive \u2014 Upload Clip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9. Google Drive \u2014 Upload Clip": {
      "main": [
        [
          {
            "node": "10. Google Sheets \u2014 Save to Library",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. IF \u2014 Find Moments Complete?": {
      "main": [
        [
          {
            "node": "7. Code \u2014 Split Each Clip",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "6. Wait \u2014 30 Seconds Retry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. WayinVideo \u2014 Get Clips Result": {
      "main": [
        [
          {
            "node": "5. IF \u2014 Find Moments Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "10. Google Sheets \u2014 Save to Library": {
      "main": [
        [
          {
            "node": "11. Gmail \u2014 Send Welcome Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. WayinVideo \u2014 Submit Find Moments": {
      "main": [
        [
          {
            "node": "3. Wait \u2014 90 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Form \u2014 New Employee + Onboarding Details": {
      "main": [
        [
          {
            "node": "2. WayinVideo \u2014 Submit Find Moments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}