{
  "id": "33wCtV1uyOtjKFIg",
  "name": "Analyze and report weekly content metrics from YouTube, TikTok and Skool",
  "tags": [],
  "nodes": [
    {
      "id": "9a0a77d5-ec82-43ad-8ad1-9d6e71075156",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2848,
        368
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c94c46c6-446c-47ff-b000-801d08193f07",
      "name": "Markdown",
      "type": "n8n-nodes-base.markdown",
      "position": [
        3296,
        176
      ],
      "parameters": {
        "html": "={{ $json.data }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "2c50ca83-82a8-4594-b879-ee4d5af9bfbd",
      "name": "Get skool members",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        3072,
        176
      ],
      "parameters": {
        "url": "=YOUR_SKOOL_URL_HERE",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/0.0.0.0 Safari/537.36"
            },
            {
              "name": "Accept-Language ",
              "value": "en-US,en;q=0.9"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
            },
            {
              "name": "Connection ",
              "value": "keep-alive"
            },
            {
              "name": "Upgrade-Insecure-Requests",
              "value": "1"
            },
            {
              "name": "Cache-Control",
              "value": "no-cache"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0e46f6b1-ff55-47cd-b497-1da1b7cdb648",
      "name": "Get channel stats",
      "type": "n8n-nodes-base.youTube",
      "position": [
        3296,
        368
      ],
      "parameters": {
        "part": [
          "statistics"
        ],
        "channelId": "YOUR_CHANNEL_ID",
        "operation": "get"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0868ef5d-8337-405d-8332-a2f19fb1c32a",
      "name": "Update record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4608,
        368
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appkessfths2QABG9",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9",
          "cachedResultName": "AI content analysis"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblEeNYoF8mxx6jTZ",
          "cachedResultUrl": "https://airtable.com/appYqri6fFZw0V5qd/tblEeNYoF8mxx6jTZ",
          "cachedResultName": "Current metrics"
        },
        "columns": {
          "value": {
            "Calculation": "={{ $json.Calculation }}",
            "YT sub count": "={{ $('Map out all 3 counts for each social platform').item.json[\"Sub count YT\"] }}",
            "Skool members": "={{ $('Map out all 3 counts for each social platform').item.json[\"Skool members\"] }}",
            "Tiktok Followers": "={{ $('Map out all 3 counts for each social platform').item.json[\"TT followers\"] }}"
          },
          "schema": [
            {
              "id": "id",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "id",
              "defaultMatch": true
            },
            {
              "id": "YT sub count",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "YT sub count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Skool members",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Skool members",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok Followers",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok Followers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Calculation",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "Calculation",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Last Modified",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Last Modified",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Calculation"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "99169032-2e9a-47b3-bc68-425e5f576d26",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        3744,
        352
      ],
      "parameters": {
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "d686e8e4-bf1f-4cee-abb7-af54f53d563f",
      "name": "Search records",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4416,
        368
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appkessfths2QABG9",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9",
          "cachedResultName": "AI content analysis"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblEeNYoF8mxx6jTZ",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9/tblEeNYoF8mxx6jTZ",
          "cachedResultName": "Current metrics"
        },
        "options": {},
        "operation": "search"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "06868695-776a-4b85-8c92-68fd48fdfc6a",
      "name": "Get Video Data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3408,
        1360
      ],
      "parameters": {
        "url": "https://www.googleapis.com/youtube/v3/videos?",
        "options": {},
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "key",
              "value": "YOUR_API_KEY"
            },
            {
              "name": "id",
              "value": "={{ $json.id.videoId }}"
            },
            {
              "name": "part",
              "value": "contentDetails, snippet, statistics"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d66c5a13-ece6-4b09-902d-eb0537888197",
      "name": "Get last weeks vids",
      "type": "n8n-nodes-base.youTube",
      "position": [
        3184,
        1360
      ],
      "parameters": {
        "filters": {
          "channelId": "YOUR_CHANNEL_ID",
          "publishedAfter": "={{ new Date(Date.now() - 7*24*60*60*1000).toISOString() }}"
        },
        "options": {},
        "resource": "video",
        "returnAll": true
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "98eaeb11-4547-40d7-9d42-9246998dbe40",
      "name": "Get Transcripts",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3632,
        1360
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/karamelo~youtube-transcripts/run-sync-get-dataset-items",
        "options": {},
        "jsonBody": "={\n    \"channelIDBoolean\": false,\n    \"channelNameBoolean\": false,\n    \"commentsBoolean\": false,\n    \"datePublishedBoolean\": false,\n    \"dateTextBoolean\": false,\n    \"descriptionBoolean\": false,\n    \"keywordsBoolean\": false,\n    \"likesBoolean\": false,\n    \"maxRetries\": 8,\n    \"proxyOptions\": {\n        \"useApifyProxy\": true,\n        \"apifyProxyGroups\": [\n            \"BUYPROXIES94952\"\n        ]\n    },\n    \"relativeDateTextBoolean\": false,\n    \"thumbnailBoolean\": false,\n    \"urls\": [\"https://www.youtube.com/watch?v={{ $json.items[0].id }}\"],\n    \"viewCountBoolean\": false\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            },
            {
              "name": "Authorization",
              "value": "Bearer YOUR_TOKEN_HERE"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3574f10f-2be8-41c4-8cd6-f3cd58eebfa6",
      "name": "Get tiktok data",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3184,
        2048
      ],
      "parameters": {
        "url": "https://api.apify.com/v2/acts/clockworks~tiktok-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN_HERE",
        "method": "POST",
        "options": {
          "timeout": 31000,
          "redirect": {
            "redirect": {}
          }
        },
        "jsonBody": "={\n  \"profiles\": [\"@YOUR_PROFILE_HERE\"],\n  \"resultsPerPage\": 100,\n  \"shouldDownloadVideos\": false,\n  \"shouldDownloadCovers\": false,\n  \"shouldDownloadSlideshowImages\": false,\n  \"shouldDownloadSubtitles\": false\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "92636232-42cb-4615-a820-7aba5ae6c9f4",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        4448,
        1472
      ],
      "parameters": {
        "numberInputs": 5
      },
      "typeVersion": 3.2
    },
    {
      "id": "ababa275-66ef-4ae9-9f8e-ce4e6738f806",
      "name": "combine items",
      "type": "n8n-nodes-base.code",
      "position": [
        3408,
        2144
      ],
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      combinedItems: items.map(i => i.json)\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "e3d7a399-460f-45a7-a4c3-8b1b3b0319a5",
      "name": "last 7 days?",
      "type": "n8n-nodes-base.if",
      "position": [
        3632,
        1952
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "aad0dbec-604b-4984-acfd-a5e46fd46690",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ new Date($json.postedDateandTime).getTime() }}\n",
              "rightValue": "={{ Date.now() - 7 * 864e5 }}"
            }
          ]
        },
        "looseTypeValidation": true
      },
      "typeVersion": 2.2
    },
    {
      "id": "38c8a730-716a-4642-8081-6e0eeb382f3e",
      "name": "last weeks lable",
      "type": "n8n-nodes-base.code",
      "position": [
        5152,
        1808
      ],
      "parameters": {
        "jsCode": "function getIsoWeekLabel(date){\n  const d=new Date(Date.UTC(date.getFullYear(),date.getMonth(),date.getDate()));\n  const day=d.getUTCDay()||7; d.setUTCDate(d.getUTCDate()+4-day);\n  const yStart=new Date(Date.UTC(d.getUTCFullYear(),0,1));\n  const w=Math.ceil((((d - yStart)/86400000)+1)/7);\n  return `${d.getUTCFullYear()}-W${String(w).padStart(2,'0')}`;\n}\nconst now=new Date();\nnow.setDate(now.getDate()-7); // previous week\nreturn [{ json: { prevWeekLabel: getIsoWeekLabel(now) } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6bb59df7-860a-4a1d-9ea6-dd12b8e1b6b2",
      "name": "Edit Fields4",
      "type": "n8n-nodes-base.set",
      "position": [
        5504,
        1808
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f0ea0cd4-f216-4211-b23d-ba12dd72abda",
              "name": "=Last Week Youtube sub count",
              "type": "string",
              "value": "={{ $json['Total YT subs'] }}"
            },
            {
              "id": "fa682680-79f1-402f-8318-40ff1cdc02c9",
              "name": "Last week tiktok follower count",
              "type": "string",
              "value": "={{ $json['Total TT followers'] }}"
            },
            {
              "id": "9c8ecbf6-e663-41e1-acd9-cf841640cc2e",
              "name": "Last week total skool members",
              "type": "string",
              "value": "={{ $json['Total skool members'] }}"
            },
            {
              "id": "9c9e211f-83fb-4d06-b9a6-42271e8676de",
              "name": "Current Youtube sub count",
              "type": "string",
              "value": "={{ $('current metrics').item.json['YT sub count'] }}"
            },
            {
              "id": "b3c2f979-d187-4b0d-8713-587f4806a3a5",
              "name": "Current tiktok follower count",
              "type": "string",
              "value": "={{ $('current metrics').item.json['Tiktok Followers'] }}"
            },
            {
              "id": "5f04dd58-8e26-41a4-9594-40d36f566cdc",
              "name": "Current skool member count",
              "type": "string",
              "value": "={{ $('current metrics').item.json['Skool members'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "293faad5-92f5-4186-bee8-f37b46aa73e3",
      "name": "add up metrics",
      "type": "n8n-nodes-base.code",
      "position": [
        4800,
        1808
      ],
      "parameters": {
        "jsCode": "// Input shape: current item has an array at $json.allData\nconst rows = Array.isArray($json.allData) ? $json.allData : [];\n\nfunction num(v){ return Number(v ?? 0) || 0; }\n\nfunction isYouTube(r){\n  // Heuristic for YT post records\n  return ('Likes' in r) || ('Comments' in r) || ('favorites' in r);\n}\n\nfunction isTikTok(r){\n  // Heuristic for TikTok post records\n  return ('videoLikes' in r) || ('commentCount' in r) || ('videoSaves' in r) || ('videoShares' in r);\n}\n\nlet ytViews = 0, ytLikes = 0, ytComments = 0, ytFavorites = 0;\nlet ttViews = 0, ttLikes = 0, ttComments = 0, ttSaves = 0, ttShares = 0;\n\nfor (const r of rows){\n  if (isYouTube(r)) {\n    ytViews     += num(r.Views);\n    ytLikes     += num(r.Likes);\n    ytComments  += num(r.Comments);\n    ytFavorites += num(r.favorites);\n  } else if (isTikTok(r)) {\n    ttViews    += num(r.videoViews);\n    ttLikes    += num(r.videoLikes);\n    ttComments += num(r.videoComments);\n    ttSaves    += num(r.videoSaves);\n    ttShares   += num(r.videoShares);\n  } else {\n    // ignore non-post objects like {currentSkoolMembers}, channel stats, weekLabel, etc.\n  }\n}\n\nreturn [{\n  json: {\n    \"YouTube views\": ytViews,\n    \"YouTube likes\": ytLikes,\n    \"YouTube comments\": ytComments,\n    \"YouTube favorites\": ytFavorites,\n    \"TikTok views\": ttViews,\n    \"TikTok likes\": ttLikes,\n    \"TikTok comments\": ttComments,\n    \"TikTok saves\": ttSaves,\n    \"TikTok shares\": ttShares\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "4c4e44cf-0603-46f8-85bd-8d2ed64683da",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        5168,
        1488
      ],
      "parameters": {
        "model": "google/gemini-2.5-flash",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d2c1c895-1340-451d-b969-3ef08112d834",
      "name": "Create a record",
      "type": "n8n-nodes-base.airtable",
      "position": [
        5872,
        1808
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appkessfths2QABG9",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9",
          "cachedResultName": "AI content analysis"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZeg65k0NwWWCD5",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9/tblZeg65k0NwWWCD5",
          "cachedResultName": "Weekly Content KPIs"
        },
        "columns": {
          "value": {
            "Week": "={{ $('Get week lable').item.json.weekLabel }}",
            "YT likes": "={{ $('add up metrics').item.json['YouTube likes'] }}",
            "YT comments": "={{ $('add up metrics').item.json['YouTube comments'] }}",
            "Tiktok likes": "={{ $('add up metrics').item.json['TikTok likes'] }}",
            "Tiktok saves": "={{ $('add up metrics').item.json['TikTok saves'] }}",
            "YT favorites": "={{ $('add up metrics').item.json['YouTube favorites'] }}",
            "Tiktok shares": "={{ $('add up metrics').item.json['TikTok shares'] }}",
            "Total YT subs": "={{ $('Edit Fields4').item.json['Current Youtube sub count'] }}",
            "YT subs added": "={{ $json['YouTube subs added'] }}",
            "Tiktok comments": "={{ $('add up metrics').item.json['TikTok comments'] }}",
            "Total TT followers": "={{ $('Edit Fields4').item.json['Current tiktok follower count'] }}",
            "Skool members added": "={{ $json['Skool members added'] }}",
            "Total skool members": "={{ $('Edit Fields4').item.json['Current skool member count'] }}",
            "Tiktok followers added": "={{ $json['TikTok followers added'] }}"
          },
          "schema": [
            {
              "id": "Week",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Week",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YT subs added",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "YT subs added",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok followers added",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok followers added",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Skool members added",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Skool members added",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YT likes",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "YT likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YT comments",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "YT comments",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "YT favorites",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "YT favorites",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok likes",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok likes",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok comments",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok comments",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok saves",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok saves",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tiktok shares",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Tiktok shares",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "Created",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total YT subs",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Total YT subs",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total TT followers",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Total TT followers",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total skool members",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": false,
              "required": false,
              "displayName": "Total skool members",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "create"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3bdfc9c5-62ea-45af-b240-8b018c17b4ed",
      "name": "last weeks lable1",
      "type": "n8n-nodes-base.code",
      "position": [
        4800,
        1376
      ],
      "parameters": {
        "jsCode": "function getIsoWeekLabel(date){\n  const d=new Date(Date.UTC(date.getFullYear(),date.getMonth(),date.getDate()));\n  const day=d.getUTCDay()||7; d.setUTCDate(d.getUTCDate()+4-day);\n  const yStart=new Date(Date.UTC(d.getUTCFullYear(),0,1));\n  const w=Math.ceil((((d - yStart)/86400000)+1)/7);\n  return `${d.getUTCFullYear()}-W${String(w).padStart(2,'0')}`;\n}\nconst now=new Date();\nnow.setDate(now.getDate()-7); // previous week\nreturn [{ json: { prevWeekLabel: getIsoWeekLabel(now) } }];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e1e98b1d-da51-4fd2-9c8f-6301a166a0a8",
      "name": "Search records1",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4960,
        1376
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appkessfths2QABG9",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9",
          "cachedResultName": "AI content analysis"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZeg65k0NwWWCD5",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9/tblZeg65k0NwWWCD5",
          "cachedResultName": "Weekly Content KPIs"
        },
        "options": {},
        "operation": "search",
        "filterByFormula": "={Week} = \"{{ $json.prevWeekLabel }}\""
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "01cb251d-c94a-4645-aa2b-bcc9da111238",
      "name": "current metrics",
      "type": "n8n-nodes-base.airtable",
      "position": [
        4976,
        1808
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appYqri6fFZw0V5qd",
          "cachedResultUrl": "https://airtable.com/appYqri6fFZw0V5qd",
          "cachedResultName": "AI Content Hub"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblEeNYoF8mxx6jTZ",
          "cachedResultUrl": "https://airtable.com/appYqri6fFZw0V5qd/tblEeNYoF8mxx6jTZ",
          "cachedResultName": "Current metrics"
        },
        "options": {},
        "operation": "search"
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "2586cac8-0297-4214-9c4e-10fa5e7fb680",
      "name": "calculate metrics",
      "type": "n8n-nodes-base.code",
      "position": [
        5680,
        1808
      ],
      "parameters": {
        "jsCode": "function num(v){ return Number(v || 0); }\n\nconst lastYT   = num($json[\"Last Week Youtube sub count\"]);\nconst lastTT   = num($json[\"Last week tiktok follower count\"]);\nconst lastSkool = num($json[\"Last week total skool members\"]);\n\nconst currYT   = num($json[\"Current Youtube sub count\"]);\nconst currTT   = num($json[\"Current tiktok follower count\"]);\nconst currSkool = num($json[\"Current skool member count\"]);\n\nreturn [{\n  json: {\n    \"YouTube subs added\": currYT - lastYT,\n    \"TikTok followers added\": currTT - lastTT,\n    \"Skool members added\": currSkool - lastSkool\n  }\n}];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5bcd9924-6a35-4950-9c7d-36fc7e2f9408",
      "name": "Schedule Trigger1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2640,
        1696
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 21 * * 0"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9933817c-603d-477a-8a99-a2a771249c2b",
      "name": "Markdown1",
      "type": "n8n-nodes-base.markdown",
      "position": [
        3520,
        1008
      ],
      "parameters": {
        "html": "={{ $json.data }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "e71f9a4e-fc89-4df9-8baa-bb906e7f5f94",
      "name": "Get skool members2",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        3296,
        1008
      ],
      "parameters": {
        "url": "=YOUR_SKOOL_URL_HERE",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/0.0.0.0 Safari/537.36"
            },
            {
              "name": "Accept-Language ",
              "value": "en-US,en;q=0.9"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
            },
            {
              "name": "Connection ",
              "value": "keep-alive"
            },
            {
              "name": "Upgrade-Insecure-Requests",
              "value": "1"
            },
            {
              "name": "Cache-Control",
              "value": "no-cache"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "38f7d981-ef84-4957-828c-4058852ed5cd",
      "name": "Merge2",
      "type": "n8n-nodes-base.merge",
      "position": [
        3856,
        2048
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "cc0f8a4c-5b8a-4d85-b85c-37a6dfb9b290",
      "name": "Extract member count1",
      "type": "n8n-nodes-base.set",
      "position": [
        3744,
        1008
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "55391b37-74d6-4b2a-8fa5-bfe6a2c4fc00",
              "name": "currentSkoolMembers",
              "type": "string",
              "value": "={{$json.data.match(/(\\d+)\\s*members/i)?.[1] || $json.data.match(/\\[(\\d+)Members\\]/i)?.[1]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "34577d33-d6ef-4d40-84be-e106a7bab2d7",
      "name": "Get channel stats1",
      "type": "n8n-nodes-base.youTube",
      "position": [
        3520,
        1696
      ],
      "parameters": {
        "part": [
          "statistics"
        ],
        "channelId": "YOUR_CHANNEL_ID",
        "operation": "get"
      },
      "credentials": {
        "youTubeOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "6209a191-5555-40b8-be11-e35111a946a9",
      "name": "Aggregate1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        4608,
        1520
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "allData"
      },
      "typeVersion": 1
    },
    {
      "id": "df74ecc0-3ca4-4d15-ac29-b83872e5e4d7",
      "name": "Search records2",
      "type": "n8n-nodes-base.airtable",
      "position": [
        5328,
        1808
      ],
      "parameters": {
        "base": {
          "__rl": true,
          "mode": "list",
          "value": "appkessfths2QABG9",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9",
          "cachedResultName": "AI content analysis"
        },
        "table": {
          "__rl": true,
          "mode": "list",
          "value": "tblZeg65k0NwWWCD5",
          "cachedResultUrl": "https://airtable.com/appkessfths2QABG9/tblZeg65k0NwWWCD5",
          "cachedResultName": "Weekly Content KPIs"
        },
        "options": {},
        "operation": "search",
        "filterByFormula": "={Week} = \"{{ $json.prevWeekLabel }}\""
      },
      "credentials": {
        "airtableTokenApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1bf9ebbc-ecc6-454b-b38a-cdd9e7fcadd8",
      "name": "Get week lable",
      "type": "n8n-nodes-base.code",
      "position": [
        3616,
        2432
      ],
      "parameters": {
        "jsCode": "function getWeekLabel(date) {\n  // ISO week calculation\n  const d = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));\n  const dayNum = d.getUTCDay() || 7; \n  d.setUTCDate(d.getUTCDate() + 4 - dayNum);\n  const yearStart = new Date(Date.UTC(d.getUTCFullYear(),0,1));\n  const weekNum = Math.ceil((((d - yearStart) / 86400000) + 1)/7);\n  return `${d.getUTCFullYear()}-W${String(weekNum).padStart(2,'0')}`;\n}\n\nconst now = new Date();\nreturn [{ json: { weekLabel: getWeekLabel(now) } }];\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "53696ab3-b2f2-4b3c-9794-c64fb493baa6",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        896
      ],
      "parameters": {
        "color": 3,
        "width": 1456,
        "height": 336,
        "content": "## Scrape your skool community\n### Converts the html to markdown\n### The code then extracts the current active skool members"
      },
      "typeVersion": 1
    },
    {
      "id": "dd841b12-c0f4-4d61-87c1-2e7af734b677",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        1232
      ],
      "parameters": {
        "color": 6,
        "width": 1456,
        "height": 368,
        "content": "## Scrape your youtube channel\n### Returns videos posted in the last 7 days\n### Uses apify actor to get transcripts for each video\n"
      },
      "typeVersion": 1
    },
    {
      "id": "12d0828c-c188-4943-a099-deac40273a9b",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2848,
        864
      ],
      "parameters": {
        "color": 7,
        "width": 1520,
        "height": 1776,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "76771073-5c3c-4b4d-be26-9b54bee87a28",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        1600
      ],
      "parameters": {
        "color": 5,
        "width": 1456,
        "height": 336,
        "content": "## Get current YT sub count"
      },
      "typeVersion": 1
    },
    {
      "id": "2b8adcbd-84ff-46d6-a0b6-644c7fad08dc",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        1936
      ],
      "parameters": {
        "color": 4,
        "width": 1456,
        "height": 336,
        "content": "## Scrape your tiktok \n### Get all vids posted in the last 7 days\n### Gets video stats \n### Get current follower count "
      },
      "typeVersion": 1
    },
    {
      "id": "4b28149a-cfc7-4079-9d90-82323a62c7ff",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2880,
        2272
      ],
      "parameters": {
        "color": 2,
        "width": 1456,
        "height": 336,
        "content": "### Creates the \"week lable\" for storing stats in airtable"
      },
      "typeVersion": 1
    },
    {
      "id": "410f0376-a3b7-47aa-b963-cf3829ab4b9f",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4560,
        1104
      ],
      "parameters": {
        "color": 7,
        "width": 1552,
        "height": 1056,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "cf8977fe-bed7-4f39-a4a5-b9239709e4b5",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4576,
        1120
      ],
      "parameters": {
        "color": 4,
        "width": 1520,
        "height": 512,
        "content": "## Analyze weekly content performance and send HTML style analysis email\n### All current week data and last weeks total sub count, skool member count and followers are fed into LLM\n### LLM then creates an HTML style email report to visually see weekly performance metrics"
      },
      "typeVersion": 1
    },
    {
      "id": "4b528d3a-d412-4d6f-b339-3cfa4f37afcf",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4576,
        1632
      ],
      "parameters": {
        "color": 3,
        "width": 1520,
        "height": 512,
        "content": "## Calculate weekly stats \n### Calculates total likes, comments, shares, saves, favorites for the week\n### Calculates subs gained, followers gained, and skool members added for the week\n### Stores all data in airtable "
      },
      "typeVersion": 1
    },
    {
      "id": "68feb8f1-09ff-42e7-b604-1ce37e97a66f",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 2304,
        "height": 736,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "0b3baacf-2b92-4407-9852-2ad03615db98",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2576,
        64
      ],
      "parameters": {
        "width": 2272,
        "height": 704,
        "content": "## Every 5 min content stats updater \n### Every 5 mins this work flow:\n#### scrapes yout YT\n#### scrapes your TT\n#### scrapes your skool \n\n### Extracts the current sub count, \n### TT followers, and active skool members\n\n### Adds them to airtable"
      },
      "typeVersion": 1
    },
    {
      "id": "17ddfb2c-6b30-4ffd-8947-99b9529a8d07",
      "name": "Get tiktok followers",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        3264,
        576
      ],
      "parameters": {
        "url": "=https://www.tiktok.com/@YOUR_PROFILE_HERE?lang=en",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/0.0.0.0 Safari/537.36"
            },
            {
              "name": "Accept-Language ",
              "value": "en-US,en;q=0.9"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
            },
            {
              "name": "Connection ",
              "value": "keep-alive"
            },
            {
              "name": "Upgrade-Insecure-Requests",
              "value": "1"
            },
            {
              "name": "Cache-Control",
              "value": "no-cache"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0381b69c-e32c-4682-9aef-a31f907e3c67",
      "name": "extract current tiktok followers",
      "type": "n8n-nodes-base.code",
      "position": [
        3488,
        576
      ],
      "parameters": {
        "jsCode": "// Get the HTML from previous node\nconst html = $input.item.json.data;\n\n// Extract JSON from script tag\nconst match = html.match(/<script id=\"__UNIVERSAL_DATA_FOR_REHYDRATION__\" type=\"application\\/json\">(.*?)<\\/script>/s);\n\nif (match) {\n  const data = JSON.parse(match[1]);\n  const stats = data.__DEFAULT_SCOPE__['webapp.user-detail'].userInfo.stats;\n  \n  return {\n    json: {\n      followerCount: stats.followerCount,\n      followingCount: stats.followingCount,\n      videoCount: stats.videoCount,\n      heartCount: stats.heartCount,\n      friendCount: stats.friendCount,\n      username: data.__DEFAULT_SCOPE__['webapp.user-detail'].userInfo.user.uniqueId,\n      nickname: data.__DEFAULT_SCOPE__['webapp.user-detail'].userInfo.user.nickname\n    }\n  };\n}\n\nreturn { json: { error: 'Could not extract data' } };"
      },
      "typeVersion": 2
    },
    {
      "id": "b22244e1-97c9-49b4-96a7-cb901d1fc1fe",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "width": 2496,
        "height": 1408,
        "content": "@[YouTube](XrH5KE-ML80)"
      },
      "typeVersion": 1
    },
    {
      "id": "e8736277-f9dd-416e-b9d3-0e6ab7c4d67b",
      "name": "Format Channel stats",
      "type": "n8n-nodes-base.set",
      "position": [
        3408,
        1952
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ea52b59d-06e1-4d5e-827c-aff247b326ec",
              "name": "description",
              "type": "string",
              "value": "={{ $json.text }}"
            },
            {
              "id": "fa8376a6-57a2-4dc3-8b4c-9e1feca5afa7",
              "name": "videoLikes",
              "type": "string",
              "value": "={{ $json.diggCount }}"
            },
            {
              "id": "ff246fe0-4f57-468c-a74c-f716f14dae1c",
              "name": "videoSaves",
              "type": "string",
              "value": "={{ $json.collectCount }}"
            },
            {
              "id": "4f0a4852-e9bb-4be3-83d9-65e95366cb7d",
              "name": "videoShares",
              "type": "string",
              "value": "={{ $json.shareCount }}"
            },
            {
              "id": "e7594d48-7d54-47b5-96ac-b6505674265d",
              "name": "postedDateandTime",
              "type": "string",
              "value": "={{ $json.createTimeISO }}"
            },
            {
              "id": "703e028d-4b24-48fc-b471-558603d361ed",
              "name": "videoComments",
              "type": "number",
              "value": "={{ $json.commentCount }}"
            },
            {
              "id": "a2413ec4-d3a1-452e-9149-d40403c0a4c4",
              "name": "videoViews",
              "type": "number",
              "value": "={{ $json.playCount }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6bbf1c83-f264-4224-b973-f4e0a6eb65a7",
      "name": "Format youtube sub count",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6094cc8b-da31-4fe6-b35f-887e33668768",
              "name": "YT subs",
              "type": "string",
              "value": "={{ $json.statistics.subscriberCount }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0d15d575-a4e4-4e27-bbc0-61dab36dce81",
      "name": "Extract Skool member count",
      "type": "n8n-nodes-base.set",
      "position": [
        3520,
        176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "55391b37-74d6-4b2a-8fa5-bfe6a2c4fc00",
              "name": "skool mems",
              "type": "string",
              "value": "={{$json.data.match(/(\\d+)\\s*members/i)?.[1] || $json.data.match(/\\[(\\d+)Members\\]/i)?.[1]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8e212488-2562-444b-aefd-7e22c022d222",
      "name": "Map out all 3 counts for each social platform",
      "type": "n8n-nodes-base.set",
      "position": [
        4192,
        368
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "fee2937a-0e26-489b-bf21-2d40cefbf0fc",
              "name": "Skool members",
              "type": "string",
              "value": "={{ $json.data[0][\"skool mems\"] }}"
            },
            {
              "id": "45e16d7d-b85e-478e-b250-3b6cc07dace6",
              "name": "Sub count YT",
              "type": "string",
              "value": "={{ $json.data[1][\"YT subs\"] }}"
            },
            {
              "id": "bb8573df-b6c8-44e7-aef5-0780973ba8e6",
              "name": "TT followers",
              "type": "string",
              "value": "={{ $json.data[2].followerCount }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6fc4e18a-51e4-4433-9a4a-7cd1671ddfed",
      "name": "combine the data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        3968,
        368
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "8236bc04-0d0e-409c-ae0e-e775c4b6d289",
      "name": "Extract follower count for tiktok",
      "type": "n8n-nodes-base.set",
      "position": [
        3632,
        2144
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "f07edd07-2c1a-443b-beea-b4e506724d10",
              "name": "followerCount",
              "type": "string",
              "value": "={{ $json.combinedItems[0].authorMeta.fans }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8c0a1ed0-cea3-4ab7-a75f-2e7cf2ea1e5b",
      "name": "Generate analysis report",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        5152,
        1280
      ],
      "parameters": {
        "text": "=This weeks contetnt data: {{ JSON.stringify($('Aggregate1').item.json.allData) }}\n\n\nLast weeks totals: \n  Youtube subs: {{ $json['Total YT subs'] }}\n\n  Tiktok followers: {{ $json[\"Total TT followers\"] }}\n\n  Skool members: {{ $json[\"Total skool members\"] }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=## ANALYSIS FRAMEWORK\n\n### 1. Performance Overview\n- Total YouTube views and engagement rate\n- Total TikTok views and engagement rate\n- Channel growth (subscribers, followers, community members)\n- Platform comparison\n\n### 2. Top Performers\n\n**YouTube (rank by engagement rate, not just views):**\n- #1: Highest engagement rate video\n- #2: Second highest engagement rate\n- #3: Third highest engagement rate\n- **Special mention:** Most viewed video (if different from top 3 AND has significantly more views)\n\n**TikTok (rank by engagement rate, not just views):**\n- #1: Highest engagement rate post\n- #2: Second highest engagement rate\n- #3: Third highest engagement rate\n- **Special mention:** Most viewed post (if different from top 3 AND has significantly more views) - flag as \"\u26a1 VIRAL\" if views are 10x+ higher than average\n\n**Ranking Philosophy:**\n- PRIMARY: Rank by engagement rate (measures content quality and resonance)\n- SECONDARY: Note highest view counts (measures reach and viral potential)\n- Both metrics matter but serve different purposes: engagement rate = what to replicate for quality, views = what has mass appeal and scales\n\n### 3. Content Analysis\n\n**Topics that resonated:**\n- Extract themes from video titles/transcripts and descriptions\n- Which topics got highest engagement rate?\n- Which topics got most views?\n- Are there topics that excel at both?\n\n**Platform differences:**\n- YouTube: Long-form tutorial content performance\n- TikTok: Short-form content engagement patterns\n- Compare engagement rates between platforms\n\n**Skool CTA effectiveness:**\n- Note which videos include Skool community link\n- Correlation with engagement and community growth?\n\n### 4. Key Insights\n\n**Look for:**\n- High views but low engagement (broad appeal, passive consumption)\n- Low views but high engagement (niche content that resonates deeply - replicate this!)\n- Comment patterns (what drives discussion?)\n- Topic clusters (AI UGC, N8N workflows, automation systems, speed to lead)\n- Tutorial vs conceptual content performance\n- Platform-specific behavior differences (TikTok vs YouTube audience)\n- Viral content characteristics\n\n### 5. Strategic Recommendations\n\n**Must be:**\n- Specific and actionable\n- Based on actual data patterns\n- Prioritized by potential impact\n- Realistic to implement\n- Balance both engagement rate and reach strategies\n\n## OUTPUT FORMAT\n\nYou must return your analysis as a complete HTML email using the exact structure below. Replace content within [DYNAMIC: ...] placeholders with your calculated metrics and analysis.\n\n**CRITICAL HTML FORMATTING RULES:**\n1. NEVER break HTML tags across lines\n2. NEVER split style attributes mid-value\n3. Keep all numeric values and units together (e.g., \"700;\" must stay together)\n4. Double-check all closing tags and quote marks\n5. Verify all font-weight values end with the complete closing: `font-weight: 700;\">` \n```html\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <title>Weekly Content Performance Report</title>\n</head>\n<body style=\"margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f7; color: #1d1d1f;\">\n    \n    <table role=\"presentation\" style=\"width: 100%; border-collapse: collapse;\">\n        <tr>\n            <td style=\"padding: 40px 20px;\">\n                \n                <!-- Main Container -->\n                <table role=\"presentation\" style=\"max-width: 680px; margin: 0 auto; background-color: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,0.08);\">\n                    \n                    <!-- Header -->\n                    <tr>\n                        <td style=\"background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 40px 40px 40px 40px; text-align: center;\">\n                            <h1 style=\"margin: 0; color: #ffffff; font-size: 32px; font-weight: 700; letter-spacing: -0.5px;\">Weekly Content Report</h1>\n                            <p style=\"margin: 12px 0 0 0; color: #e0e7ff; font-size: 16px; font-weight: 500;\">[DYNAMIC: Week label from data, e.g., \"Week 49, 2025\"]</p>\n                        </td>\n                    </tr>\n                    \n                    <!-- Performance Snapshot -->\n                    <tr>\n                        <td style=\"padding: 40px 40px 30px 40px;\">\n                            <h2 style=\"margin: 0 0 24px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\ud83d\udcca Performance Snapshot</h2>\n                            \n                            <table role=\"presentation\" style=\"width: 100%; border-collapse: collapse;\">\n                                <tr>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #f9fafb; border-radius: 12px; vertical-align: top;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #6b7280; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Total YouTube Views</p>\n                                        <p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">[DYNAMIC: Exact sum of all YouTube video views]</p>\n                                        <p style=\"margin: 8px 0 0 0; color: #6b7280; font-size: 14px; font-weight: 600;\">[X.XX]% avg engagement</p>\n                                    </td>\n                                    <td style=\"width: 20px;\"></td>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #f9fafb; border-radius: 12px; vertical-align: top;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #6b7280; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Total TikTok Views</p>\n                                        <p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">[DYNAMIC: Exact sum of all TikTok video views]</p>\n                                        <p style=\"margin: 8px 0 0 0; color: #6b7280; font-size: 14px; font-weight: 600;\">[X.XX]% avg engagement</p>\n                                    </td>\n                                </tr>\n                                <tr>\n                                    <td colspan=\"3\" style=\"height: 20px;\"></td>\n                                </tr>\n                                <tr>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #f9fafb; border-radius: 12px; vertical-align: top;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #6b7280; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">YouTube Subscribers</p>\n                                        <p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">[DYNAMIC: Current subscriber count]</p>\n                                        <p style=\"margin: 8px 0 0 0; color: #10b981; font-size: 14px; font-weight: 600;\">[DYNAMIC: +X this week (+Y.Y%)]</p>\n                                    </td>\n                                    <td style=\"width: 20px;\"></td>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #f9fafb; border-radius: 12px; vertical-align: top;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #6b7280; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">TikTok Followers</p>\n                                        <p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">[DYNAMIC: Current follower count]</p>\n                                        <p style=\"margin: 8px 0 0 0; color: [#10b981 if positive, #ef4444 if negative]; font-size: 14px; font-weight: 600;\">[DYNAMIC: +X this week (+Y.Y%)]</p>\n                                    </td>\n                                </tr>\n                                <tr>\n                                    <td colspan=\"3\" style=\"height: 20px;\"></td>\n                                </tr>\n                                <tr>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #f9fafb; border-radius: 12px; vertical-align: top;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #6b7280; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Skool Community</p>\n                                        <p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">[DYNAMIC: Current member count]</p>\n                                        <p style=\"margin: 8px 0 0 0; color: #10b981; font-size: 14px; font-weight: 600;\">[DYNAMIC: +X this week (+Y.Y%)]</p>\n                                    </td>\n                                    <td style=\"width: 20px;\"></td>\n                                    <td style=\"width: 50%; padding: 20px; background-color: #d1fae5; border-radius: 12px; vertical-align: top; border-left: 4px solid #10b981;\">\n                                        <p style=\"margin: 0 0 8px 0; color: #065f46; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83d\udcc8 Platform Comparison</p>\n                                        <p style=\"margin: 0; color: #065f46; font-size: 13px; line-height: 1.6;\">[DYNAMIC: 1-2 sentence comparison noting which platform drives more engagement/growth and key difference in performance]</p>\n                                    </td>\n                                </tr>\n                            </table>\n                        </td>\n                    </tr>\n                    \n                    <!-- Top Performers -->\n                    <tr>\n                        <td style=\"padding: 0 40px 30px 40px;\">\n                            <h2 style=\"margin: 0 0 20px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\ud83c\udfc6 Top Performers</h2>\n                            \n                            <h3 style=\"margin: 0 0 12px 0; color: #6b7280; font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">YouTube</h3>\n                            \n                            <!-- Top Video 1 -->\n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #fef3c7; border-left: 4px solid #f59e0b; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #92400e; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd47 Highest Engagement Rate</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 18px; font-weight: 700; line-height: 1.4;\">[DYNAMIC: Video title with highest engagement rate]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #78350f; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            <!-- Top Video 2 -->\n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #e0e7ff; border-left: 4px solid #6366f1; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #3730a3; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd48 Second Best Engagement</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 18px; font-weight: 700; line-height: 1.4;\">[DYNAMIC: Video title]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #3730a3; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            <!-- Top Video 3 -->\n                            <div style=\"margin-bottom: 24px; padding: 20px; background-color: #fee2e2; border-left: 4px solid #ef4444; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #991b1b; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd49 Third Best Engagement</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 18px; font-weight: 700; line-height: 1.4;\">[DYNAMIC: Video title]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #991b1b; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            [DYNAMIC: IF highest-view YouTube video is NOT in top 3 by engagement AND has 2x+ more views than the top 3 average, add:]\n                            <!--\n                            <div style=\"margin-bottom: 24px; padding: 16px; background-color: #f3f4f6; border-radius: 8px; border-left: 3px solid #6b7280;\">\n                                <p style=\"margin: 0 0 4px 0; color: #6b7280; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83d\udcc8 Most Viewed (Broad Appeal)</p>\n                                <p style=\"margin: 0; color: #1d1d1f; font-size: 14px; font-weight: 600;\">\"[Video title]\" - [X] views, [Y.YY]% engagement</p>\n                            </div>\n                            -->\n                            \n                            <h3 style=\"margin: 0 0 12px 0; color: #6b7280; font-size: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">TikTok</h3>\n                            \n                            <!-- Top TikTok 1 -->\n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #fef3c7; border-left: 4px solid #f59e0b; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #92400e; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd47 Highest Engagement Rate</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.4; font-style: italic;\">[DYNAMIC: First 80 chars of TikTok description]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #78350f; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            <!-- Top TikTok 2 -->\n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #e0e7ff; border-left: 4px solid #6366f1; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #3730a3; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd48 Second Best Engagement</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.4; font-style: italic;\">[DYNAMIC: First 80 chars of TikTok description]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #3730a3; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            <!-- Top TikTok 3 -->\n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #fee2e2; border-left: 4px solid #ef4444; border-radius: 8px;\">\n                                <p style=\"margin: 0 0 8px 0; color: #991b1b; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\ud83e\udd49 Third Best Engagement</p>\n                                <p style=\"margin: 0 0 12px 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.4; font-style: italic;\">[DYNAMIC: First 80 chars of TikTok description]</p>\n                                <table role=\"presentation\" style=\"width: 100%;\">\n                                    <tr>\n                                        <td style=\"padding: 0; color: #991b1b; font-size: 14px;\">\n                                            <strong>[DYNAMIC: views]</strong> views \u2022 <strong>[DYNAMIC: X.XX%]</strong> engagement\n                                        </td>\n                                    </tr>\n                                </table>\n                            </div>\n                            \n                            [DYNAMIC: IF highest-view TikTok post is NOT in top 3 by engagement AND has 10x+ more views than the top 3 average, add:]\n                            <!--\n                            <div style=\"padding: 16px; background-color: #fef3c7; border-radius: 8px; border-left: 3px solid #f59e0b;\">\n                                <p style=\"margin: 0 0 4px 0; color: #92400e; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;\">\u26a1 VIRAL POST (Exceptional Reach)</p>\n                                <p style=\"margin: 0; color: #1d1d1f; font-size: 14px; font-weight: 600;\">\"[First 60 chars of description]\" - [X] views, [Y.YY]% engagement</p>\n                            </div>\n                            -->\n                        </td>\n                    </tr>\n                    \n                    <!-- What Worked -->\n                    <tr>\n                        <td style=\"padding: 0 40px 30px 40px;\">\n                            <h2 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\u2705 What Worked This Week</h2>\n                            <div style=\"padding: 24px; background-color: #d1fae5; border-radius: 12px; border-left: 4px solid #10b981;\">\n                                <ul style=\"margin: 0; padding-left: 20px; color: #065f46; font-size: 15px; line-height: 1.8;\">\n                                    [DYNAMIC: 3-5 bullet points of successful patterns. Each should be 1-2 sentences with specific data. Focus on both high engagement rate content (quality) and high view content (reach).]\n                                </ul>\n                            </div>\n                        </td>\n                    </tr>\n                    \n                    <!-- Areas for Improvement -->\n                    <tr>\n                        <td style=\"padding: 0 40px 30px 40px;\">\n                            <h2 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\ud83d\udd0d Areas for Improvement</h2>\n                            <div style=\"padding: 24px; background-color: #fef9c3; border-radius: 12px; border-left: 4px solid #eab308;\">\n                                <ul style=\"margin: 0; padding-left: 20px; color: #713f12; font-size: 15px; line-height: 1.8;\">\n                                    [DYNAMIC: 2-4 bullet points identifying underperformance or opportunities. Look for content with good engagement but low reach, or high reach but low engagement.]\n                                </ul>\n                            </div>\n                        </td>\n                    </tr>\n                    \n                    <!-- Key Insights -->\n                    <tr>\n                        <td style=\"padding: 0 40px 30px 40px;\">\n                            <h2 style=\"margin: 0 0 16px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\ud83d\udca1 Key Insights</h2>\n                            <div style=\"padding: 24px; background-color: #f3f4f6; border-radius: 12px;\">\n                                <p style=\"margin: 0; color: #374151; font-size: 15px; line-height: 1.8;\">\n                                    [DYNAMIC: 2-3 paragraphs providing strategic analysis that connects the data points. Should include:\n                                    - Platform comparison and audience behavior differences\n                                    - Balance between engagement rate (quality) and views (reach)\n                                    - Content patterns that drive both quality engagement AND scale\n                                    - How viral content vs high-engagement content serve different strategic purposes\n                                    - Strategic implications for future content]\n                                </p>\n                            </div>\n                        </td>\n                    </tr>\n                    \n                    <!-- Recommendations -->\n                    <tr>\n                        <td style=\"padding: 0 40px 40px 40px;\">\n                            <h2 style=\"margin: 0 0 20px 0; color: #1d1d1f; font-size: 24px; font-weight: 700;\">\ud83c\udfaf Recommendations for Next Week</h2>\n                            \n                            <div style=\"margin-bottom: 16px; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 12px;\">\n                                <p style=\"margin: 0 0 4px 0; color: #e0e7ff; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Priority #1</p>\n                                <p style=\"margin: 0; color: #ffffff; font-size: 16px; font-weight: 600; line-height: 1.6;\">[DYNAMIC: Most impactful, data-driven recommendation - should focus on replicating high-engagement formats]</p>\n                            </div>\n                            \n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #ede9fe; border-radius: 12px; border-left: 4px solid #8b5cf6;\">\n                                <p style=\"margin: 0 0 4px 0; color: #5b21b6; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Priority #2</p>\n                                <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.6;\">[DYNAMIC: Second recommendation - consider leveraging viral topics/formats for broader reach]</p>\n                            </div>\n                            \n                            <div style=\"margin-bottom: 16px; padding: 20px; background-color: #ede9fe; border-radius: 12px; border-left: 4px solid #8b5cf6;\">\n                                <p style=\"margin: 0 0 4px 0; color: #5b21b6; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Priority #3</p>\n                                <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.6;\">[DYNAMIC: Third recommendation]</p>\n                            </div>\n                            \n                            <div style=\"padding: 20px; background-color: #ede9fe; border-radius: 12px; border-left: 4px solid #8b5cf6;\">\n                                <p style=\"margin: 0 0 4px 0; color: #5b21b6; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;\">Priority #4</p>\n                                <p style=\"margin: 0; color: #1d1d1f; font-size: 16px; font-weight: 600; line-height: 1.6;\">[DYNAMIC: Fourth recommendation]</p>\n                            </div>\n                        </td>\n                    </tr>\n                    \n                    <!-- Footer -->\n                    <tr>\n                        <td style=\"padding: 30px 40px; background-color: #f9fafb; text-align: center; border-top: 1px solid #e5e7eb;\">\n                            <p style=\"margin: 0; color: #6b7280; font-size: 13px; line-height: 1.6;\">\n                                Generated automatically by your content analysis system<br>\n                                Keep creating amazing content! \ud83d\ude80\n                            </p>\n                        </td>\n                    </tr>\n                    \n                </table>\n                \n            </td>\n        </tr>\n    </table>\n    \n</body>\n</html>\n```\n\n## CRITICAL INSTRUCTIONS\n\n1. **Maintain HTML Structure:** Do NOT modify any HTML tags, styling, or layout structure. Only replace content within [DYNAMIC: ...] placeholders.\n\n2. **HTML INTEGRITY CHECK - MANDATORY:**\n   - Before outputting, verify EVERY opening tag has a matching closing tag\n   - Verify EVERY style attribute ends with a closing quote and bracket: `\">` \n   - Verify all `font-weight: 700;\">` attributes are COMPLETE - never truncated\n   - Never break numeric values or HTML attributes across multiple lines\n   - All subscriber/follower/member counts must be single, complete numbers\n\n3. **Data Accuracy:** Base all analysis strictly on the provided metrics. Do not invent or assume data not present in the input.\n\n4. **Engagement Rate Calculations:**\n   - **YouTube:** Calculate per video: (likes + comments + favorites) / views * 100\n   - **TikTok:** Calculate per post: (likes + saves + shares + comments) / views * 100\n   - Then AVERAGE those individual rates across all videos/posts\n   - DO NOT calculate total engagements / total views\n   - Example: If video A has 5% and video B has 3%, average is 4%\n\n5. **Top Performer Ranking Logic:**\n   - **PRIMARY RANKING:** Always rank by engagement rate (quality metric)\n   - **SPECIAL MENTIONS:** \n     - For YouTube: Include \"Most Viewed\" IF it's not in top 3 AND has 2x+ more views than top 3 average\n     - For TikTok: Include \"\u26a1 VIRAL POST\" IF it's not in top 3 AND has 10x+ more views than top 3 average\n   - This acknowledges both quality (engagement) and scale (reach)\n\n6. **Growth Calculations:** Use the provided \"Last Week's Totals\" to calculate actual growth numbers. Show both absolute (+X) and percentage growth calculated as: (current - last) / last * 100\n\n7. **Tone:** Professional but conversational. Be direct and actionable, not overly formal.\n\n8. **Brevity:** Keep insights concise but meaningful. Each bullet point should be 1-2 sentences maximum.\n\n9. **Be Specific:** Instead of \"This video did well,\" say \"This video achieved 563 views with 3.91% engagement (2x the channel average of 1.94%).\"\n\n10. **Balance Quality and Scale:** In your analysis, explain the strategic difference between:\n    - High engagement rate content (what to replicate for quality/conversion)\n    - High view count content (what has broad appeal/viral potential)\n    - Both serve important but different purposes in a content strategy\n\n11. **Complete HTML:** Return the ENTIRE HTML document with all your dynamic content inserted. This will be sent directly as an email body.\n\n12. **No Preamble:** Output ONLY the HTML. No explanations, no additional text before or after the HTML.\n\n13. **FINAL VALIDATION STEP:** Before returning your output, scan through and verify:\n    - Every `<p style=\"margin: 0; color: #1d1d1f; font-size: 32px; font-weight: 700;\">` has a number followed by `</p>`\n    - No broken style attributes\n    - All closing tags present\n    - No line breaks inside HTML tags or style values\n    - Special mentions are only included when thresholds are met\n\n## DATA CALCULATION REFERENCE\n\nBased on the provided data structure, here's how to calculate metrics:\n\n**YouTube Videos (identify by having \"Views\", \"Likes\", \"Comments\", \"favorites\" fields):**\n- Calculate engagement per video: (likes + comments + favorites) / views * 100\n- Average all individual engagement rates\n- Sum all views for total\n- Rank by engagement rate for top 3\n- Check if highest-view video should get special mention\n\n**TikTok Posts (identify by having \"videoViews\", \"videoLikes\", \"videoSaves\", \"videoShares\", \"videoComments\" fields):**\n- Calculate engagement per post: (videoLikes + videoSaves + videoShares + videoComments) / videoViews * 100\n- Average all individual engagement rates\n- Sum all videoViews for total\n- Rank by engagement rate for top 3\n- Check if highest-view post should get \"\u26a1 VIRAL\" mention (10x+ threshold)\n\n**Growth Metrics:**\n- YouTube Subscribers: Current from channel stats object - Last week's value\n- TikTok Followers: Current from followerCount object - Last week's value\n- Skool Members: Current from currentSkoolMembers object - Last week's value\n- Calculate percentage: (growth / last week's value) * 100\n\n**Example Rankings:**\n\nIf you have these TikTok posts:\n1. Post A: 628 views, 8.28% engagement \u2190 Rank #1 (highest engagement)\n2. Post B: 2,613 views, 7.58% engagement \u2190 Rank #2\n3. Post C: 118,900 views, 7.30% engagement \u2190 Rank #3\n4. Average of top 3 views: (628 + 2,613 + 118,900) / 3 = 40,714\n\nSince Post C has 118,900 views (which is 2.9x the average, but NOT 10x+), it does NOT qualify for \"\u26a1 VIRAL\" special mention. It's correctly placed in #3.\n\nHowever, if there was a Post D with 500,000 views and 6% engagement (not in top 3), and the average of top 3 views was 40,714, Post D would qualify (500k is 12x the average) for the \"\u26a1 VIRAL POST\" special mention.\n\nUse these calculation methods consistently across all data."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.7
    },
    {
      "id": "972d4438-f96a-487e-9d0d-7f9e1a4f2b7a",
      "name": "Send html style report to your email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        5472,
        1376
      ],
      "parameters": {
        "sendTo": "YOUR_EMAIL_HERE",
        "message": "={{ $json.text }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Weekly content performance"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "db113485-caf6-4772-ac1b-7b302197eba6",
      "name": "Format youtube video stats",
      "type": "n8n-nodes-base.set",
      "position": [
        3856,
        1360
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b1b7b5f6-f769-4bcb-97cf-51ca593bd768",
              "name": "=videoTitle",
              "type": "string",
              "value": "={{ $json.title }}"
            },
            {
              "id": "04060c1b-ab2c-4b6e-91a7-150b73fb27d7",
              "name": "Description",
              "type": "string",
              "value": "={{ $('Get Video Data').item.json.items[0].snippet.description }}"
            },
            {
              "id": "d9623810-d9d2-4b1e-8c91-8a76908baf38",
              "name": "Views",
              "type": "string",
              "value": "={{ $('Get Video Data').item.json.items[0].statistics.viewCount }}"
            },
            {
              "id": "c831582d-545a-49b8-b614-eed3bee2f1cc",
              "name": "Likes",
              "type": "string",
              "value": "={{ $('Get Video Data').item.json.items[0].statistics.likeCount }}"
            },
            {
              "id": "1e8f6457-7922-49fb-9010-e328c7f3e9f3",
              "name": "Comments",
              "type": "string",
              "value": "={{ $('Get Video Data').item.json.items[0].statistics.commentCount }}"
            },
            {
              "id": "6f85dd38-8e4b-4993-aec9-9280c17e12cb",
              "name": "favorites",
              "type": "string",
              "value": "={{ $('Get Video Data').item.json.items[0].statistics.favoriteCount }}"
            },
            {
              "id": "f2654041-001f-43c3-8deb-e654d9c5a9ae",
              "name": "Transcript",
              "type": "string",
              "value": "={{ $json.captions }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "675bbb1f-3297-4fbb-a143-7ca9a7cbafd2",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        1520
      ],
      "parameters": {
        "width": 1056,
        "height": 1056,
        "content": "# Weekly AI Content Consultant & Reporter\n## Created by: [Jordan Austin](https://www.skool.com/ai-growth-lab-4394/about?ref=5065ab28874b4325b44ef3ead8105722)\n\n## \ud83c\udfaf Who is this for\nContent creators, agencies, and community managers who want to automate their weekly metrics reporting without manual data entry.\n\n## \ud83d\udca1 How it works\nEvery Sunday at 9:00 PM, this workflow:\n1. **Scrapes Metrics:** Gathers video stats and follower counts from your YouTube, TikTok, and Skool community.\n2. **Filters Content:** Identifies videos posted in the last 7 days.\n3. **Calculates Growth:** Compares current metrics against \"Last Week's\" data stored in Airtable to determine net growth.\n4. **AI Analysis:** Feeds data and transcripts into an LLM to generate a strategic HTML report.\n5. **Reporting:** Emails you the formatted report and archives the data in Airtable.\n\n## \ud83d\uded1 CRITICAL: First Run Setup\nThis system calculates growth by looking for a record from the **previous week**. Since you are setting this up new, that record does not exist yet.\n\n**You must create a \"Baseline Record\" manually so the first run works:**\n1. Open your new Airtable Base and go to the **\"Weekly Content KPIs\"** table.\n2. Create a new row.\n3. **Week Column:** Enter the *previous* week's ISO label (e.g., if today is Week 45, enter `2025-W44`).\n4. **Totals Columns:** Manually enter your *current* total `YT subs`, `TT followers`, and `Skool members`.\n5. **Result:** When the workflow runs next Sunday (Week 46), it will look back for \"Week 45\", find this record, and accurately calculate your growth.\n\n## \u2699\ufe0f Configuration\n1. **Airtable:**\n   - Duplicate this base: [AI Content Hub Template](https://airtable.com/appkessfths2QABG9/shr1ceynxbhDcTSxB)\n   - Connect your Airtable credential.\n   - Update all Airtable nodes to point to your new Base ID.\n2. **Variables:**\n   - Update the URL/ID variables in the first node (or HTTP nodes) with your specific Skool URL, TikTok Profile, and YouTube Channel ID.\n3. **Credentials:**\n   - Ensure you have accounts for Apify, Google (YouTube/Gmail), and OpenRouter.\n\n## \ud83d\udd0c APIs Required\n- [Apify](https://www.apify.com) (uses actors for scraping)- [For more info on how to set up apify api](https://docs.apify.com/)\n- [WATCH THIS TO LEARN HOW TO SET UP ALL GOOGLE APIS](https://youtube.com/shorts/FBRQNmCN0F8?feature=share) (Youtube) - [For more info on setting up the youtube api](https://docs.n8n.io/integrations/builtin/credentials/google/?utm_source=n8n_app&utm_medium=credential_settings&utm_campaign=create_new_credentials_modal)\n- [Airtable](https://airtable.com) - [For more info on airtable](https://docs.n8n.io/integrations/builtin/credentials/airtable/?utm_source=n8n_app&utm_medium=credential_settings&utm_campaign=create_new_credentials_modal)\n- [OpenRouter](https://openrouter.ai/) (or OpenAI) - [For more info on OpenRouter]((https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatopenrouter/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=%40n8n%2Fn8n-nodes-langchain.lmChatOpenRouter))"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "ae62069a-31ba-4f2e-85c7-0e3ac771be0e",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "combine the data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Aggregate1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge2": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 3
          }
        ]
      ]
    },
    "Markdown": {
      "main": [
        [
          {
            "node": "Extract Skool member count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown1": {
      "main": [
        [
          {
            "node": "Extract member count1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate1": {
      "main": [
        [
          {
            "node": "add up metrics",
            "type": "main",
            "index": 0
          },
          {
            "node": "last weeks lable1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields4": {
      "main": [
        [
          {
            "node": "calculate metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "last 7 days?": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "combine items": {
      "main": [
        [
          {
            "node": "Extract follower count for tiktok",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Video Data": {
      "main": [
        [
          {
            "node": "Get Transcripts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get week lable": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 4
          }
        ]
      ]
    },
    "Search records": {
      "main": [
        [
          {
            "node": "Update record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "add up metrics": {
      "main": [
        [
          {
            "node": "current metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Transcripts": {
      "main": [
        [
          {
            "node": "Format youtube video stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get tiktok data": {
      "main": [
        [
          {
            "node": "Format Channel stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "combine items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search records1": {
      "main": [
        [
          {
            "node": "Generate analysis report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search records2": {
      "main": [
        [
          {
            "node": "Edit Fields4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "current metrics": {
      "main": [
        [
          {
            "node": "last weeks lable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get skool members",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get channel stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get tiktok followers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "combine the data": {
      "main": [
        [
          {
            "node": "Map out all 3 counts for each social platform",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "last weeks lable": {
      "main": [
        [
          {
            "node": "Search records2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get channel stats": {
      "main": [
        [
          {
            "node": "Format youtube sub count",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get skool members": {
      "main": [
        [
          {
            "node": "Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "Get last weeks vids",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get skool members2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get tiktok data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get channel stats1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get week lable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "calculate metrics": {
      "main": [
        [
          {
            "node": "Create a record",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "last weeks lable1": {
      "main": [
        [
          {
            "node": "Search records1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get channel stats1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Get skool members2": {
      "main": [
        [
          {
            "node": "Markdown1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get last weeks vids": {
      "main": [
        [
          {
            "node": "Get Video Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Channel stats": {
      "main": [
        [
          {
            "node": "last 7 days?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get tiktok followers": {
      "main": [
        [
          {
            "node": "extract current tiktok followers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract member count1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate analysis report",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Format youtube sub count": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Generate analysis report": {
      "main": [
        [
          {
            "node": "Send html style report to your email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Skool member count": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format youtube video stats": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "extract current tiktok followers": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Extract follower count for tiktok": {
      "main": [
        [
          {
            "node": "Merge2",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Map out all 3 counts for each social platform": {
      "main": [
        [
          {
            "node": "Search records",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}