{
  "name": "Daily digest of new YouTube uploads",
  "nodes": [
    {
      "parameters": {
        "content": "## Daily digest\nEvery morning: checks your channels, summarizes each new video in two sentences, and emails one digest. No new videos, no email.\n\n**YouTubeTranscriptAPI key (once):** Credentials → New → Header Auth. Name: `Authorization`. Value: `Bearer tk_live_…` (your key from youtubetranscriptapi.com/dashboard/keys). Call it *YouTubeTranscriptAPI key* and pick it in every YouTube node.\n\n**Edit:** the channel list in *Channels to watch*, and your address in *Email the digest*. Add your OpenAI key and connect Gmail.\n\n**Cost:** checking channels is free; 1 credit per new video.",
        "width": 460,
        "height": 420,
        "color": 5
      },
      "id": "6e9721b6-95f1-4d33-8b79-2a66c11ef403",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -80
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "9d8831e3-9cab-459e-8d95-d3b74e22cd9e",
      "name": "Every morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Edit this list: @handles, channel links or UC… channel IDs.\nconst channels = [\"@freecodecamp\", \"@TED\"];\n\nreturn channels.map((channel) => ({ json: { channel } }));"
      },
      "id": "38170ea3-1dbf-41b9-8a99-8555bce4a48c",
      "name": "Channels to watch",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://youtubetranscriptapi.com/api/v2/youtube/channel/latest",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "channel",
              "value": "={{ $json.channel }}"
            }
          ]
        },
        "options": {}
      },
      "id": "0a7d3146-4a57-4cb7-85eb-f328b94cb31e",
      "name": "Latest videos",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "const since = Date.now() - 24 * 60 * 60 * 1000;\nconst out = [];\nfor (const item of $input.all()) {\n  const channel = item.json.channel_title ?? item.json.channel_id;\n  for (const v of item.json.results ?? []) {\n    if (v.publishedAt && Date.parse(v.publishedAt) >= since) {\n      out.push({ json: { channel, title: v.title, url: v.url } });\n    }\n  }\n}\nreturn out;"
      },
      "id": "cd643689-a7d1-49a6-8644-c789c19c333f",
      "name": "New in the last 24 hours",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://youtubetranscriptapi.com/api/v2/youtube/transcript",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "video_url",
              "value": "={{ $json.url }}"
            },
            {
              "name": "format",
              "value": "text"
            },
            {
              "name": "include_timestamp",
              "value": "false"
            }
          ]
        },
        "options": {}
      },
      "id": "9cec4514-d29c-4f5a-840f-1c50bd3cda23",
      "name": "Get transcript",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ],
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Video: {{ $('New in the last 24 hours').item.json.title }}\nChannel: {{ $('New in the last 24 hours').item.json.channel }}\n\nTranscript:\n{{ $json.transcript ?? 'No transcript: the video has no captions.' }}",
        "messages": {
          "messageValues": [
            {
              "message": "Summarize this new YouTube video in two sentences: what it is about, and the single most useful point. If there is no transcript, say the video has no captions."
            }
          ]
        },
        "hasOutputParser": false
      },
      "id": "b1e4724f-8dd9-47e3-8ae6-40a0e26b313e",
      "name": "Summarize each",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.6,
      "position": [
        1100,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {}
      },
      "id": "ec9c1bc9-879e-4d6d-8721-2e36b45f0cd8",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        1100,
        220
      ]
    },
    {
      "parameters": {
        "jsCode": "const videos = $('New in the last 24 hours').all();\nconst lines = $input.all().map((s, i) => {\n  const v = videos[i].json;\n  return `${v.channel}: ${v.title}\\n${v.url}\\n${s.json.text}`;\n});\nconst n = lines.length;\nreturn [{ json: { subject: `YouTube digest: ${n} new video${n === 1 ? '' : 's'}`, body: lines.join('\\n\\n') } }];"
      },
      "id": "57f4ef32-c4d6-45cc-8a2a-92c860599f91",
      "name": "Build the digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1340,
        0
      ]
    },
    {
      "parameters": {
        "sendTo": "you@example.com",
        "subject": "={{ $json.subject }}",
        "emailType": "text",
        "message": "={{ $json.body }}",
        "options": {
          "appendAttribution": false
        }
      },
      "id": "04f5489c-094a-46a6-8508-2fd8bbca6e33",
      "name": "Email the digest",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1560,
        0
      ],
      "webhookId": "0099bbfe-b769-4446-8784-f2e9b287d857"
    }
  ],
  "connections": {
    "Every morning": {
      "main": [
        [
          {
            "node": "Channels to watch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Channels to watch": {
      "main": [
        [
          {
            "node": "Latest videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Latest videos": {
      "main": [
        [
          {
            "node": "New in the last 24 hours",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New in the last 24 hours": {
      "main": [
        [
          {
            "node": "Get transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get transcript": {
      "main": [
        [
          {
            "node": "Summarize each",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize each": {
      "main": [
        [
          {
            "node": "Build the digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build the digest": {
      "main": [
        [
          {
            "node": "Email the digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarize each",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  }
}