Skip to content

Instantly share code, notes, and snippets.

@saadnvd1
Last active July 27, 2025 01:15
Show Gist options
  • Select an option

  • Save saadnvd1/495a57fdcf38bddc1057f0ac74f462d3 to your computer and use it in GitHub Desktop.

Select an option

Save saadnvd1/495a57fdcf38bddc1057f0ac74f462d3 to your computer and use it in GitHub Desktop.
Create a Custom YouTube Channel Newsletter to Grow Your Audience with n8n
const videos = $input.first().json.output;
let html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Your YouTube Channel Newsletter</title>
</head>
<body style="background-color: #f5f7fa; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; color: #333333; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; margin: 0; padding: 0;">
<div role="main" aria-label="Latest videos newsletter" style="background-color: #ffffff; max-width: 600px; margin: 24px auto; padding: 24px 32px; border-radius: 12px; box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1); text-align: left;">
<h1 style="color: #ff6d5a; font-size: 30px; font-weight: 700; margin-bottom: 28px; text-align: center; letter-spacing: 1px;">Latest Videos from Saad Naveed</h1>
`;
for (const video of videos) {
const thumbnail = video.thumbnail_url || '';
html += `
<div style="border-bottom: 1px solid #e0e0e0; padding-bottom: 20px; margin-bottom: 20px; display: flex; align-items: flex-start; gap: 32px;">
<div aria-label="Video thumbnail" style="flex-shrink: 0; width: 120px; height: 67px; border-radius: 8px; overflow: hidden; box-shadow: 0 3px 8px rgba(0,0,0,0.15); margin-right: 16px;">
<a href="${video.link}" target="_blank" rel="noopener noreferrer">
<img src="${thumbnail}" alt="Thumbnail for ${video.title}" style="width: 100%; height: 100%; object-fit: cover; display: block;" />
</a>
</div>
<div style="flex-grow: 1;">
<p style="font-size: 18px; font-weight: 600; margin: 0 0 8px 0; color: #222222;">
<a href="${video.link}" target="_blank" rel="noopener noreferrer" style="color: #ff6d5a; text-decoration: none;" tabindex="0">${video.title}</a>
</p>
<p style="font-size: 14px; color: #555555; margin: 0; line-height: 1.5;">${video.description}</p>
</div>
</div>
`;
}
html += `
</div>
</body>
</html>
`;
// Return the full HTML for use in the next node
return [{ json: { newsletterHtml: html } }];
https://www.youtube.com/feeds/videos.xml?channel_id=<YOUR_CHANNEL_ID>
Newsletter ID:
{{ new Date().toISOString().slice(0,10).replace(/-/g,'') }}
Subject:
Saad's YouTube Channel's Newsletter ({{ new Date().toLocaleDateString('en-US', { year: '2-digit', month: '2-digit', day: '2-digit' }) }})
HTML:
{{ $json.html }}
[
{
"title": "Video Title",
"description": "Video Description",
"link": "https://www.youtube.com/shorts/5Pwe3TYnUrw",
"thumbnail_url": "https://i1.ytimg.com/vi/ToW_AezocP0/hqdefault.jpg"
},
{
"title": "Video Title",
"description": "Video Description",
"link": "https://www.youtube.com/shorts/5Pwe3TYnUrw",
"thumbnail_url": "https://i1.ytimg.com/vi/ToW_AezocP0/hqdefault.jpg"
}
]
Your job is to take this data {{ $json.feed.entry.toJsonString() }} and format it in the required output format. Also, summarize the video description at the same time as it'll be used in a newsletter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment