YouTube-Neuvideos→Automatisches Veröffentlichen von Links in Slack

Fortgeschritten

Dies ist ein Social Media, Multimodal AI-Bereich Automatisierungsworkflow mit 6 Nodes. Hauptsächlich werden Code, Cron, Slack, HttpRequest und andere Nodes verwendet. Automatisierte Benachrichtigung über neue YouTube-Videos an Slack

Voraussetzungen
  • Slack Bot Token oder Webhook URL
  • Möglicherweise sind Ziel-API-Anmeldedaten erforderlich
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "name": "YouTube New Video → Auto-Post Link to Slack",
  "nodes": [
    {
      "id": "setup-instructions",
      "name": "Setup-Anleitung",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        80
      ],
      "parameters": {
        "width": 280,
        "height": 220,
        "content": "🎬 **SETUP REQUIRED:**\n\n1. **Get YouTube Channel RSS:**\n   - Go to channel → View Page Source\n   - Find: channel/UC[CHANNEL_ID]\n   - RSS URL: youtube.com/feeds/videos.xml?channel_id=[ID]\n   - Replace in HTTP Request node\n\n2. **Slack Connection:**\n   - Connect Slack OAuth\n   - Update channel in final node\n\n3. **Timing:**\n   - Runs every 30 minutes\n   - Adjust cron if needed\n\n✨ Tracks last video to avoid duplicates!"
      },
      "typeVersion": 1
    },
    {
      "id": "youtube-check-trigger",
      "name": "Alle 30 Minuten prüfen",
      "type": "n8n-nodes-base.cron",
      "position": [
        200,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "*/30 * * * *"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fetch-youtube-rss",
      "name": "RSS von YouTube abrufen",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        300
      ],
      "parameters": {
        "url": "https://www.youtube.com/feeds/videos.xml?channel_id=YOUR_CHANNEL_ID_HERE",
        "options": {}
      },
      "typeVersion": 4.1
    },
    {
      "id": "parse-rss-data",
      "name": "RSS parsen & auf neues Video prüfen",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        300
      ],
      "parameters": {
        "jsCode": "// Parse YouTube RSS feed and extract video data\nconst rssData = $input.first().json;\nconst xmlContent = rssData;\n\n// Simple XML parsing for YouTube RSS\nconst entries = [];\nconst entryMatches = xmlContent.matchAll(/<entry[\\s\\S]*?<\\/entry>/g);\n\nfor (const match of entryMatches) {\n  const entry = match[0];\n  \n  // Extract video data using regex\n  const titleMatch = entry.match(/<title><!\\[CDATA\\[([^\\]]+)\\]\\]><\\/title>/);\n  const linkMatch = entry.match(/<link rel=\"alternate\" href=\"([^\"]+)\"\\/?>/);\n  const publishedMatch = entry.match(/<published>([^<]+)<\\/published>/);\n  const descriptionMatch = entry.match(/<media:description><!\\[CDATA\\[([^\\]]+)\\]\\]><\\/media:description>/);\n  const videoIdMatch = entry.match(/watch\\?v=([^&]+)/);\n  \n  if (titleMatch && linkMatch && publishedMatch) {\n    entries.push({\n      title: titleMatch[1],\n      link: linkMatch[1],\n      published: publishedMatch[1],\n      description: descriptionMatch ? descriptionMatch[1].substring(0, 200) + '...' : '',\n      video_id: videoIdMatch ? videoIdMatch[1] : '',\n      published_timestamp: new Date(publishedMatch[1]).getTime()\n    });\n  }\n}\n\n// Sort by publication date (newest first)\nentries.sort((a, b) => b.published_timestamp - a.published_timestamp);\n\n// Get the most recent video\nconst latestVideo = entries[0];\n\nif (!latestVideo) {\n  console.log('No videos found in RSS feed');\n  return null;\n}\n\n// Check if this video is new (published within last 2 hours)\nconst twoHoursAgo = Date.now() - (2 * 60 * 60 * 1000);\nconst isNewVideo = latestVideo.published_timestamp > twoHoursAgo;\n\nconst normalizedData = {\n  ...latestVideo,\n  is_new_video: isNewVideo,\n  channel_name: 'Your Channel', // Will be extracted from RSS in real implementation\n  formatted_date: new Date(latestVideo.published).toLocaleDateString()\n};\n\nconsole.log('Latest video data:', {\n  title: normalizedData.title,\n  published: normalizedData.formatted_date,\n  is_new: normalizedData.is_new_video\n});\n\n// Only proceed if it's a new video\nif (!isNewVideo) {\n  console.log('No new videos to announce');\n  return null;\n}\n\nreturn {\n  json: normalizedData\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "format-slack-message",
      "name": "Slack-Nachricht formatieren",
      "type": "n8n-nodes-base.code",
      "position": [
        800,
        300
      ],
      "parameters": {
        "jsCode": "// Format video announcement for Slack\nconst video = $input.first().json;\n\n// Create rich Slack message\nconst slackMessage = {\n  text: `🎬 New Video Alert!`,\n  channel: '#general', // Change to your preferred channel\n  username: 'YouTube Bot',\n  icon_emoji: ':tv:',\n  blocks: [\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": `🎬 *New Video Published!*\\n\\n*${video.title}*\\n\\n📅 Published: ${video.formatted_date}\\n\\n${video.description}`\n      }\n    },\n    {\n      \"type\": \"actions\",\n      \"elements\": [\n        {\n          \"type\": \"button\",\n          \"text\": {\n            \"type\": \"plain_text\",\n            \"text\": \"🎥 Watch Now\",\n            \"emoji\": true\n          },\n          \"url\": video.link,\n          \"style\": \"primary\"\n        }\n      ]\n    },\n    {\n      \"type\": \"context\",\n      \"elements\": [\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": `📺 ${video.channel_name} | 🔗 <${video.link}|${video.video_id}>`\n        }\n      ]\n    }\n  ]\n};\n\nconsole.log('Formatted Slack message for video:', video.title);\n\nreturn {\n  json: slackMessage\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "post-to-slack",
      "name": "An Slack senden",
      "type": "n8n-nodes-base.slack",
      "position": [
        1000,
        300
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "channel": "={{ $json.channel }}",
        "resource": "message",
        "operation": "post",
        "otherOptions": {
          "blocks": "={{ JSON.stringify($json.blocks) }}",
          "username": "={{ $json.username }}",
          "icon_emoji": "={{ $json.icon_emoji }}"
        },
        "authentication": "oAuth2"
      },
      "typeVersion": 2.1
    }
  ],
  "active": true,
  "settings": {
    "timezone": "UTC"
  },
  "versionId": "1",
  "connections": {
    "fetch-youtube-rss": {
      "main": [
        [
          {
            "node": "parse-rss-data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "format-slack-message": {
      "main": [
        [
          {
            "node": "post-to-slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "youtube-check-trigger": {
      "main": [
        [
          {
            "node": "fetch-youtube-rss",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "parse-rss-data": {
      "main": [
        [
          {
            "node": "format-slack-message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Soziale Medien, Multimodales KI

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes6
Kategorie2
Node-Typen5
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
David Olusola

David Olusola

@dae221

I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34