{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "2b5644dc-c9ae-4d2b-865a-e9eec8d6eb19",
      "name": "Main \u2014 Overview & Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -272
      ],
      "parameters": {
        "width": 400,
        "height": 748,
        "content": "## \ud83c\udf93 Onboarding Video Quiz Builder\n\n### How it works\nUser submits a training video URL via form. The workflow sends the video to WayinVideo for transcription, waits 45 seconds, then polls until the transcript is ready. Once ready, an AI agent (GPT) reads the full transcript and generates the exact number of MCQ questions requested. The final quiz is saved to a Google Sheet.\n\n### Setup\n1. Add your WayinVideo API key \u2014 replace `YOUR_WAYINVIDEO_API_KEY` in nodes 2 and 4\n2. Add your OpenAI API key in the `OpenAI \u2014 Chat Model` node\n3. Connect Google Sheets OAuth2 credentials in node 7\n4. Replace `YOUR_GOOGLE_SHEET_ID` in node 7 with your actual Sheet ID\n5. Ensure your Google Sheet has a tab named **Quiz Bank** with columns: Department, Video URL, Total Questions, Quiz Questions, Generated On\n\n### Customization tips\n- Swap `gpt-4o-mini` for a stronger model in the OpenAI node for higher quality questions\n- Increase the Wait time (node 3) if transcription fails on longer videos\n- Edit the AI prompt in node 6 to change question format, language, or difficulty level"
      },
      "typeVersion": 1
    },
    {
      "id": "b8bfedb0-4cf3-444b-add9-4736788414c6",
      "name": "Section \u2014 Input",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        464,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 212,
        "content": "## \ud83d\udccb Step 1 \u2014 User Input\nForm collects video URL, department topic, and desired question count."
      },
      "typeVersion": 1
    },
    {
      "id": "aca32979-4d2d-4d2d-b6f4-278d9d797489",
      "name": "Section \u2014 Transcription",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 560,
        "height": 132,
        "content": "## \ud83c\udfac Steps 2\u20134 \u2014 Transcription\nSubmits video to WayinVideo, waits 45s, then fetches the completed transcript."
      },
      "typeVersion": 1
    },
    {
      "id": "ee433a12-11c4-4a39-9f10-1e77fe873557",
      "name": "Section \u2014 Status Check",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        -144
      ],
      "parameters": {
        "color": 5,
        "height": 148,
        "content": "## \u2705 Step 5 \u2014 Status Check\nChecks if transcript is ready. If not ready, loops back to wait."
      },
      "typeVersion": 1
    },
    {
      "id": "7126d80b-3780-4ef8-906d-6fed223881ab",
      "name": "Warning \u2014 IF Node Empty Condition",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        256
      ],
      "parameters": {
        "color": 3,
        "width": 592,
        "height": 208,
        "content": "## \u26a0\ufe0f WARNING \u2014 Empty IF Condition (Infinite Loop Risk)\nThe IF node has no condition configured. As-is, it will ALWAYS route to the false branch and loop back to the Wait node indefinitely.\n\n**Fix:** Set the condition to check `{{ $json.data.status }}` equals `SUCCEEDED` so the true branch runs the AI agent only when transcription is complete."
      },
      "typeVersion": 1
    },
    {
      "id": "3ab7baf4-cee3-49fd-a137-11c5dc59eeeb",
      "name": "Section \u2014 AI Quiz Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 360,
        "height": 148,
        "content": "## \ud83e\udd16 Step 6 \u2014 AI Quiz Generation\nGPT reads the full transcript and generates the exact number of MCQ questions with answers and references."
      },
      "typeVersion": 1
    },
    {
      "id": "cf25fee2-2c28-40b6-aac6-e736f7aff822",
      "name": "Section \u2014 Save to Sheet",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        -144
      ],
      "parameters": {
        "color": 5,
        "height": 148,
        "content": "## \ud83d\udcbe Step 7 \u2014 Save Results\nAppends quiz questions and metadata to the Google Sheet Quiz Bank tab."
      },
      "typeVersion": 1
    },
    {
      "id": "e8e59295-bd9d-4245-96ad-dc564cc81dd2",
      "name": "1. Form \u2014 Video URL + Topic",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        464,
        16
      ],
      "parameters": {
        "options": {},
        "formTitle": "\ud83c\udf93 Onboarding Video Quiz Builder",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Onboarding Video URL",
              "placeholder": "https://www.youtube.com/watch?v=xxxxxxx",
              "requiredField": true
            },
            {
              "fieldLabel": "Department / Topic",
              "placeholder": "e.g. HR Policy, IT Security, Sales Process",
              "requiredField": true
            },
            {
              "fieldLabel": "Number of Questions",
              "placeholder": "e.g. 10",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Onboarding video ka URL paste karo \u2014 AI automatically MCQ quiz questions banayega Google Sheet mein save karne ke liye."
      },
      "typeVersion": 2.2
    },
    {
      "id": "af92bb46-16a9-4051-add5-e722bdeaac07",
      "name": "2. WayinVideo \u2014 Submit Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        16
      ],
      "parameters": {
        "url": "https://wayinvideo-api.wayin.ai/api/v2/transcripts",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_url\": \"{{ $json['Onboarding Video URL'] }}\",\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": "c7ef9d60-d194-4494-bfa1-df9becc26576",
      "name": "3. Wait \u2014 45 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        976,
        16
      ],
      "parameters": {
        "amount": 45
      },
      "typeVersion": 1.1
    },
    {
      "id": "38b196f9-a711-4262-b808-0704896a3662",
      "name": "4. WayinVideo \u2014 Get Transcript",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1216,
        16
      ],
      "parameters": {
        "url": "=https://wayinvideo-api.wayin.ai/api/v2/transcripts/results/{{ $('2. WayinVideo \u2014 Submit Transcript').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": "4d872c79-889a-44f1-ba95-9e226b203762",
      "name": "5. If \u2014 Transcript Status Check",
      "type": "n8n-nodes-base.if",
      "position": [
        1408,
        16
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "acf1e7a5-31e0-42ca-a51c-15bd82f36c16",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "e30ca2d7-53d8-4d71-8724-5bd7f84219fd",
      "name": "6. AI \u2014 Generate MCQ Quiz",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1648,
        0
      ],
      "parameters": {
        "text": "=You are a quiz creator. Create exactly {{ $('1. Form \u2014 Video URL + Topic').item.json['Number of Questions'] }} multiple choice questions (MCQs) only from the transcript provided. No more, no less \u2014 always 10 questions.\n\nRULES:\n- Use only information from the transcript. No general knowledge.\n- Each question must have 4 options: A, B, C, D\n- Only one option is correct\n- Wrong options should be close but clearly wrong based on the transcript\n- Questions should cover facts, numbers, rules, steps mentioned in the video\n- No repeated questions\n- Keep language simple and easy to understand\n\nOUTPUT FORMAT \u2014 use this exact format for every question:\n\nQ[number]: [Question]\nA) [Option]\nB) [Option]\nC) [Option]\nD) [Option]\nCorrect Answer: [A / B / C / D]\nReference: [Speaker name and approximate time]\n---\n\nEXAMPLE:\n\nQ1: How many paid leaves does an employee get per year?\nA) 8 days\nB) 10 days\nC) 12 days\nD) 15 days\nCorrect Answer: C\nReference: Speaker 1 \u2014 around 2 min 15 sec\n---\n\nIMPORTANT:\n- Always generate exactly {{ $('1. Form \u2014 Video URL + Topic').item.json['Number of Questions'] }} questions \u2014 this is mandatory\n- Output questions only \u2014 no intro text, no conclusion, no explanation\n- At the end write: TOTAL QUESTIONS GENERATED: 10\n\nDepartment: {{ $('1. Form \u2014 Video URL + Topic').item.json['Department / Topic'] }}\n\nCreate exactly {{ $('1. Form \u2014 Video URL + Topic').item.json['Number of Questions'] }} questions from this transcript only.\n\nVideo Transcript:\n{{ $('4. WayinVideo \u2014 Get Transcript').item.json.data.transcript.map(s => '[' + s.speaker + ' | ' + Math.floor(s.start/1000) + 's] ' + s.text).join('\\n') }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 3.1
    },
    {
      "id": "10cd4a70-947e-497a-9917-9a2dfff26f12",
      "name": "OpenAI \u2014 Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1648,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "e5289047-af07-49f5-b2cb-ddfb71b3dc23",
      "name": "7. Google Sheets \u2014 Save Quiz Bank",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2000,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "Video URL": "={{ $('1. Form \u2014 Video URL + Topic').item.json['Onboarding Video URL'] }}",
            "Department": "={{ $('1. Form \u2014 Video URL + Topic').item.json['Department / Topic'] }}",
            "Generated On": "={{ $now }}",
            "Quiz Questions": "={{ $json.choices[0].message.content }}",
            "Total Questions": "={{ $('1. Form \u2014 Video URL + Topic').item.json['Number of Questions'] }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Quiz Bank"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.5
    }
  ],
  "connections": {
    "OpenAI \u2014 Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "6. AI \u2014 Generate MCQ Quiz",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "3. Wait \u2014 45 Seconds": {
      "main": [
        [
          {
            "node": "4. WayinVideo \u2014 Get Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "6. AI \u2014 Generate MCQ Quiz": {
      "main": [
        [
          {
            "node": "7. Google Sheets \u2014 Save Quiz Bank",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Form \u2014 Video URL + Topic": {
      "main": [
        [
          {
            "node": "2. WayinVideo \u2014 Submit Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4. WayinVideo \u2014 Get Transcript": {
      "main": [
        [
          {
            "node": "5. If \u2014 Transcript Status Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. If \u2014 Transcript Status Check": {
      "main": [
        [
          {
            "node": "6. AI \u2014 Generate MCQ Quiz",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "3. Wait \u2014 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. WayinVideo \u2014 Submit Transcript": {
      "main": [
        [
          {
            "node": "3. Wait \u2014 45 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}