{
  "name": "YouTube video to a repurpose brief",
  "nodes": [
    {
      "id": "9233a6d3-b33f-4a2e-8a29-71a771b55003",
      "name": "Read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -688,
        -120
      ],
      "parameters": {
        "content": "## YouTube video to a repurpose brief\nEach new video on your channel gets a brief row: the clips and posts to cut from it, with due dates. Every Monday you get the list of what is still open.\n\n### You need\n- Your YouTube channel ID. No YouTube login is needed: the feed is public.\n- A Google Sheets login and a Repurpose Briefs tab with: Video ID, Title, Link, Thumbnail, Kind, Published, Deliverables, Due, Status\n- A Telegram bot and your chat ID\n\n### Set it up\n1. In **New video on your channel**, swap YOUR_CHANNEL_ID for your channel ID. It starts with UC.\n2. Pick your sheet in **Read the briefs**, **Add the brief** and **Read open briefs**.\n3. In **Settings**, add your chat ID. Change the list of deliverables and the days to finish them if you like.\n4. Failure alert: put your chat ID in **Write the failure alert** and your bot in **Send the failure alert**. Then in Workflow settings, set Error workflow to this workflow.\n\n### Test it\n- Click Test workflow with **Every Monday** picked. You get the list of open briefs (empty at first).\n- Turn the workflow on. Your next video adds one brief row and sends you a message. Set a row to Done when the clips are out.",
        "height": 858,
        "width": 560,
        "color": 4
      }
    },
    {
      "id": "29d00cf9-0bec-47a4-9f86-312146c72a6d",
      "name": "Note: brief",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -48,
        -120
      ],
      "parameters": {
        "content": "## Make the brief\nOne row per video, never two: the Video ID is checked first. Shorts get a shorter list. You write the clips and posts yourself.",
        "height": 480,
        "width": 1460,
        "color": 7
      }
    },
    {
      "id": "a6051b34-ffb6-40c2-b1cd-2d9149abed90",
      "name": "Note: weekly",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        672,
        380
      ],
      "parameters": {
        "content": "## Monday list\nEvery Monday you get the briefs that are not Done, oldest first.",
        "height": 420,
        "width": 960,
        "color": 7
      }
    },
    {
      "id": "91910742-716a-420b-9951-1000a7c84c54",
      "name": "New video on your channel",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 15,
              "unit": "minutes"
            }
          ]
        },
        "feedUrl": "https://www.youtube.com/feeds/videos.xml?channel_id=YOUR_CHANNEL_ID"
      }
    },
    {
      "id": "c2d02dc9-e2b6-462f-bc77-1727e48427a4",
      "name": "Every Monday",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        460
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 9
            }
          ]
        }
      }
    },
    {
      "id": "fe77fc06-ca00-456a-ac2d-10a2c814edad",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        200
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "deliverables",
              "type": "string",
              "value": "Short clip 1, Short clip 2, Short clip 3, Carousel, Text post, Newsletter blurb"
            },
            {
              "id": "f2",
              "name": "shortsDeliverables",
              "type": "string",
              "value": "Repost to other apps, Text post"
            },
            {
              "id": "f3",
              "name": "daysToFinish",
              "type": "number",
              "value": 7
            },
            {
              "id": "f4",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_CHAT_ID"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "ce55a880-8aab-4fdc-8635-cb56e7832d5a",
      "name": "Monday run?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        480,
        200
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Every Monday').isExecuted }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "08ce16b7-aa38-4580-9d2c-f3ce42057157",
      "name": "Read the briefs",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        720,
        0
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Repurpose Briefs",
          "mode": "name"
        },
        "options": {}
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "id": "864c95d0-d4b9-4c17-a1ab-9b5ad116632f",
      "name": "Build the brief",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const s = $('Settings').first().json;\nconst known = new Set($('Read the briefs').all().map(r => String(r.json['Video ID'] || '').trim()).filter(Boolean));\nconst out = [];\nfor (const { json: v } of $('New video on your channel').all()) {\n  const id = String(v.id || v.guid || '').replace('yt:video:', '').trim() || String(v.link || '').split(/[=/]/).pop();\n  if (!id || known.has(id)) continue;\n  known.add(id);\n  const isShort = /\\/shorts\\//.test(String(v.link || ''));\n  const list = String(isShort ? s.shortsDeliverables : s.deliverables).split(',').map(x => x.trim()).filter(Boolean);\n  const published = v.isoDate || v.pubDate || '';\n  out.push({ json: {\n    videoId: id, title: String(v.title || '').trim(), link: v.link, thumbnail: 'https://i.ytimg.com/vi/' + id + '/hqdefault.jpg',\n    kind: isShort ? 'Short' : 'Video', published, deliverables: list.join(', '),\n    due: $now.plus({ days: Number(s.daysToFinish) || 7 }).toISODate(),\n  } });\n}\nreturn out;"
      }
    },
    {
      "id": "108f8908-86f7-4c2e-974f-2ffcc0505117",
      "name": "Add the brief",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1200,
        0
      ],
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Repurpose Briefs",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Video ID": "={{ $json.videoId }}",
            "Title": "={{ $json.title }}",
            "Link": "={{ $json.link }}",
            "Thumbnail": "={{ $json.thumbnail }}",
            "Kind": "={{ $json.kind }}",
            "Published": "={{ $json.published }}",
            "Deliverables": "={{ $json.deliverables }}",
            "Due": "={{ $json.due }}",
            "Status": "To do"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Video ID",
              "displayName": "Video ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Thumbnail",
              "displayName": "Thumbnail",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Kind",
              "displayName": "Kind",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Published",
              "displayName": "Published",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Deliverables",
              "displayName": "Deliverables",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Due",
              "displayName": "Due",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "8f4456d1-62a7-443b-802e-a4d82b159d61",
      "name": "Tell you about the brief",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1440,
        0
      ],
      "parameters": {
        "chatId": "={{ $('Settings').first().json.telegramChatId }}",
        "text": "={{ 'New brief: ' + $('Build the brief').item.json.title + '\\nMake: ' + $('Build the brief').item.json.deliverables + '\\nDue: ' + $('Build the brief').item.json.due + '\\n' + $('Build the brief').item.json.link }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "b407307e-5d8a-423d-bada-be41a6d0dd74",
      "name": "Read open briefs",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        720,
        460
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "Repurpose Briefs",
          "mode": "name"
        },
        "options": {}
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "id": "331274bc-4f9a-4b53-ad51-63dfdbe1acca",
      "name": "Write the Monday list",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        960,
        460
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const open = $input.all().map(i => i.json).filter(r => r['Video ID'] && String(r.Status || '').trim().toLowerCase() !== 'done')\n  .sort((a, b) => String(a.Due).localeCompare(String(b.Due)));\nconst today = $now.toISODate();\nconst lines = open.slice(0, 20).map(r => '- ' + r.Title + ' (due ' + r.Due + (String(r.Due) < today ? ', late' : '') + ')');\nconst message = open.length === 0 ? 'No open briefs. Every video has its clips and posts.' : 'Open briefs: ' + open.length + '\\n\\n' + lines.join('\\n') + (open.length > 20 ? '\\n...and ' + (open.length - 20) + ' more' : '');\nreturn [{ json: { message } }];"
      }
    },
    {
      "id": "eb733369-c2c5-4e1e-924e-2240076ac8d0",
      "name": "Send the Monday list",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1200,
        460
      ],
      "parameters": {
        "chatId": "={{ $('Settings').first().json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "4515e02a-9c7b-4b43-b4f8-50987b418974",
      "name": "When this workflow fails",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        -648,
        818
      ],
      "parameters": {}
    },
    {
      "id": "449a3cdb-24ca-4784-b947-bfddcc65f10a",
      "name": "Write the failure alert",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -428,
        818
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_TELEGRAM_CHAT_ID"
            },
            {
              "id": "f2",
              "name": "message",
              "type": "string",
              "value": "={{ 'A workflow stopped.\\n\\nWorkflow: ' + (($json.workflow || {}).name || 'unknown') + '\\nFailed step: ' + (($json.execution || {}).lastNodeExecuted || 'unknown') + '\\nWhy: ' + String((($json.execution || {}).error || {}).message || 'n8n did not give a reason.').slice(0, 300) + (($json.execution || {}).url ? '\\nOpen the run: ' + $json.execution.url : '') }}"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "9246f926-f562-4b91-a7f3-1e0989c03518",
      "name": "Send the failure alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -208,
        818
      ],
      "parameters": {
        "chatId": "={{ $json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    }
  ],
  "connections": {
    "New video on your channel": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Monday": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Monday run?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Monday run?": {
      "main": [
        [
          {
            "node": "Read open briefs",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Read the briefs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read open briefs": {
      "main": [
        [
          {
            "node": "Write the Monday list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the Monday list": {
      "main": [
        [
          {
            "node": "Send the Monday list",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the briefs": {
      "main": [
        [
          {
            "node": "Build the brief",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build the brief": {
      "main": [
        [
          {
            "node": "Add the brief",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add the brief": {
      "main": [
        [
          {
            "node": "Tell you about the brief",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When this workflow fails": {
      "main": [
        [
          {
            "node": "Write the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the failure alert": {
      "main": [
        [
          {
            "node": "Send the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}
