Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Last active June 1, 2025 06:45
Show Gist options
  • Save owainlewis/12b4d099d0a5ceeae84b3f0044008504 to your computer and use it in GitHub Desktop.
Save owainlewis/12b4d099d0a5ceeae84b3f0044008504 to your computer and use it in GitHub Desktop.
{
"name": "YouTube Research Agent",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-40,
-320
],
"id": "41601c71-b527-4934-9e36-47aa1cf60015",
"name": "When clicking 'Test workflow'"
},
{
"parameters": {
"operation": "get",
"channelId": "={{ $json['Channel ID'] }}"
},
"type": "n8n-nodes-base.youTube",
"typeVersion": 1,
"position": [
620,
-320
],
"id": "5509655b-c624-43b8-8e72-6436861a52c1",
"name": "Get Channel",
"credentials": {
"youTubeOAuth2Api": {
"id": "[YOUTUBE_CREDENTIAL_ID]",
"name": "YouTube OAuth2 Credential"
}
}
},
{
"parameters": {
"resource": "video",
"limit": "={{ $('Configuration').item.json.VIDEO_COUNT }}",
"filters": {
"channelId": "={{ $json.id }}"
},
"options": {
"order": "date"
}
},
"type": "n8n-nodes-base.youTube",
"typeVersion": 1,
"position": [
840,
-320
],
"id": "44d7c62e-c4ff-4cc1-997b-417b07be879a",
"name": "Get Videos",
"credentials": {
"youTubeOAuth2Api": {
"id": "[YOUTUBE_CREDENTIAL_ID]",
"name": "YouTube OAuth2 Credential"
}
}
},
{
"parameters": {
"resource": "video",
"operation": "get",
"videoId": "={{ $json.id.videoId }}",
"part": [
"statistics"
],
"options": {}
},
"type": "n8n-nodes-base.youTube",
"typeVersion": 1,
"position": [
1060,
-320
],
"id": "76a1780a-243f-418b-a586-717bff04879c",
"name": "Get Video Statistics",
"credentials": {
"youTubeOAuth2Api": {
"id": "[YOUTUBE_CREDENTIAL_ID]",
"name": "YouTube OAuth2 Credential"
}
}
},
{
"parameters": {
"authentication": "airtableOAuth2Api",
"operation": "search",
"base": {
"__rl": true,
"value": "[AIRTABLE_BASE_ID]",
"mode": "list",
"cachedResultName": "Youtube Research Agent",
"cachedResultUrl": "https://airtable.com/[AIRTABLE_BASE_ID]"
},
"table": {
"__rl": true,
"value": "[AIRTABLE_CHANNELS_TABLE_ID]",
"mode": "list",
"cachedResultName": "Channels",
"cachedResultUrl": "https://airtable.com/[AIRTABLE_BASE_ID]/[AIRTABLE_CHANNELS_TABLE_ID]"
},
"filterByFormula": "{Selected} = 1",
"options": {}
},
"type": "n8n-nodes-base.airtable",
"typeVersion": 2.1,
"position": [
400,
-320
],
"id": "59f62bec-c9e5-404e-9fc2-38e7318277cd",
"name": "Get Channels",
"credentials": {
"airtableOAuth2Api": {
"id": "[AIRTABLE_CREDENTIAL_ID]",
"name": "Airtable OAuth2 Credential"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "fe5c335a-e461-4566-ba8c-2a97c50dd303",
"name": "VIDEO_COUNT",
"value": 50,
"type": "number"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
180,
-320
],
"id": "eacc0917-82b2-4daf-af89-7dffc3df6698",
"name": "Configuration"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "8cf9133b-18bf-4b34-8a3c-864cc73f3d36",
"leftValue": "={{ $('Get Videos').item.json.snippet.publishedAt }}",
"rightValue": "={{ $now.minus(3, 'months') }}",
"operator": {
"type": "dateTime",
"operation": "after"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.filter",
"typeVersion": 2.2,
"position": [
1280,
-320
],
"id": "217a509f-34f1-4b91-b83e-e9d67d923ab9",
"name": "Last 3 Months"
},
{
"parameters": {
"authentication": "airtableOAuth2Api",
"operation": "upsert",
"base": {
"__rl": true,
"value": "[AIRTABLE_BASE_ID]",
"mode": "list",
"cachedResultName": "Youtube Research Agent",
"cachedResultUrl": "https://airtable.com/[AIRTABLE_BASE_ID]"
},
"table": {
"__rl": true,
"value": "[AIRTABLE_VIDEOS_TABLE_ID]",
"mode": "list",
"cachedResultName": "Videos",
"cachedResultUrl": "https://airtable.com/[AIRTABLE_BASE_ID]/[AIRTABLE_VIDEOS_TABLE_ID]"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Video Title": "={{ $('Get Videos').item.json.snippet.title.replaceAll(''', \"'\") }}",
"View Count": "={{ $json.statistics.viewCount }}",
"Like Count": "={{ $json.statistics.likeCount }}",
"Comment Count": "={{ $json.statistics.commentCount }}",
"Video ID": "={{ $json.id }}",
"Channel Name": "={{ $('Get Channel').item.json.snippet.title }}",
"Multiplier": "={{ $json.statistics.viewCount / ($('Get Channel').item.json.statistics.viewCount / $('Get Channel').item.json.statistics.videoCount) }} "
},
"matchingColumns": [
"Video ID"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "string",
"readOnly": true,
"removed": false
},
{
"id": "Video ID",
"displayName": "Video ID",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Channel Name",
"displayName": "Channel Name",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Video Title",
"displayName": "Video Title",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "View Count",
"displayName": "View Count",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
},
{
"id": "Like Count",
"displayName": "Like Count",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
},
{
"id": "Comment Count",
"displayName": "Comment Count",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
},
{
"id": "Multiplier",
"displayName": "Multiplier",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "number",
"readOnly": false,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.airtable",
"typeVersion": 2.1,
"position": [
1500,
-320
],
"id": "ae555b15-6e0a-4dcd-b427-6d8944c19150",
"name": "Add Entry",
"credentials": {
"airtableOAuth2Api": {
"id": "[AIRTABLE_CREDENTIAL_ID]",
"name": "Airtable OAuth2 Credential"
}
}
}
],
"pinData": {},
"connections": {
"When clicking 'Test workflow'": {
"main": [
[
{
"node": "Configuration",
"type": "main",
"index": 0
}
]
]
},
"Get Channel": {
"main": [
[
{
"node": "Get Videos",
"type": "main",
"index": 0
}
]
]
},
"Get Videos": {
"main": [
[
{
"node": "Get Video Statistics",
"type": "main",
"index": 0
}
]
]
},
"Get Video Statistics": {
"main": [
[
{
"node": "Last 3 Months",
"type": "main",
"index": 0
}
]
]
},
"Get Channels": {
"main": [
[
{
"node": "Get Channel",
"type": "main",
"index": 0
}
]
]
},
"Configuration": {
"main": [
[
{
"node": "Get Channels",
"type": "main",
"index": 0
}
]
]
},
"Last 3 Months": {
"main": [
[
{
"node": "Add Entry",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "[VERSION_ID]",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "[INSTANCE_ID]"
},
"id": "[WORKFLOW_ID]",
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment