{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "02c8e1dc-ac9a-4090-9fef-e07ec92b87f3",
      "name": "New Video URL (Notion Trigger)",
      "type": "n8n-nodes-base.notionTrigger",
      "position": [
        -1472,
        80
      ],
      "parameters": {
        "simple": false,
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "value": "2a71d9a7-7486-807a-9006-d048aa512d16",
          "cachedResultUrl": "https://www.notion.so/2a71d9a77486807a9006d048aa512d16",
          "cachedResultName": "High Performing YouTube Videos"
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6945d42d-45b9-46a5-8bef-13e68b84e0f9",
      "name": "Extract YouTube Video ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -1200,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0ccd35d8-a431-4cb7-8328-5c74c1a8b858",
              "name": "video_id",
              "type": "string",
              "value": "={{ $json.properties['Video ID'].formula.string }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1c3af437-6151-403b-bf96-98f9ac36d987",
      "name": "Fetch Video Data (YouTube API)",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -976,
        80
      ],
      "parameters": {
        "options": {},
        "videoId": "={{ $json.video_id }}",
        "resource": "video",
        "operation": "get"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2017b4ae-428c-483c-8d76-8e061239e93a",
      "name": "Fetch Channel Info (YouTube API)",
      "type": "n8n-nodes-base.youTube",
      "position": [
        -832,
        400
      ],
      "parameters": {
        "channelId": "={{ $json.snippet.channelId }}",
        "operation": "get"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0b3df2d9-b6f5-4112-9723-e3c6c3e9ac94",
      "name": "Format Video Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -480,
        80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "75120858-82a6-49ac-b4d3-9f3d31dff2bb",
              "name": "title",
              "type": "string",
              "value": "={{ $json.snippet.title }}"
            },
            {
              "id": "51ed4555-79ee-4915-a2c7-c4ed1f6c9ebb",
              "name": "thumbnails",
              "type": "string",
              "value": "={{ $json.snippet.thumbnails.standard.url }}"
            },
            {
              "id": "4766a1e1-e624-4299-95c3-01a628bc4afd",
              "name": "channel_name",
              "type": "string",
              "value": "={{ $json.snippet.channelTitle }}"
            },
            {
              "id": "5043540a-f5a9-42f2-abe4-dcde272199f8",
              "name": "viewCount",
              "type": "string",
              "value": "={{ $json.statistics.viewCount }}"
            },
            {
              "id": "d9a4c209-d0f4-4c14-92ff-7d47086b562f",
              "name": "likeCount",
              "type": "string",
              "value": "={{ $json.statistics.likeCount }}"
            },
            {
              "id": "1ff94c47-56e0-4776-962b-31c83701256c",
              "name": "commentCount",
              "type": "string",
              "value": "={{ $json.statistics.commentCount }}"
            },
            {
              "id": "8d03d8ea-0f3c-41c6-94af-da128bb122f8",
              "name": "channelId",
              "type": "string",
              "value": "={{ $json.snippet.channelId }}"
            },
            {
              "id": "048310eb-dc55-4b1f-98ed-1dcd494cf86c",
              "name": "video_id",
              "type": "string",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7f986f0d-dc08-4ce2-b8af-15f3f564348b",
      "name": "Format Channel Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -480,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b0766c19-9e9a-45ae-8787-474377f63034",
              "name": "subscriberCount",
              "type": "string",
              "value": "={{ $json.statistics.subscriberCount }}"
            },
            {
              "id": "2970a916-9ccd-4dc7-a07a-ad7dae500bcc",
              "name": "channel_name",
              "type": "string",
              "value": "={{ $json.snippet.title }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8872828f-e24f-4a5f-8778-8dbecec88c51",
      "name": "Merge Video + Channel Info",
      "type": "n8n-nodes-base.merge",
      "position": [
        -256,
        96
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "fieldsToMatchString": "channel_name"
      },
      "typeVersion": 3.2
    },
    {
      "id": "dc3937c8-99e6-4147-861c-6616bcc731ed",
      "name": "Update Notion Page",
      "type": "n8n-nodes-base.notion",
      "position": [
        -16,
        96
      ],
      "parameters": {
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('New Video URL (Notion Trigger)').item.json.id }}"
        },
        "simple": false,
        "options": {},
        "resource": "databasePage",
        "operation": "update",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Channel Name|rich_text",
              "textContent": "={{ $json.channel_name }}"
            },
            {
              "key": "Comments|number",
              "numberValue": "={{ parseInt($json.commentCount) }}"
            },
            {
              "key": "Likes|number",
              "numberValue": "={{ parseInt($json.likeCount) }}"
            },
            {
              "key": "Subscribers|number",
              "numberValue": "={{ parseInt($json.subscriberCount) }}"
            },
            {
              "key": "Thumbnail|files",
              "fileUrls": {
                "fileUrl": [
                  {
                    "url": "={{ $json.thumbnails }}",
                    "name": "={{ $json.thumbnails.split(\"/\")[5]}}"
                  }
                ]
              }
            },
            {
              "key": "Video Title|rich_text",
              "textContent": "={{ $json.title }}"
            },
            {
              "key": "Views|number",
              "numberValue": "={{ parseInt($json.viewCount) }}"
            },
            {
              "key": "Status|status",
              "statusValue": "Done"
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "28f40051-1ce3-48fe-b8e2-a459f37b43be",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -1104
      ],
      "parameters": {
        "width": 848,
        "height": 848,
        "content": "# **Information**\n\n## **Who it's for**\nYouTube creators, content marketers, and anyone who wants to automatically enrich YouTube links added to a Notion database.\n\n## **What it does**\nAutomatically extracts important video and channel data \u2014 including title, views, likes, comments, thumbnail, channel name, subscribers, and a custom viral score \u2014 whenever a new YouTube URL is added to Notion.\n\n## **How it works**\n1. A Notion Trigger fires when a new page is added to your database.  \n2. The workflow extracts the YouTube video ID from the provided URL.  \n3. A YouTube API request retrieves video details (title, views, likes, comments, thumbnail).  \n4. A second YouTube API request retrieves channel information (name and subscriber count).  \n5. Both sets of data are cleaned and formatted.  \n6. The enriched data is written back to the same Notion page.\n\n## **Requirements**\n- YouTube Data API (OAuth2 recommended)  \n- Notion integration connected to your workspace  \n- This Notion template (includes all required fields):  \n  https://lunar-curler-d17.notion.site/2a71d9a77486807a9006d048aa512d16?v=2a71d9a7748680eda620000ca9c112a4\n\n## **Setup steps**\n1. Duplicate the Notion template linked above.  \n2. Connect your Notion credentials in n8n.  \n3. Create and connect a YouTube OAuth2 credential.  \n4. Assign your credential to the YouTube API nodes.  \n5. Test once with a manual execution."
      },
      "typeVersion": 1
    },
    {
      "id": "a79cb90d-055a-4fc9-bfcc-eb2522332b13",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 576,
        "content": "Triggers the workflow when a new page is added to the Notion database.\nReads the YT Link field so the workflow knows which video to process."
      },
      "typeVersion": 1
    },
    {
      "id": "76ca3d9a-bef1-4a7b-ab21-770ca28c3423",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -752
      ],
      "parameters": {
        "color": 3,
        "width": 768,
        "height": 496,
        "content": "# Watch the walkthrough on YouTube\n[![](https://img.youtube.com/vi/pAuKTI-n8G4/hqdefault.jpg)](https://www.youtube.com/watch?v=pAuKTI-n8G4)"
      },
      "typeVersion": 1
    },
    {
      "id": "5eac24b0-c2df-4e51-9c99-6e5c174af39f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 208,
        "height": 576,
        "content": "Extracts the video ID from the YouTube URL so the YouTube API can get stats."
      },
      "typeVersion": 1
    },
    {
      "id": "47b1d9ba-2430-438b-9222-f2df979200a1",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 256,
        "content": "Gets channel-level data including channel name and subscriber count."
      },
      "typeVersion": 1
    },
    {
      "id": "12513564-bb10-455c-b67c-e0daf2884e44",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 256,
        "content": "Cleans and structures video fields (views, likes, comments, thumbnail) into a consistent format for updating Notion."
      },
      "typeVersion": 1
    },
    {
      "id": "02abd7f1-14bc-499c-a3cc-9840911eea98",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -528,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 256,
        "content": "Prepares channel-related fields (channel name, subscribers) for merging with video data."
      },
      "typeVersion": 1
    },
    {
      "id": "b1af7244-2c8d-4ed0-90c7-15776bb49015",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 576,
        "content": "Combines the formatted video and channel data into a single payload used to update Notion.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0131fe0c-235b-46a1-a98e-f7f0eb5e7045",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 576,
        "content": "Updates the same Notion page with all enriched fields: title, views, likes, comments, thumbnail, subscribers, channel name, and viral score.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "710d1d45-14c5-4d4b-a629-f6b04b9064a9",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 464,
        "content": "Starts the workflow when a new Notion page is added and extracts the YouTube video ID from the provided URL."
      },
      "typeVersion": 1
    },
    {
      "id": "61c6ebca-f35c-4825-82bb-075e3b6532b6",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "content": "Calls the YouTube API twice to retrieve video statistics and channel-level information needed for enrichment."
      },
      "typeVersion": 1
    },
    {
      "id": "8b44ce20-01e3-4b90-b272-df94ad929827",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "content": "Cleans and structures both video and channel fields so they can be merged into a single, consistent payload."
      },
      "typeVersion": 1
    },
    {
      "id": "bef3938a-afd3-439c-ba40-a8dcf91ba304",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -240
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "content": "Combines all formatted fields and updates the same Notion row with enriched video and channel data."
      },
      "typeVersion": 1
    },
    {
      "id": "1491d1b4-3ead-44a8-9bbf-c0ea6384b2ac",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1024,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 192,
        "height": 256,
        "content": "Uses the YouTube API to fetch video details including title, views, likes, comments, and thumbnail."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Format Video Data": {
      "main": [
        [
          {
            "node": "Merge Video + Channel Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Channel Data": {
      "main": [
        [
          {
            "node": "Merge Video + Channel Info",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Extract YouTube Video ID": {
      "main": [
        [
          {
            "node": "Fetch Video Data (YouTube API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Video + Channel Info": {
      "main": [
        [
          {
            "node": "Update Notion Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Video Data (YouTube API)": {
      "main": [
        [
          {
            "node": "Format Video Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Channel Info (YouTube API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Video URL (Notion Trigger)": {
      "main": [
        [
          {
            "node": "Extract YouTube Video ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Channel Info (YouTube API)": {
      "main": [
        [
          {
            "node": "Format Channel Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}