New openshorts-content-machine.json: daily channel-RSS watcher (one video per day, new upload first then back catalog), clips delivered to Telegram with approve/skip buttons, approved clips drip-scheduled via /api/social/post, weekly analytics digest from the new endpoints. A 402 pauses the machine with a Telegram notice and leaves the video unmarked so the next day retries it. Both templates now carry webhookId on webhook-based trigger nodes: without it n8n imports the node but never registers the webhook, so every incoming call 404s. Found by importing and executing the workflow against a live n8n.
885 lines
No EOL
26 KiB
JSON
885 lines
No EOL
26 KiB
JSON
{
|
|
"name": "OpenShorts Content Machine: your channel clips itself, you approve from your phone",
|
|
"nodes": [
|
|
{
|
|
"parameters": {
|
|
"content": "## ACT 1 \u2014 Watch the channel (daily)\n\nOnce a day this branch reads your channel's RSS feed and picks **one** video to clip: a new upload if there is one, otherwise the next unprocessed video from your back catalog (newest first). One video per day keeps your quota burn predictable.\n\n**Setup**: put your channel id in the *Channel RSS feed* node (`https://www.youtube.com/feeds/videos.xml?channel_id=UC...`). Find it at youtube.com \u2192 your channel \u2192 About \u2192 Share \u2192 Copy channel ID.\n\nIf OpenShorts answers 402 (out of minutes) the machine pauses and tells you on Telegram instead of failing silently.",
|
|
"height": 420,
|
|
"width": 400,
|
|
"color": 4
|
|
},
|
|
"id": "note-act1",
|
|
"name": "Act 1 note",
|
|
"type": "n8n-nodes-base.stickyNote",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
-560,
|
|
-120
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"rule": {
|
|
"interval": [
|
|
{
|
|
"field": "days",
|
|
"triggerAtHour": 9
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"id": "daily-schedule",
|
|
"name": "Every day 09:00",
|
|
"type": "n8n-nodes-base.scheduleTrigger",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
-80,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://www.youtube.com/feeds/videos.xml?channel_id=YOUR_CHANNEL_ID",
|
|
"options": {}
|
|
},
|
|
"id": "channel-rss",
|
|
"name": "Channel RSS feed",
|
|
"type": "n8n-nodes-base.rssFeedRead",
|
|
"typeVersion": 1.1,
|
|
"position": [
|
|
140,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// One video per run: the newest video we have not processed yet.\n// A fresh upload is by definition the newest unprocessed one, so new\n// uploads win automatically; with nothing new, the back catalog drains\n// newest-first. Processed links persist in workflow static data\n// (production executions only \u2014 manual test runs do not save it).\nconst staticData = $getWorkflowStaticData('global');\nconst done = staticData.processedVideos || [];\nconst videos = $input.all().map((i) => i.json);\nconst fresh = videos.filter((v) => v.link && !done.includes(v.link));\nif (fresh.length === 0) {\n return [];\n}\nconst pick = fresh[0];\nreturn [{ json: { url: pick.link, title: pick.title, published: pick.isoDate } }];"
|
|
},
|
|
"id": "pick-video",
|
|
"name": "Pick next video",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
360,
|
|
0
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "https://api.openshorts.app/api/process",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpHeaderAuth",
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={\n \"url\": \"{{ $json.url }}\",\n \"acknowledged\": true,\n \"webhook_url\": \"PASTE_THE_PRODUCTION_URL_OF_THE_CLIPS-READY_WEBHOOK_NODE_HERE\",\n \"webhook_secret\": \"change-me\"\n}",
|
|
"options": {}
|
|
},
|
|
"id": "start-job",
|
|
"name": "Start OpenShorts job",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
580,
|
|
0
|
|
],
|
|
"onError": "continueErrorOutput",
|
|
"credentials": {
|
|
"httpHeaderAuth": {
|
|
"name": "OpenShorts API key"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Only mark the video done once OpenShorts accepted the job \u2014 a failed\n// submit (quota, downtime) leaves it unmarked so tomorrow retries it.\nconst staticData = $getWorkflowStaticData('global');\nconst done = staticData.processedVideos || [];\nconst url = $('Pick next video').first().json.url;\nif (!done.includes(url)) {\n done.push(url);\n}\nstaticData.processedVideos = done;\nreturn $input.all();"
|
|
},
|
|
"id": "mark-processed",
|
|
"name": "Mark video as processed",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
800,
|
|
-60
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"text": "=\ud83c\udfac Clipping started: {{ $('Pick next video').first().json.title }}\n\nI'll send the clips here for approval when they're ready.",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-clipping",
|
|
"name": "Notify: clipping started",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
1020,
|
|
-60
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"text": "\u26a0\ufe0f Autopilot paused: OpenShorts rejected the job (most likely you're out of minutes this month). The video was NOT marked as processed, so it will be retried tomorrow. Top up or upgrade at https://www.openshorts.app/",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-quota",
|
|
"name": "Notify: out of minutes",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
800,
|
|
120
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"content": "## ACT 2 \u2014 Clips arrive on your phone\n\n**No polling, no Wait-node loop.** OpenShorts calls this webhook once per job (success **and** failure, so nothing ever hangs). Each finished 9:16 clip lands in your Telegram with two buttons: \u2705 publish or \u274c skip \u2014 a human approves every post, which is also what keeps you on the right side of YouTube's inauthentic-content policy.\n\n**Setup**: copy the **production** URL of the *Clips ready* webhook node and paste it as `webhook_url` inside *Start OpenShorts job*. Telegram fetches videos by URL up to ~20 MB; bigger clips fall back to a message with the download link and the same buttons.",
|
|
"height": 380,
|
|
"width": 400,
|
|
"color": 5
|
|
},
|
|
"id": "note-act2",
|
|
"name": "Act 2 note",
|
|
"type": "n8n-nodes-base.stickyNote",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
-560,
|
|
340
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"httpMethod": "POST",
|
|
"path": "openshorts-machine-clips",
|
|
"options": {}
|
|
},
|
|
"id": "clips-webhook",
|
|
"name": "Clips ready (webhook)",
|
|
"type": "n8n-nodes-base.webhook",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
-80,
|
|
440
|
|
],
|
|
"webhookId": "30f3bc66-1f03-4d2f-94b8-aed49571238d"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"typeValidation": "strict",
|
|
"version": 2
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "c1",
|
|
"leftValue": "={{ $json.body.event }}",
|
|
"rightValue": "job.completed",
|
|
"operator": {
|
|
"type": "string",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "if-completed",
|
|
"name": "Job completed?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2.2,
|
|
"position": [
|
|
140,
|
|
440
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// One Telegram message per clip, carrying everything the approval\n// buttons need inside callback_data (Telegram caps it at 64 bytes:\n// action|job_id|clip_index fits).\nconst body = $json.body;\nreturn (body.clips || []).map((clip, i) => ({\n json: {\n job_id: body.job_id,\n clip_index: i,\n title: clip.title || `Clip ${i + 1}`,\n download_url: clip.download_url || clip.video_url,\n },\n}));"
|
|
},
|
|
"id": "split-clips",
|
|
"name": "One item per clip",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
360,
|
|
380
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"operation": "sendVideo",
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"file": "={{ $json.download_url }}",
|
|
"replyMarkup": "inlineKeyboard",
|
|
"inlineKeyboard": {
|
|
"rows": [
|
|
{
|
|
"row": {
|
|
"buttons": [
|
|
{
|
|
"text": "\u2705 Publish",
|
|
"additionalFields": {
|
|
"callback_data": "=pub|{{ $json.job_id }}|{{ $json.clip_index }}"
|
|
}
|
|
},
|
|
{
|
|
"text": "\u274c Skip",
|
|
"additionalFields": {
|
|
"callback_data": "skip"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"additionalFields": {
|
|
"caption": "={{ $json.title }}"
|
|
}
|
|
},
|
|
"id": "tg-clip-video",
|
|
"name": "Send clip for approval",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
580,
|
|
380
|
|
],
|
|
"onError": "continueErrorOutput",
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"text": "=\ud83c\udfac {{ $json.title }}\n\nToo big for Telegram preview \u2014 watch it here:\n{{ $json.download_url }}",
|
|
"replyMarkup": "inlineKeyboard",
|
|
"inlineKeyboard": {
|
|
"rows": [
|
|
{
|
|
"row": {
|
|
"buttons": [
|
|
{
|
|
"text": "\u2705 Publish",
|
|
"additionalFields": {
|
|
"callback_data": "=pub|{{ $json.job_id }}|{{ $json.clip_index }}"
|
|
}
|
|
},
|
|
{
|
|
"text": "\u274c Skip",
|
|
"additionalFields": {
|
|
"callback_data": "skip"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-clip-link",
|
|
"name": "Send clip link instead",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
800,
|
|
480
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"text": "=\u274c OpenShorts job failed: {{ $json.body.error || 'unknown error' }}\n\nNothing was published. The machine keeps running tomorrow.",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-job-failed",
|
|
"name": "Notify: job failed",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
360,
|
|
560
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"content": "## ACT 3 \u2014 Tap \u2705, it gets scheduled\n\nThe Telegram trigger listens for the approval buttons. Every approved clip is scheduled through OpenShorts (which posts to every social account you connected there \u2014 TikTok, Instagram, YouTube) at a rate of **one post per day**: approve five clips today and you just filled five days of content.\n\n**Setup**: none beyond the Telegram credential \u2014 the chat id comes from the button tap itself. Change the platforms list in *Schedule social post* if you want fewer networks.",
|
|
"height": 380,
|
|
"width": 400,
|
|
"color": 6
|
|
},
|
|
"id": "note-act3",
|
|
"name": "Act 3 note",
|
|
"type": "n8n-nodes-base.stickyNote",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
-560,
|
|
800
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"updates": [
|
|
"callback_query"
|
|
],
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-trigger",
|
|
"name": "Approval buttons",
|
|
"type": "n8n-nodes-base.telegramTrigger",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
-80,
|
|
900
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
},
|
|
"webhookId": "906a710d-3e76-4911-b7e6-f336e6da5d66"
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "const cb = $json.callback_query || {};\nconst [action, jobId, clipIndex] = String(cb.data || '').split('|');\nreturn [{\n json: {\n action: action || 'skip',\n job_id: jobId || '',\n clip_index: parseInt(clipIndex || '0', 10),\n chat_id: cb.message && cb.message.chat ? cb.message.chat.id : null,\n clip_title: cb.message ? (cb.message.caption || '') : '',\n },\n}];"
|
|
},
|
|
"id": "parse-button",
|
|
"name": "Parse button",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
140,
|
|
900
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"conditions": {
|
|
"options": {
|
|
"caseSensitive": true,
|
|
"typeValidation": "strict",
|
|
"version": 2
|
|
},
|
|
"conditions": [
|
|
{
|
|
"id": "c2",
|
|
"leftValue": "={{ $json.action }}",
|
|
"rightValue": "pub",
|
|
"operator": {
|
|
"type": "string",
|
|
"operation": "equals"
|
|
}
|
|
}
|
|
],
|
|
"combinator": "and"
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "if-approved",
|
|
"name": "Approved?",
|
|
"type": "n8n-nodes-base.if",
|
|
"typeVersion": 2.2,
|
|
"position": [
|
|
360,
|
|
900
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// One post per day: each approval takes the next free daily slot, so a\n// batch of approvals turns into a steady drip instead of a burst.\nconst staticData = $getWorkflowStaticData('global');\nconst now = Date.now();\nconst last = staticData.lastScheduledAt || 0;\nconst slot = Math.max(now + 10 * 60 * 1000, last + 24 * 60 * 60 * 1000);\nstaticData.lastScheduledAt = slot;\nconst item = $input.first().json;\nreturn [{ json: { ...item, scheduled_date: new Date(slot).toISOString() } }];"
|
|
},
|
|
"id": "reserve-slot",
|
|
"name": "Reserve daily slot",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
580,
|
|
840
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"method": "POST",
|
|
"url": "https://api.openshorts.app/api/social/post",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpHeaderAuth",
|
|
"sendBody": true,
|
|
"specifyBody": "json",
|
|
"jsonBody": "={\n \"job_id\": \"{{ $json.job_id }}\",\n \"clip_index\": {{ $json.clip_index }},\n \"platforms\": [\"tiktok\", \"instagram\", \"youtube\"],\n \"scheduled_date\": \"{{ $json.scheduled_date }}\",\n \"timezone\": \"UTC\"\n}",
|
|
"options": {}
|
|
},
|
|
"id": "social-post",
|
|
"name": "Schedule social post",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
800,
|
|
840
|
|
],
|
|
"onError": "continueErrorOutput",
|
|
"credentials": {
|
|
"httpHeaderAuth": {
|
|
"name": "OpenShorts API key"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "={{ $('Parse button').first().json.chat_id }}",
|
|
"text": "=\ud83d\udcc5 Scheduled! Going out to your connected accounts on {{ $('Reserve daily slot').first().json.scheduled_date.slice(0, 10) }}.",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-scheduled",
|
|
"name": "Confirm: scheduled",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
1020,
|
|
780
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "={{ $('Parse button').first().json.chat_id }}",
|
|
"text": "=\u26a0\ufe0f Could not schedule that clip: {{ $json.error && $json.error.message ? $json.error.message : 'posting failed' }}. Make sure your social accounts are connected in your OpenShorts account page.",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-post-failed",
|
|
"name": "Confirm: posting failed",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
1020,
|
|
900
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "={{ $('Parse button').first().json.chat_id }}",
|
|
"text": "\ud83d\uddd1 Skipped. It stays in your OpenShorts dashboard if you change your mind.",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-skipped",
|
|
"name": "Confirm: skipped",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
580,
|
|
980
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"content": "## ACT 4 \u2014 The feedback loop: learn what worked\n\nOnce a week the machine reads the analytics of everything it published (via the OpenShorts analytics API, which aggregates TikTok/Instagram/YouTube numbers) and sends you the verdict: total impressions, per-platform split, and your best post.\n\nThe machine that posts is the machine that measures \u2014 so every approval you make next week is informed by what actually landed. Close the loop further by feeding your winners back as examples in your clip prompts.",
|
|
"height": 340,
|
|
"width": 400,
|
|
"color": 3
|
|
},
|
|
"id": "note-act4",
|
|
"name": "Act 4 note",
|
|
"type": "n8n-nodes-base.stickyNote",
|
|
"typeVersion": 1,
|
|
"position": [
|
|
-560,
|
|
1260
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"rule": {
|
|
"interval": [
|
|
{
|
|
"field": "weeks",
|
|
"triggerAtDay": [
|
|
0
|
|
],
|
|
"triggerAtHour": 18
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"id": "weekly-schedule",
|
|
"name": "Every Sunday 18:00",
|
|
"type": "n8n-nodes-base.scheduleTrigger",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
-80,
|
|
1360
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://api.openshorts.app/api/social/analytics/impressions",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpHeaderAuth",
|
|
"sendQuery": true,
|
|
"queryParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "period",
|
|
"value": "last_week"
|
|
},
|
|
{
|
|
"name": "breakdown",
|
|
"value": "true"
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "weekly-impressions",
|
|
"name": "Weekly impressions",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
140,
|
|
1360
|
|
],
|
|
"credentials": {
|
|
"httpHeaderAuth": {
|
|
"name": "OpenShorts API key"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"url": "https://api.openshorts.app/api/social/analytics/posts",
|
|
"authentication": "genericCredentialType",
|
|
"genericAuthType": "httpHeaderAuth",
|
|
"sendQuery": true,
|
|
"queryParameters": {
|
|
"parameters": [
|
|
{
|
|
"name": "since",
|
|
"value": "={{ $now.minus({ days: 7 }).toFormat('yyyy-MM-dd') }}"
|
|
}
|
|
]
|
|
},
|
|
"options": {}
|
|
},
|
|
"id": "weekly-posts",
|
|
"name": "Per-post metrics",
|
|
"type": "n8n-nodes-base.httpRequest",
|
|
"typeVersion": 4.2,
|
|
"position": [
|
|
360,
|
|
1360
|
|
],
|
|
"credentials": {
|
|
"httpHeaderAuth": {
|
|
"name": "OpenShorts API key"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"parameters": {
|
|
"jsCode": "// Turn the two analytics responses into one human digest message.\nconst impressions = $('Weekly impressions').first().json || {};\nconst postsResp = $input.first().json || {};\nconst posts = postsResp.posts || postsResp.data || postsResp.items || [];\n\nconst views = (post) => {\n const m = post.post_metrics || post.metrics || post;\n return Number(m.views || m.impressions || m.plays || 0);\n};\n\nconst total = impressions.total_impressions || posts.reduce((s, p) => s + views(p), 0);\nconst sorted = [...posts].sort((a, b) => views(b) - views(a));\nconst best = sorted[0];\n\nconst perPlatform = impressions.per_platform\n ? Object.entries(impressions.per_platform)\n .map(([p, v]) => ` \u2022 ${p}: ${Number(v).toLocaleString('en-US')}`)\n .join('\\n')\n : '';\n\nlet text = `\ud83d\udcca Your week on autopilot\\n\\n`;\ntext += `Posts published: ${posts.length}\\n`;\ntext += `Total impressions: ${Number(total).toLocaleString('en-US')}\\n`;\nif (perPlatform) {\n text += `${perPlatform}\\n`;\n}\nif (best && views(best) > 0) {\n const title = best.title || best.caption || best.platform_post_id || 'your top post';\n text += `\\n\ud83c\udfc6 Best post: \"${title}\" \u2014 ${views(best).toLocaleString('en-US')} views`;\n}\nif (posts.length === 0) {\n text += `\\nNothing published this week. Approve some clips and the machine does the rest.`;\n}\nreturn [{ json: { digest: text } }];"
|
|
},
|
|
"id": "write-digest",
|
|
"name": "Write the digest",
|
|
"type": "n8n-nodes-base.code",
|
|
"typeVersion": 2,
|
|
"position": [
|
|
580,
|
|
1360
|
|
]
|
|
},
|
|
{
|
|
"parameters": {
|
|
"chatId": "YOUR_TELEGRAM_CHAT_ID",
|
|
"text": "={{ $json.digest }}",
|
|
"additionalFields": {}
|
|
},
|
|
"id": "tg-digest",
|
|
"name": "Send weekly digest",
|
|
"type": "n8n-nodes-base.telegram",
|
|
"typeVersion": 1.2,
|
|
"position": [
|
|
800,
|
|
1360
|
|
],
|
|
"credentials": {
|
|
"telegramApi": {
|
|
"name": "Telegram bot"
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"connections": {
|
|
"Every day 09:00": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Channel RSS feed",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Channel RSS feed": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Pick next video",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Pick next video": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Start OpenShorts job",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Start OpenShorts job": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Mark video as processed",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"node": "Notify: out of minutes",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Mark video as processed": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Notify: clipping started",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Clips ready (webhook)": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Job completed?",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Job completed?": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "One item per clip",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"node": "Notify: job failed",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"One item per clip": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Send clip for approval",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Send clip for approval": {
|
|
"main": [
|
|
[],
|
|
[
|
|
{
|
|
"node": "Send clip link instead",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Approval buttons": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Parse button",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Parse button": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Approved?",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Approved?": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Reserve daily slot",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"node": "Confirm: skipped",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Reserve daily slot": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Schedule social post",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Schedule social post": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Confirm: scheduled",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
],
|
|
[
|
|
{
|
|
"node": "Confirm: posting failed",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Every Sunday 18:00": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Weekly impressions",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Weekly impressions": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Per-post metrics",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Per-post metrics": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Write the digest",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
},
|
|
"Write the digest": {
|
|
"main": [
|
|
[
|
|
{
|
|
"node": "Send weekly digest",
|
|
"type": "main",
|
|
"index": 0
|
|
}
|
|
]
|
|
]
|
|
}
|
|
},
|
|
"settings": {
|
|
"executionOrder": "v1"
|
|
},
|
|
"pinData": {}
|
|
} |