{
  "id": "r9ALq0ecJ0ICB7C9",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "YouTube Lecture \u2192 Chapter-wise Notes + MCQ Quiz",
  "tags": [],
  "nodes": [
    {
      "id": "def517bb-cf24-4578-8f51-e3f06ad8ad1f",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -560
      ],
      "parameters": {
        "color": 4,
        "width": 556,
        "height": 1172,
        "content": "## YouTube Lecture to Chapter-wise Study Notes and MCQ Quiz \u2014 WayinVideo + GPT-4o-mini + Google Sheets + Gmail\n\nFor students who want to turn any YouTube lecture into structured chapter-wise study notes and a multiple-choice quiz \u2014 automatically delivered to their inbox. Submit a YouTube video URL via the form. WayinVideo Transcription API v2 extracts the full spoken transcript as a structured JSON array with speaker labels and timestamps. GPT-4o-mini reads the transcript and generates chapter-wise notes (one chapter per major topic shift) plus 5 MCQ questions per chapter with correct answers and explanations. A Code node parses the structured output. Google Sheets logs the video URL, subject, and all generated content. Gmail sends a formatted HTML email with the full notes and quiz ready for revision.\n\n## How it works\n- **1. Form \u2014 YouTube Lecture URL** collects YouTube URL, subject name, chapter count, and email\n- **2. HTTP \u2014 WayinVideo Submit Transcription** submits the YouTube URL to WayinVideo Transcription API v2\n- **3. Code \u2014 Extract Task ID** validates the response and stores task id from data.id\n- **4. Wait \u2014 30 Seconds** gives WayinVideo initial processing time\n- **5. HTTP \u2014 Poll Transcription Status** polls the results endpoint until status is SUCCEEDED\n- **6. Code \u2014 Merge Poll Status** updates status and stores transcript segments array\n- **7. IF \u2014 Transcription Complete?** \u2014 TRUE (still processing): 30-second retry \u2192 re-polls | FALSE (SUCCEEDED): proceeds to prepare\n- **8. Wait \u2014 30 Second Retry** waits before re-polling\n- **9. Code \u2014 Prepare Transcript** converts the transcript segments array into clean readable text and merges form metadata\n- **10. AI Agent \u2014 Generate Notes and Quiz** uses GPT-4o-mini to produce chapter-wise notes plus 5 MCQ questions per chapter in strict JSON format\n- **OpenAI \u2014 GPT-4o-mini Model** language model attached to the AI Agent\n- **11. Code \u2014 Parse Notes and Quiz** strips markdown fences, parses JSON, builds HTML email\n- **12. Google Sheets \u2014 Log Study Session** appends video URL, subject, chapter count, and full content\n- **13. Gmail \u2014 Send Notes and Quiz** sends a formatted HTML email with all chapters and quiz questions\n\n## Set up steps\n1. In **2. HTTP \u2014 WayinVideo Submit Transcription** \u2014 replace `YOUR_WAYINVIDEO_API_KEY` with your WayinVideo API key (get it from wayin.ai/wayinvideo/api-dashboard). Purchase API units at the same dashboard before running\n2. In **5. HTTP \u2014 Poll Transcription Status** \u2014 replace `YOUR_WAYINVIDEO_API_KEY`\n3. In **OpenAI \u2014 GPT-4o-mini Model** \u2014 connect your OpenAI API credential\n4. In **12. Google Sheets \u2014 Log Study Session** \u2014 connect Google Sheets OAuth2 credential and replace `YOUR_GOOGLE_SHEET_ID`. Create a sheet tab named Study Log with columns: Date, YouTube URL, Subject, Lecture Title, Chapters Generated, Quiz Questions, Summary, Notes, Quiz, Status\n5. In **13. Gmail \u2014 Send Notes and Quiz** \u2014 connect Gmail OAuth2 credential"
      },
      "typeVersion": 1
    },
    {
      "id": "aa62487d-20dd-4353-9ff1-aa4799df4b6e",
      "name": "Section \u2014 Form Input and WayinVideo Transcription Submit",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -384,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 452,
        "height": 356,
        "content": "## Form Input and WayinVideo Transcription Submit\nForm collects YouTube URL, subject name, chapter count, and email. HTTP node submits to WayinVideo Transcription API v2 with Authorization: Bearer header and x-wayinvideo-api-version: v2."
      },
      "typeVersion": 1
    },
    {
      "id": "749231e4-4a1c-439f-aea7-09f2ad065fc1",
      "name": "Section \u2014 Task ID Extract, Initial Wait, Status Poll Loop",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -208
      ],
      "parameters": {
        "color": 6,
        "width": 1220,
        "height": 596,
        "content": "## Task ID Extract, Initial Wait, Status Poll Loop\nCode extracts task id from data.id. After 30s initial wait the results endpoint is polled. Merge Status stores transcript segments array. IF checks for SUCCEEDED status \u2014 TRUE branch retries every 30 seconds."
      },
      "typeVersion": 1
    },
    {
      "id": "821356ac-e824-4a7c-b77d-2f5ff8d99223",
      "name": "Section \u2014 Transcript Preparation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -256
      ],
      "parameters": {
        "color": 6,
        "width": 516,
        "height": 724,
        "content": "## Transcript Preparation\nCode node converts the transcript segments array (text + speaker + timestamps) into clean readable text. Merges form metadata for the AI agent. Trims to 12000 characters for GPT context."
      },
      "typeVersion": 1
    },
    {
      "id": "638fa256-5122-4307-ba2c-a95486790aae",
      "name": "Section \u2014 GPT-4o-mini Notes and Quiz Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2032,
        -352
      ],
      "parameters": {
        "color": 6,
        "width": 452,
        "height": 612,
        "content": "## GPT-4o-mini Notes and Quiz Generation\nAI Agent reads the transcript and produces chapter-wise study notes plus 5 MCQ questions per chapter in strict JSON format. Code node parses and formats the structured output into HTML email."
      },
      "typeVersion": 1
    },
    {
      "id": "e59d1425-d8e8-4c34-8dba-90f3eaceb730",
      "name": "Section \u2014 Google Sheets Log and Gmail Delivery",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        -272
      ],
      "parameters": {
        "color": 4,
        "width": 404,
        "height": 436,
        "content": "## Google Sheets Log and Gmail Delivery\nSheets logs the full study session with all generated content. Gmail sends the formatted HTML email with chapter notes and quiz questions."
      },
      "typeVersion": 1
    },
    {
      "id": "dd32e9bb-09cd-4e27-8571-0e32c804c90e",
      "name": "1. Form \u2014 YouTube Lecture URL",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -320,
        -80
      ],
      "parameters": {
        "options": {},
        "formTitle": "YouTube Lecture to Study Notes and Quiz",
        "formFields": {
          "values": [
            {
              "fieldLabel": "YouTube Lecture URL",
              "placeholder": "https://www.youtube.com/watch?v=...",
              "requiredField": true
            },
            {
              "fieldLabel": "Subject or Topic Name",
              "placeholder": "e.g. Introduction to Machine Learning, World War II, Organic Chemistry",
              "requiredField": true
            },
            {
              "fieldLabel": "Number of Chapters",
              "placeholder": "e.g. 3 (recommended: 3 to 6 depending on video length)",
              "requiredField": true
            },
            {
              "fieldType": "email",
              "fieldLabel": "Your Email",
              "placeholder": "your@email.com",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter a YouTube lecture URL and get chapter-wise notes plus a multiple choice quiz delivered to your email \u2014 ready for revision."
      },
      "typeVersion": 2.2
    },
    {
      "id": "c53f66c4-eb74-4ad7-a375-aa73b2d9eea4",
      "name": "2. HTTP \u2014 WayinVideo Submit Transcription",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -112,
        -80
      ],
      "parameters": {
        "url": "https://wayinvideo-api.wayin.ai/api/v2/transcripts",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_url\": \"{{ $json['YouTube Lecture URL'] }}\",\n  \"source_lang\": \"en\"\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "bdcbbf4a-c35d-4761-849a-11ce524a8568",
      "name": "3. Code \u2014 Extract Task ID",
      "type": "n8n-nodes-base.code",
      "position": [
        224,
        -96
      ],
      "parameters": {
        "jsCode": "const resp = $input.first().json;\n\n// WayinVideo v2 returns data.id as task identifier\nif (!resp.data || !resp.data.id) {\n  throw new Error('WayinVideo did not return a task id. Response: ' + JSON.stringify(resp));\n}\n\nconst formData = $('1. Form \u2014 YouTube Lecture URL').item.json;\n\nreturn [{\n  json: {\n    task_id: resp.data.id,\n    task_name: resp.data.name || '',\n    task_status: resp.data.status || 'CREATED',\n    youtube_url: formData['YouTube Lecture URL'],\n    subject: formData['Subject or Topic Name'],\n    chapter_count: formData['Number of Chapters'],\n    user_email: formData['Your Email'],\n    poll_count: 0,\n    submitted_at: new Date().toISOString()\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "7ef08f6d-eceb-44ba-868c-e04f6ec5784c",
      "name": "4. Wait \u2014 30 Seconds",
      "type": "n8n-nodes-base.wait",
      "position": [
        464,
        -96
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "d587d543-37c8-4af4-a4e8-67773200ea0c",
      "name": "5. HTTP \u2014 Poll Transcription Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        704,
        -96
      ],
      "parameters": {
        "url": "=https://wayinvideo-api.wayin.ai/api/v2/transcripts/results/{{ $json.task_id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "x-wayinvideo-api-version",
              "value": "v2"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0c55e767-31b4-420d-81fd-c83a610e34cd",
      "name": "6. Code \u2014 Merge Poll Status",
      "type": "n8n-nodes-base.code",
      "position": [
        944,
        -96
      ],
      "parameters": {
        "jsCode": "const resp = $input.first().json;\nconst prev = $('3. Code \u2014 Extract Task ID').item.json;\n\n// WayinVideo v2: status values are CREATED / QUEUED / ONGOING / SUCCEEDED / FAILED\n// transcript is array of {text, language, start, end, speaker} \u2014 available when SUCCEEDED\nreturn [{\n  json: {\n    ...prev,\n    status: resp.data?.status || 'ONGOING',\n    transcript_segments: resp.data?.transcript || null,\n    cost_usage: resp.data?.cost_usage || 0,\n    error_message: resp.data?.error_message || null,\n    poll_count: (prev.poll_count || 0) + 1\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "6883bd8e-e294-4e14-ba0c-35bed4a9f19f",
      "name": "7. IF \u2014 Transcription Complete?",
      "type": "n8n-nodes-base.if",
      "position": [
        1184,
        -96
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "not-succeeded",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "SUCCEEDED"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "49291d69-69e5-4d05-8288-9d44c6a879a1",
      "name": "8. Wait \u2014 30 Second Retry",
      "type": "n8n-nodes-base.wait",
      "position": [
        1184,
        64
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "3c0a76db-e700-4d41-93e8-0b37cc447eb0",
      "name": "9. Code \u2014 Prepare Transcript",
      "type": "n8n-nodes-base.code",
      "position": [
        1488,
        -80
      ],
      "parameters": {
        "jsCode": "// WayinVideo v2 returns transcript as JSON array \u2014 no separate file download needed\n// segments: [{text, language, start, end, speaker}, ...]\nconst meta = $('6. Code \u2014 Merge Poll Status').item.json;\n\nconst segments = meta.transcript_segments || [];\n\nif (segments.length === 0) {\n  throw new Error('Transcript segments are empty. Check if the video has clear audio and transcription succeeded.');\n}\n\n// Join all text segments into clean readable paragraph\nconst cleanTranscript = segments\n  .map(s => (s.text || '').trim())\n  .filter(t => t.length > 0)\n  .join(' ')\n  .replace(/\\s+/g, ' ')\n  .trim()\n  .slice(0, 12000);\n\nreturn [{\n  json: {\n    transcript: cleanTranscript,\n    transcript_length: cleanTranscript.length,\n    segment_count: segments.length,\n    youtube_url: meta.youtube_url,\n    subject: meta.subject,\n    chapter_count: meta.chapter_count,\n    user_email: meta.user_email,\n    submitted_at: meta.submitted_at\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "a63ac66d-0295-4b3f-9af5-88ac6319dc09",
      "name": "10. AI Agent \u2014 Generate Notes and Quiz",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1728,
        -80
      ],
      "parameters": {
        "text": "=Subject: {{ $json.subject }}\nRequested Chapters: {{ $json.chapter_count }}\n\nTranscript:\n{{ $json.transcript }}",
        "options": {
          "systemMessage": "You are an expert educational content creator. Read the lecture transcript carefully and produce structured chapter-wise study notes plus MCQ quiz questions.\n\nReturn ONLY a valid JSON object \u2014 no markdown, no backticks, no explanation.\n\nJSON structure:\n{\n  \"lecture_title\": \"inferred title from content\",\n  \"total_chapters\": 3,\n  \"chapters\": [\n    {\n      \"chapter_number\": 1,\n      \"chapter_title\": \"Chapter title here\",\n      \"key_concepts\": [\"concept 1\", \"concept 2\", \"concept 3\"],\n      \"detailed_notes\": \"3-5 sentences summarizing this chapter's main content clearly\",\n      \"important_terms\": [\n        {\"term\": \"term name\", \"definition\": \"clear one-sentence definition\"}\n      ],\n      \"quiz\": [\n        {\n          \"question\": \"Clear MCQ question?\",\n          \"options\": [\"A) option\", \"B) option\", \"C) option\", \"D) option\"],\n          \"correct_answer\": \"A\",\n          \"explanation\": \"One sentence explaining why this is correct\"\n        }\n      ]\n    }\n  ],\n  \"overall_summary\": \"3-4 sentence summary of the entire lecture\",\n  \"key_takeaways\": [\"takeaway 1\", \"takeaway 2\", \"takeaway 3\"]\n}\n\nRules:\n- Create exactly the number of chapters requested\n- Each chapter must have exactly 5 quiz questions\n- Keep notes factual \u2014 only use information from the transcript\n- important_terms should have 2-4 terms per chapter\n- Return ONLY the JSON object \u2014 nothing before or after it"
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "9c13a34b-f95e-4a01-b416-56f14a8487c4",
      "name": "OpenAI \u2014 GPT-4o-mini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1728,
        128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "8020aa85-3c81-4360-aa39-43423359792e",
      "name": "11. Code \u2014 Parse Notes and Quiz",
      "type": "n8n-nodes-base.code",
      "position": [
        2096,
        -80
      ],
      "parameters": {
        "jsCode": "const raw = $input.first().json.output || $input.first().json.text || '';\nconst meta = $('9. Code \u2014 Prepare Transcript').item.json;\n\nlet parsed;\ntry {\n  const cleaned = raw.replace(/```json/gi, '').replace(/```/g, '').trim();\n  parsed = JSON.parse(cleaned);\n} catch (e) {\n  throw new Error('Could not parse AI output as JSON. Raw: ' + raw.slice(0, 300));\n}\n\nconst chapters = parsed.chapters || [];\n\nlet notesText = '';\nlet quizText = '';\n\nfor (const ch of chapters) {\n  notesText += `CHAPTER ${ch.chapter_number}: ${ch.chapter_title}\\n`;\n  notesText += `${ch.detailed_notes}\\n`;\n  notesText += `Key Concepts: ${(ch.key_concepts || []).join(', ')}\\n`;\n  if (ch.important_terms && ch.important_terms.length > 0) {\n    notesText += `Terms: ${ch.important_terms.map(t => t.term + ': ' + t.definition).join(' | ')}\\n`;\n  }\n  notesText += '\\n';\n\n  quizText += `CHAPTER ${ch.chapter_number} QUIZ\\n`;\n  for (const q of (ch.quiz || [])) {\n    quizText += `Q: ${q.question}\\n`;\n    quizText += (q.options || []).join(' | ') + '\\n';\n    quizText += `Answer: ${q.correct_answer} \u2014 ${q.explanation}\\n\\n`;\n  }\n}\n\nconst escHtml = s => String(s || '').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');\n\nlet chaptersHtml = '';\nfor (const ch of chapters) {\n  const termsHtml = (ch.important_terms || []).map(t =>\n    `<li><strong>${escHtml(t.term)}:</strong> ${escHtml(t.definition)}</li>`\n  ).join('');\n\n  const conceptsHtml = (ch.key_concepts || []).map(c =>\n    `<span style=\"display:inline-block;background:#e8f4fd;color:#0066cc;padding:3px 10px;border-radius:12px;font-size:12px;margin:2px;\">${escHtml(c)}</span>`\n  ).join('');\n\n  const quizHtml = (ch.quiz || []).map((q, i) => `\n    <div style=\"margin-bottom:14px;padding:12px;background:#f8f8f8;border-radius:6px;\">\n      <p style=\"margin:0 0 8px;font-weight:600;color:#1a1a1a;\">Q${i+1}. ${escHtml(q.question)}</p>\n      <p style=\"margin:0 0 6px;font-size:13px;color:#444;\">${(q.options||[]).join('<br>')}</p>\n      <p style=\"margin:0;font-size:12px;color:#059669;font-weight:600;\">Answer: ${escHtml(q.correct_answer)} \u2014 ${escHtml(q.explanation)}</p>\n    </div>`).join('');\n\n  chaptersHtml += `\n    <div style=\"margin-bottom:28px;padding:20px;border:1px solid #e5e7eb;border-radius:8px;\">\n      <h2 style=\"color:#1a1a2e;font-size:17px;margin:0 0 8px;\">Chapter ${ch.chapter_number}: ${escHtml(ch.chapter_title)}</h2>\n      <div style=\"margin-bottom:10px;\">${conceptsHtml}</div>\n      <p style=\"font-size:14px;color:#374151;line-height:1.7;margin:0 0 12px;\">${escHtml(ch.detailed_notes)}</p>\n      ${termsHtml ? `<ul style=\"font-size:13px;color:#555;padding-left:18px;margin:0 0 14px;\">${termsHtml}</ul>` : ''}\n      <h3 style=\"color:#1a1a2e;font-size:14px;margin:16px 0 8px;\">Quiz \u2014 Chapter ${ch.chapter_number}</h3>\n      ${quizHtml}\n    </div>`;\n}\n\nconst takeawaysHtml = (parsed.key_takeaways || []).map(t =>\n  `<li style=\"margin-bottom:6px;color:#374151;\">${escHtml(t)}</li>`\n).join('');\n\nconst htmlEmail = `<!DOCTYPE html>\n<html>\n<head><meta charset=\"UTF-8\"></head>\n<body style=\"font-family:Arial,sans-serif;max-width:680px;margin:0 auto;background:#f9fafb;padding:20px;\">\n  <div style=\"background:#1a1a2e;padding:28px;border-radius:10px 10px 0 0;\">\n    <div style=\"font-size:11px;color:#9ca3af;letter-spacing:1.5px;text-transform:uppercase;margin-bottom:8px;\">Study Notes + Quiz</div>\n    <h1 style=\"color:#fff;font-size:22px;margin:0;\">${escHtml(parsed.lecture_title || meta.subject)}</h1>\n    <p style=\"color:#9ca3af;font-size:13px;margin:8px 0 0;\">${chapters.length} chapters &nbsp;\u2022&nbsp; ${chapters.reduce((a,c) => a + (c.quiz||[]).length, 0)} quiz questions</p>\n  </div>\n  <div style=\"background:#fff;padding:24px;\">\n    <div style=\"background:#f0fdf4;border-left:4px solid #059669;padding:14px 16px;border-radius:0 6px 6px 0;margin-bottom:24px;\">\n      <p style=\"font-weight:700;color:#065f46;margin:0 0 6px;\">Lecture Summary</p>\n      <p style=\"font-size:14px;color:#374151;margin:0;line-height:1.7;\">${escHtml(parsed.overall_summary)}</p>\n    </div>\n    <h2 style=\"color:#1a1a2e;font-size:15px;margin:0 0 12px;\">Key Takeaways</h2>\n    <ul style=\"padding-left:18px;margin:0 0 24px;\">${takeawaysHtml}</ul>\n    ${chaptersHtml}\n  </div>\n  <div style=\"background:#1a1a2e;padding:14px 24px;border-radius:0 0 10px 10px;text-align:center;\">\n    <p style=\"color:#6b7280;font-size:11px;margin:0;\">Generated by n8n YouTube Lecture to Study Notes workflow &nbsp;\u2022&nbsp; Powered by WayinVideo + GPT-4o-mini</p>\n  </div>\n</body>\n</html>`;\n\nreturn [{\n  json: {\n    user_email: meta.user_email,\n    subject: meta.subject,\n    youtube_url: meta.youtube_url,\n    submitted_at: meta.submitted_at,\n    lecture_title: parsed.lecture_title || meta.subject,\n    total_chapters: chapters.length,\n    total_quiz_questions: chapters.reduce((a,c) => a + (c.quiz||[]).length, 0),\n    overall_summary: parsed.overall_summary || '',\n    notes_text: notesText,\n    quiz_text: quizText,\n    html_email: htmlEmail\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "e837e027-abea-4db3-8464-b81574bd3e43",
      "name": "12. Google Sheets \u2014 Log Study Session",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2336,
        -80
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.submitted_at }}",
            "Quiz": "={{ $json.quiz_text }}",
            "Notes": "={{ $json.notes_text }}",
            "Status": "Delivered",
            "Subject": "={{ $json.subject }}",
            "Summary": "={{ $json.overall_summary }}",
            "YouTube URL": "={{ $json.youtube_url }}",
            "Lecture Title": "={{ $json.lecture_title }}",
            "Quiz Questions": "={{ $json.total_quiz_questions }}",
            "Chapters Generated": "={{ $json.total_chapters }}"
          },
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": []
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Study Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_GOOGLE_SHEET_ID"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "ffa1278b-3078-4ccb-acf1-fcdbb7ff4ed2",
      "name": "13. Gmail \u2014 Send Notes and Quiz",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2704,
        -80
      ],
      "parameters": {
        "sendTo": "={{ $json.user_email }}",
        "message": "={{ $json.html_email }}",
        "options": {
          "senderName": "Study Notes Bot"
        },
        "subject": "=Study Notes Ready: {{ $json.lecture_title }} \u2014 {{ $json.total_chapters }} chapters + {{ $json.total_quiz_questions }} quiz questions"
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "b6990655-d452-4467-80f4-e2d666587c55",
  "connections": {
    "4. Wait \u2014 30 Seconds": {
      "main": [
        [
          {
            "node": "5. HTTP \u2014 Poll Transcription Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3. Code \u2014 Extract Task ID": {
      "main": [
        [
          {
            "node": "4. Wait \u2014 30 Seconds",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8. Wait \u2014 30 Second Retry": {
      "main": [
        [
          {
            "node": "5. HTTP \u2014 Poll Transcription Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI \u2014 GPT-4o-mini Model": {
      "ai_languageModel": [
        [
          {
            "node": "10. AI Agent \u2014 Generate Notes and Quiz",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "6. Code \u2014 Merge Poll Status": {
      "main": [
        [
          {
            "node": "7. IF \u2014 Transcription Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9. Code \u2014 Prepare Transcript": {
      "main": [
        [
          {
            "node": "10. AI Agent \u2014 Generate Notes and Quiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1. Form \u2014 YouTube Lecture URL": {
      "main": [
        [
          {
            "node": "2. HTTP \u2014 WayinVideo Submit Transcription",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "11. Code \u2014 Parse Notes and Quiz": {
      "main": [
        [
          {
            "node": "12. Google Sheets \u2014 Log Study Session",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7. IF \u2014 Transcription Complete?": {
      "main": [
        [
          {
            "node": "8. Wait \u2014 30 Second Retry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9. Code \u2014 Prepare Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5. HTTP \u2014 Poll Transcription Status": {
      "main": [
        [
          {
            "node": "6. Code \u2014 Merge Poll Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "12. Google Sheets \u2014 Log Study Session": {
      "main": [
        [
          {
            "node": "13. Gmail \u2014 Send Notes and Quiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "10. AI Agent \u2014 Generate Notes and Quiz": {
      "main": [
        [
          {
            "node": "11. Code \u2014 Parse Notes and Quiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2. HTTP \u2014 WayinVideo Submit Transcription": {
      "main": [
        [
          {
            "node": "3. Code \u2014 Extract Task ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}