{
  "name": "Template - Content Summarizer (Free Version) - fabimarkl.com",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Summarize YouTube Videos",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Enter Link to YouTube Videos ",
              "fieldType": "textarea",
              "requiredField": true
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.3,
      "position": [
        144,
        80
      ],
      "id": "49c3ae23-1592-4adb-9a3b-ad5bf3a83ced",
      "name": "On form submission",
      "webhookId": "d4a0b2c6-673a-476f-9f06-d9e2ce549b1c"
    },
    {
      "parameters": {
        "url": "=https://youtube-video-summarizer-gpt-ai.p.rapidapi.com/api/v1/get-transcript-v2",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "video_id",
              "value": "={{ $json.videoId }}"
            },
            {
              "name": "platform",
              "value": "youtube"
            }
          ]
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Rapidapi-Key",
              "value": "Insert your API key"
            },
            {
              "name": "X-Rapidapi-Host",
              "value": "youtube-video-summarizer-gpt-ai.p.rapidapi.com"
            },
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        816,
        80
      ],
      "id": "20b4e27f-2fc8-4364-a1c9-3b1b6f99216a",
      "name": "Get Video Data",
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "jsCode": "const items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n  const transcripts = item.json?.data?.transcripts;\n  if (!transcripts) continue;\n\n  // Find the first transcript key that has a 'custom' array\n  const langKey = Object.keys(transcripts).find(\n    key => Array.isArray(transcripts[key]?.custom)\n  );\n\n  if (!langKey) continue;\n\n  const fullText = transcripts[langKey].custom\n    .map(seg => seg.text || \"\")\n    .join(\" \")\n    .replace(/&#39;/g, \"'\")\n    .replace(/&amp;/g, \"&\");\n\n  results.push({\n    json: {\n      videoTitle: item.json?.data?.videoInfo?.name || \"\",\n      fullText\n    }\n  });\n}\n\nreturn results.length > 0 ? results : [{ json: { fullText: \"\" } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1040,
        80
      ],
      "id": "2ffaea01-1cd4-4318-a54c-8858a06c79df",
      "name": "Clean Text"
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const url = item.json.url;\n\nlet videoId = null;\n\nconst m1 = url.match(/[?&]v=([^&]+)/);\nif (m1) videoId = m1[1];\n\nif (!videoId) {\n  const m2 = url.match(/youtu\\.be\\/([^?]+)/);\n  if (m2) videoId = m2[1];\n}\n\nreturn {\n  json: {\n    videoId\n  }\n};\n"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        592,
        80
      ],
      "id": "dcec322c-32f9-49a7-842b-78518353e3ad",
      "name": "Get Video ID"
    },
    {
      "parameters": {
        "jsCode": "const input = $input.first().json['Enter Link to YouTube Videos '];\nconst urlList = input.split('\\n').filter(url => url.trim() !== '');\n\n// Return array of URLs\nreturn urlList.map(url => ({\n  json: { url: url.trim() }\n}));"
      },
      "id": "a4cf845f-456b-4b3e-9a17-d40ffa5cc269",
      "name": "Split",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        368,
        80
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-5.2",
          "mode": "list",
          "cachedResultName": "GPT-5.2"
        },
        "messages": {
          "values": [
            {
              "content": "=You are a YouTube summary expert. Create a concise but detailed summary of this video transcript in 200–300 words.\n\nFollow this structure EXACTLY and do NOT alter or remove any Markdown formatting characters:\n\n**Type**: YouTube\n\n**Title**: {{ $('Get Video Data').item.json.data.videoInfo.name }}\n\n**URL**: [{{ $('Split').item.json.url }}]({{ $('Split').item.json.url }})\n\n**Main Topic:** [1 sentence summarizing the core theme of the video]\n\n**Key Points:**\n- [3–5 bullet points of the most important insights or takeaways]\n- [each bullet MUST start with \"- \"]\n- [no blank lines between bullets]\n- [keep bullets short and concrete]\n\n**Why Watch:** [2–3 sentences explaining who should watch this, what value they’ll get, and why it matters]\n\n**Bottom Line:** [1 sentence verdict that states whether it's worth the viewer’s time]\n\n# Formatting Rules (critical):\n- Keep every pair of ** exactly as shown.\n- Do NOT change the headings, labels, or section order.\n- Do NOT remove or change any Markdown characters.\n- Do NOT add new sections.\n- Do NOT reformat the URL. It MUST remain: [URL](URL)\n- Output must be clean and valid Markdown.\n- No emojis, no fluff, no additional commentary.\n\nTranscript:\n{{ $json.fullText }}\n"
            }
          ]
        },
        "simplify": false,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        1264,
        80
      ],
      "id": "8252b9d1-aa7e-481d-a40d-02e9db2fac93",
      "name": "Summarize YT Video",
      "credentials": {
        "openAiApi": {
          "id": "80b8DOj8REc2MMqi",
          "name": "OpenAi account 9"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Extract all summaries from the messy GPT response format\nconst items = $input.all();\n\nlet markdown = '# Content Summaries\\n\\n';\nmarkdown += `Generated: ${new Date().toLocaleDateString()}\\n\\n`;\nmarkdown += `Total Items: ${items.length}\\n\\n`;\nmarkdown += '---\\n\\n';\n\nfor (let i = 0; i < items.length; i++) {\n  const item = items[i].json;\n  let summary = '';\n  \n  // Handle different response formats\n  if (item.message && item.message.content) {\n    // Format 1: Direct message object\n    summary = item.message.content;\n  } else if (item.choices && item.choices[0] && item.choices[0].message) {\n    // Format 2: Full GPT response with choices array\n    summary = item.choices[0].message.content;\n  } else if (item.content) {\n    // Format 3: Direct content field\n    summary = item.content;\n  } else {\n    summary = 'Error: Could not extract summary';\n  }\n  \n  markdown += `${summary}\\n\\n`;\n  markdown += '---\\n\\n';\n}\n\nreturn { json: { markdown: markdown } };"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1616,
        80
      ],
      "id": "3370f0dd-fede-40be-9f73-7cd97f502f6b",
      "name": "Combine"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://md-to-pdf.fly.dev",
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "markdown",
              "value": "={{ $json.markdown }}"
            }
          ]
        },
        "options": {
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "md-to-pdf.pdf"
            }
          }
        }
      },
      "id": "7782b268-37a8-49c8-93ed-4cc4f2e5d940",
      "name": "Convert HTML to PDF",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1840,
        80
      ]
    },
    {
      "parameters": {
        "sendTo": "insert your email address",
        "subject": "Your content was summarized (PDF)",
        "message": "Here your PDF",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "md-to-pdf.pdf"
              }
            ]
          }
        }
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        2064,
        80
      ],
      "id": "43c8b299-1b79-47c3-8737-9a2db9e117d7",
      "name": "Send a message",
      "webhookId": "328b7fad-9faa-4285-97f2-b6ab0e178081",
      "executeOnce": false,
      "credentials": {
        "gmailOAuth2": {
          "id": "6FbWEcqJuVdvNQWb",
          "name": "receipts"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Split",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Data": {
      "main": [
        [
          {
            "node": "Clean Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video ID": {
      "main": [
        [
          {
            "node": "Get Video Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Text": {
      "main": [
        [
          {
            "node": "Summarize YT Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split": {
      "main": [
        [
          {
            "node": "Get Video ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize YT Video": {
      "main": [
        [
          {
            "node": "Combine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine": {
      "main": [
        [
          {
            "node": "Convert HTML to PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert HTML to PDF": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1f20bca0-f0ab-4b4c-949c-d3235142ba71",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "7ff6625f0127f3e9a7865e3493009de1c48f57dc5ed87def3ae3316be7f6b238"
  },
  "id": "EYzwNN1P6qldip2z",
  "tags": []
}