{ "name": "Promote New YouTube Videos on X", "tags": [], "nodes": [ { "id": "promote-new-youtube-videos-on-x-0", "name": "Post to X", "type": "n8n-nodes-base.twitter", "position": [ 1280, 380 ], "parameters": { "text": "={{ $json.text }}", "additionalFields": {} }, "typeVersion": 2 }, { "id": "promote-new-youtube-videos-on-x-1", "name": "Generate Post for X with ChatGPT", "type": "@n8n/n8n-nodes-langchain.openAi", "position": [ 900, 380 ], "parameters": { "modelId": { "__rl": true, "mode": "list", "value": "gpt-3.5-turbo", "cachedResultName": "GPT-3.5-TURBO" }, "options": {}, "messages": { "values": [ { "content": "=Write an engaging post about my latest YouTube video for X (Twitter) of no more than 140 characters in length. Link to the video at https://youtu.be/{{ $json.id.videoId }} use this title and description: {{ $json.snippet.title }} {{ $json.snippet.description }}" } ] } }, "typeVersion": 1.3 }, { "id": "promote-new-youtube-videos-on-x-2", "name": "Fetch Latest Videos", "type": "n8n-nodes-base.youTube", "position": [ 680, 380 ], "parameters": { "limit": 1, "filters": { "channelId": "YOUR_YOUTUBE_CHANNEL_ID", "publishedAfter": "={{ new Date(new Date().getTime() - 30 * 60000).toISOString() }}" }, "options": { "order": "date" }, "resource": "video" }, "typeVersion": 1 }, { "id": "promote-new-youtube-videos-on-x-3", "name": "Check Every 30 Min", "type": "n8n-nodes-base.scheduleTrigger", "position": [ 460, 380 ], "parameters": { "rule": { "interval": [ { "field": "minutes", "minutesInterval": 30 } ] } }, "typeVersion": 1.2 }, { "id": "promote-new-youtube-videos-on-x-4", "name": "Validate the post", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "function validate({result,url}){const text=typeof result==='string'?result.trim():'';if(!text||Array.from(text).length>140||!text.includes(url))throw Error('Post must include the video link and fit 140 characters');return {text}}\n\nreturn $input.all().map((x,i)=>({json:validate({result:x.json.message.content,url:\"https://youtu.be/\"+$(\"Fetch Latest Videos\").item.json.id.videoId}),pairedItem:{item:i}}));" } } ], "active": false, "pinData": {}, "settings": { "executionOrder": "v1" }, "connections": { "Check Every 30 Min": { "main": [ [ { "node": "Fetch Latest Videos", "type": "main", "index": 0 } ] ] }, "Fetch Latest Videos": { "main": [ [ { "node": "Generate Post for X with ChatGPT", "type": "main", "index": 0 } ] ] }, "Generate Post for X with ChatGPT": { "main": [ [ { "node": "Validate the post", "type": "main", "index": 0 } ] ] }, "Validate the post": { "main": [ [ { "node": "Post to X", "type": "main", "index": 0 } ] ] } } }