{ "nodes": [ { "name": "Set", "type": "n8n-nodes-base.set", "position": [ 500, 510 ], "parameters": { "values": { "string": [ { "name": "id", "value": "={{$node[\"GetVideosYT\"].json[\"id\"][\"videoId\"]}}" }, { "name": "url", "value": "=https://youtu.be/{{$node[\"GetVideosYT\"].json[\"id\"][\"videoId\"]}}" }, { "name": "title", "value": "={{$node[\"GetVideosYT\"].json[\"snippet\"][\"title\"]}}" } ], "boolean": [] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1, "id": "new-youtube-channel-videos-to-telegram-0" }, { "name": "Function", "type": "n8n-nodes-base.code", "position": [ 640, 510 ], "parameters": { "mode": "runOnceForAllItems", "jsCode": "const rows=$input.all().map(({json:x})=>{if(typeof x.id!=='string'||!/^[A-Za-z0-9_-]{1,128}$/.test(x.id)||typeof x.title!=='string')throw new Error('Invalid video');const t=x.title.replace(/&/g,'&').replace(//g,'>');const text='New video on YouTube!\\n'+t+'\\n\\nhttps://youtu.be/'+x.id;if(text.length>4096)throw new Error('Telegram message exceeds limit');return {id:x.id,text}});const data=$getWorkflowStaticData('node');data.ids=data.ids||[];const result=[];for(const row of rows){if(data.ids.includes(row.id))break;result.push({json:row})}data.ids=rows.map(x=>x.id);return result;" }, "typeVersion": 2, "id": "new-youtube-channel-videos-to-telegram-1" }, { "name": "CheckTime", "type": "n8n-nodes-base.interval", "position": [ 210, 510 ], "parameters": { "unit": "minutes", "interval": 30 }, "typeVersion": 1, "id": "new-youtube-channel-videos-to-telegram-2" }, { "name": "GetVideosYT", "type": "n8n-nodes-base.youTube", "position": [ 370, 510 ], "parameters": { "limit": 4, "filters": { "channelId": "YOUR_YOUTUBE_CHANNEL_ID" }, "options": { "order": "date" }, "resource": "video" }, "typeVersion": 1, "id": "new-youtube-channel-videos-to-telegram-3" }, { "name": "SendVideo", "type": "n8n-nodes-base.telegram", "position": [ 790, 510 ], "parameters": { "text": "={{ $json.text }}", "chatId": "YOUR_TELEGRAM_CHAT_ID", "additionalFields": { "parse_mode": "HTML" } }, "typeVersion": 1, "id": "new-youtube-channel-videos-to-telegram-4" } ], "connections": { "Set": { "main": [ [ { "node": "Function", "type": "main", "index": 0 } ] ] }, "Function": { "main": [ [ { "node": "SendVideo", "type": "main", "index": 0 } ] ] }, "CheckTime": { "main": [ [ { "node": "GetVideosYT", "type": "main", "index": 0 } ] ] }, "GetVideosYT": { "main": [ [ { "node": "Set", "type": "main", "index": 0 } ] ] } }, "name": "New YouTube Channel Videos to Telegram", "active": false, "pinData": {} }