{
  "name": "YouTube Pattern Recognition (Script-wise)",
  "nodes": [
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw",
          "mode": "list",
          "cachedResultName": "YouTube (NeuroEverything) Master Sheet",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 836344211,
          "mode": "list",
          "cachedResultName": "40 Popular YouTube Videos Short Form",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit#gid=836344211"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "STATUS",
              "lookupValue": "PENDING"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -1440,
        -192
      ],
      "id": "9c1a2861-bffb-424c-a8af-3f074f87ac82",
      "name": "Get row(s) in sheet"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -1232,
        -192
      ],
      "id": "a79bfd5c-8fd1-40c1-8d88-1bcf98c56d03",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "jsCode": "let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\nlet result = '';\nlet length = 48; // Desired length of the random string\n\nfor (let i = 0; i < length; i++) {\n  result += characters.charAt(Math.floor(Math.random() * characters.length));\n}\n\nreturn [{ json: { randomString: result } }];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -864,
        -176
      ],
      "id": "d5bb667a-eb73-445b-a626-81b8aafeb909",
      "name": "Code"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Video Title:\n{{ $('Get row(s) in sheet').item.json.Link }}\n\nTranscript:\n{{ $('Get row(s) in sheet').item.json.Transcript }}",
        "options": {
          "systemMessage": "You will be provided with a transcript of a high performing YouTube video within the science category. You will be then expected to analyse what makes this transcript engaging and explain why (on the basis of the video's script) did the script perform well, outlining key aspects that can then be inserted into a Google Sheet so as to be used by another AI agent at a later date to create powerful and highly effective video scripts.\n\nProvide your response in the form of a series of bullet points without ever including filler about what you are about to do etc."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -640,
        -176
      ],
      "id": "22b40a6a-8953-44a6-b3f5-adb2244b69d6",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -656,
        -16
      ],
      "id": "9c0e2c28-8588-4601-b196-9677d515b1f5",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "OjRKrQXB019XKwdP",
          "name": "OpenAi Account (Personal)"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $json.randomString }}",
        "contextWindowLength": 10
      },
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        -544,
        -336
      ],
      "id": "7eadbe5a-58b4-497c-9db9-9920f0203434",
      "name": "Simple Memory"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.toolSerpApi",
      "typeVersion": 1,
      "position": [
        -560,
        -16
      ],
      "id": "b7b97536-0808-41b9-9a33-84093b77d3f6",
      "name": "SerpAPI",
      "credentials": {
        "serpApi": {
          "id": "A7ogaA7Ye8tWnNxu",
          "name": "SerpAPI account"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1.1,
      "position": [
        -464,
        -16
      ],
      "id": "79a48a15-9c73-44d9-985d-ce25634259c6",
      "name": "Think"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw",
          "mode": "list",
          "cachedResultName": "YouTube (NeuroEverything) Master Sheet",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 836344211,
          "mode": "list",
          "cachedResultName": "40 Popular YouTube Videos Short Form",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit#gid=836344211"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $('Get row(s) in sheet').item.json.row_number }}",
            "STATUS": "DONE"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "STATUS",
              "displayName": "STATUS",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Creator",
              "displayName": "Creator",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Transcript",
              "displayName": "Transcript",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Length",
              "displayName": "Length",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "5s Hook",
              "displayName": "5s Hook",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Language Style",
              "displayName": "Language Style",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Human Elements",
              "displayName": "Human Elements",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Emotional Triggers",
              "displayName": "Emotional Triggers",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Pacing",
              "displayName": "Pacing",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Key Moments",
              "displayName": "Key Moments",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -32,
        -176
      ],
      "id": "322766b3-8ef7-4fb4-82f4-4ef5e45b089e",
      "name": "Update row in sheet1"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw",
          "mode": "list",
          "cachedResultName": "YouTube (NeuroEverything) Master Sheet",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": 1973881329,
          "mode": "list",
          "cachedResultName": "AI Analysis",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1PNrsDoa78lTrfIICwqvL3nCCDkUvYvUdmLAAMMHvrTw/edit#gid=1973881329"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Channel": "={{ $('Get row(s) in sheet').item.json.Creator }}",
            "Video Title": "={{ $('Get row(s) in sheet').item.json.Link }}",
            "Duration": "={{ $('Get row(s) in sheet').item.json.Length }}",
            "Transcript": "={{ $('Get row(s) in sheet').item.json.Transcript }}",
            "Analysis": "={{ $json.output }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Channel",
              "displayName": "Channel",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Video Title",
              "displayName": "Video Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Duration",
              "displayName": "Duration",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Transcript",
              "displayName": "Transcript",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysis",
              "displayName": "Analysis",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -208,
        -176
      ],
      "id": "0724a3bb-0781-41f4-98dd-3b1a868f1ba9",
      "name": "Append row in sheet"
    },
    {
      "parameters": {
        "amount": 30
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        176,
        -176
      ],
      "id": "db3e754b-d067-47a6-929b-ea5bdd93d8b2",
      "name": "Wait",
      "webhookId": "4a461641-c4c1-4e02-87e0-744571396d91"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -1728,
        -192
      ],
      "id": "79bcdafc-8ed3-463a-b1d7-be074ff63c6e",
      "name": "When clicking ‘Execute workflow’"
    }
  ],
  "pinData": {},
  "connections": {
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "SerpAPI": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Update row in sheet1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Update row in sheet1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "versionId": "2d679dd7-a239-47a9-8b97-d364ea61a4f3",
  "meta": {
    "instanceId": "5ff5a5992c4c72af22abbdcfa574d8cdf93dc14d57eb9f66e3d9ef2a3e2dbb6c"
  },
  "id": "niYl9z0jzRJN2Ab0",
  "tags": []
}