{ "id": "TApiWf36Digest01", "name": "Weekly Channel Digest → Ghost/Substack Draft (TranscriptAPI)", "nodes": [ { "parameters": { "rule": { "interval": [ { "field": "days", "daysInterval": 7, "triggerAtHour": 8 } ] } }, "id": "36363636-3636-4636-8636-363636363601", "name": "Every Week", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [ -320, 0 ] }, { "parameters": { "assignments": { "assignments": [ { "id": "36363636-3636-4636-8636-3636363636a1", "name": "channel", "value": "REPLACE_WITH_CHANNEL_HANDLE_OR_ID", "type": "string" }, { "id": "36363636-3636-4636-8636-3636363636a2", "name": "draftUrl", "value": "REPLACE_WITH_GHOST_OR_SUBSTACK_DRAFT_URL", "type": "string" } ] }, "options": {} }, "id": "36363636-3636-4636-8636-363636363602", "name": "Set Channel", "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -100, 0 ] }, { "parameters": { "url": "https://transcriptapi.com/api/v2/youtube/channel/latest", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "channel", "value": "={{ $json.channel }}" } ] }, "options": {} }, "id": "36363636-3636-4636-8636-363636363603", "name": "Get Latest Videos (TranscriptAPI)", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 120, 0 ], "credentials": { "httpHeaderAuth": { "id": "REPLACE_TRANSCRIPTAPI_CRED_ID", "name": "TranscriptAPI - Authorization Bearer" } } }, { "parameters": { "jsCode": "const WINDOW_DAYS = 7; const cutoff = Date.now() - WINDOW_DAYS * 864e5;\nconst out = [];\nconst data = $input.first().json; const ch = (data.channel && data.channel.title) || null;\nfor (const v of (data.results || [])) {\n const pub = v.published ? new Date(v.published).getTime() : 0;\n if (pub >= cutoff) out.push({ json: { videoId: v.videoId, title: v.title || null, videoUrl: v.link || ('https://www.youtube.com/watch?v=' + v.videoId), channelTitle: ch } });\n}\nreturn out;" }, "id": "36363636-3636-4636-8636-363636363604", "name": "Collect New Videos", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 340, 0 ] }, { "parameters": { "maxItems": 8 }, "id": "36363636-3636-4636-8636-363636363605", "name": "Keep Top 8", "type": "n8n-nodes-base.limit", "typeVersion": 1, "position": [ 560, 0 ] }, { "parameters": { "url": "https://transcriptapi.com/api/v2/youtube/transcript", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "video_url", "value": "={{ $json.videoUrl }}" }, { "name": "format", "value": "json" }, { "name": "send_metadata", "value": "true" } ] }, "options": {} }, "id": "36363636-3636-4636-8636-363636363606", "name": "Get Transcript (TranscriptAPI)", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 780, 0 ], "credentials": { "httpHeaderAuth": { "id": "REPLACE_TRANSCRIPTAPI_CRED_ID", "name": "TranscriptAPI - Authorization Bearer" } }, "onError": "continueRegularOutput" }, { "parameters": { "jsCode": "const MAX = 5000; const sources = []; const blocks = [];\nfor (const item of $input.all()) {\n const d = item.json; const seg = Array.isArray(d.transcript) ? d.transcript : [];\n if (seg.length === 0) continue;\n const meta = d.metadata || {}; const vid = d.video_id; const title = meta.title || vid;\n const text = seg.map((s) => s.text).join(' ').slice(0, MAX);\n sources.push({ title, videoUrl: 'https://www.youtube.com/watch?v=' + vid });\n blocks.push('### ' + title + '\\n' + text);\n}\nreturn [ { json: { sourceCount: sources.length, sources, combinedText: blocks.join('\\n\\n') } } ];" }, "id": "36363636-3636-4636-8636-363636363607", "name": "Aggregate Digest Input", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ 1000, 0 ] }, { "parameters": { "method": "POST", "url": "https://api.openai.com/v1/chat/completions", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ model: 'gpt-4o-mini', messages: [ { role: 'system', content: 'You are a newsletter editor. From the supplied transcripts of this period\\u2019s videos from one channel, assemble a weekly digest post in Markdown: a short intro, one section per video (title as H2 + 2-3 sentence summary + link), and a closing line. Ready to paste into Ghost or Substack.' }, { role: 'user', content: 'Videos:\\n\\n' + $json.combinedText } ] }) }}", "options": {} }, "id": "36363636-3636-4636-8636-363636363608", "name": "Write Weekly Digest (LLM)", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1220, 0 ], "credentials": { "httpHeaderAuth": { "id": "REPLACE_OPENAI_CRED_ID", "name": "OpenAI - Authorization Bearer" } } }, { "parameters": { "method": "POST", "url": "={{ $('Set Channel').first().json.draftUrl }}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ JSON.stringify({ status: 'draft', title: 'Weekly Channel Digest', markdown: $json.choices[0].message.content }) }}", "options": {} }, "id": "36363636-3636-4636-8636-363636363609", "name": "Create Draft (placeholder)", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ 1440, 0 ] } ], "connections": { "Every Week": { "main": [ [ { "node": "Set Channel", "type": "main", "index": 0 } ] ] }, "Set Channel": { "main": [ [ { "node": "Get Latest Videos (TranscriptAPI)", "type": "main", "index": 0 } ] ] }, "Get Latest Videos (TranscriptAPI)": { "main": [ [ { "node": "Collect New Videos", "type": "main", "index": 0 } ] ] }, "Collect New Videos": { "main": [ [ { "node": "Keep Top 8", "type": "main", "index": 0 } ] ] }, "Keep Top 8": { "main": [ [ { "node": "Get Transcript (TranscriptAPI)", "type": "main", "index": 0 } ] ] }, "Get Transcript (TranscriptAPI)": { "main": [ [ { "node": "Aggregate Digest Input", "type": "main", "index": 0 } ] ] }, "Aggregate Digest Input": { "main": [ [ { "node": "Write Weekly Digest (LLM)", "type": "main", "index": 0 } ] ] }, "Write Weekly Digest (LLM)": { "main": [ [ { "node": "Create Draft (placeholder)", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1" }, "pinData": {} }