Nuevos videos de YouTube → Publicación automática de enlaces en Slack
Este es unSocial Media, Multimodal AIflujo de automatización del dominio deautomatización que contiene 6 nodos.Utiliza principalmente nodos como Code, Cron, Slack, HttpRequest. Automatización de las notificaciones de videos de YouTube a Slack
- •Bot Token de Slack o URL de Webhook
- •Pueden requerirse credenciales de autenticación para la API de destino
Nodos utilizados (6)
Categoría
{
"name": "YouTube New Video → Auto-Post Link to Slack",
"nodes": [
{
"id": "setup-instructions",
"name": "Instrucciones de configuración",
"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": "Verificar cada 30 minutos",
"type": "n8n-nodes-base.cron",
"position": [
200,
300
],
"parameters": {
"rule": {
"interval": [
{
"field": "cronExpression",
"expression": "*/30 * * * *"
}
]
}
},
"typeVersion": 1
},
{
"id": "fetch-youtube-rss",
"name": "Obtener RSS de YouTube",
"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": "Analizar RSS y buscar videos nuevos",
"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": "Formatear mensaje de Slack",
"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": "Publicar en Slack",
"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
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Intermedio - Redes sociales, IA Multimodal
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
David Olusola
@dae221I 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
Compartir este flujo de trabajo