{
  "name": "Analyze Meta Ad Library Video Ads with Gemini and store results in Google Sheets",
  "nodes": [
    {
      "id": "30c7e140-fafe-4ae7-9de9-a969857967d5",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -100,
        380
      ]
    },
    {
      "id": "d38614bf-bbcc-4619-bcc4-cb42a80a1148",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "position": [
        100,
        380
      ]
    },
    {
      "id": "7bb34d03-5cf0-497a-bead-87df84661ffd",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1960,
        380
      ]
    },
    {
      "id": "d23fed5b-f230-4511-b4ea-76393617e740",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        3460,
        700
      ]
    },
    {
      "id": "e56dbefc-458f-40db-850e-f243740c5651",
      "name": "Clean Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        300,
        380
      ]
    },
    {
      "id": "6dbce614-58ce-4389-be16-a117ba5b6032",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        0
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "1f26b54d-d0c5-483b-b3cf-e5e971128f2e",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3260,
        300
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "e554fcd8-90f0-4f38-ad78-1b08f4cd4a82",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3360,
        860
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "96359003-2cd3-4ebf-90aa-8be4c44f1949",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3640,
        320
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "3e3c13b8-063c-4e0d-99dd-93902646c197",
      "name": "Store Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3860,
        440
      ]
    },
    {
      "id": "717fa264-afc3-4e2f-a48a-f3101e3ccf97",
      "name": "Structured Output Parsing Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        3480,
        440
      ]
    },
    {
      "id": "a61b82eb-21bf-4a0a-8863-e3fd3321c280",
      "name": "Wait for Upload Processing",
      "type": "n8n-nodes-base.wait",
      "position": [
        3020,
        440
      ]
    },
    {
      "id": "b3a0113f-a5e4-45e6-b093-a61ec5933446",
      "name": "Pass Values for Gemini",
      "type": "n8n-nodes-base.set",
      "position": [
        2780,
        440
      ]
    },
    {
      "id": "590f1356-4e6a-4e2a-aef4-9ec3c421b3bf",
      "name": "Upload Video to Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2580,
        440
      ]
    },
    {
      "id": "88d88a31-4137-40e9-8470-4fb247cfac27",
      "name": "Analyze Video with Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3240,
        440
      ]
    },
    {
      "id": "2168902d-1a0c-4807-9e88-08b9349ba19a",
      "name": "Download File",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2200,
        440
      ]
    },
    {
      "id": "4fc6c731-ac04-4b33-a7df-919bff17ddc1",
      "name": "Change Filetype to Video",
      "type": "n8n-nodes-base.code",
      "position": [
        2380,
        440
      ]
    },
    {
      "id": "9cb29e1e-be52-4f7d-90aa-c930d283d442",
      "name": "Scrape Meta Ad Library with Apify",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        500,
        380
      ]
    },
    {
      "id": "59a198fa-3859-41a0-806b-280e9b9dd72a",
      "name": "Pass relevant Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1720,
        380
      ]
    },
    {
      "id": "ea30c850-3ae8-455e-9681-f42f59681a8a",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        3660,
        700
      ]
    },
    {
      "id": "ac3ae0cd-8dda-4b38-858e-d3f4f21f7e5c",
      "name": "Calculate Runtime in Days",
      "type": "n8n-nodes-base.set",
      "position": [
        700,
        380
      ]
    },
    {
      "id": "28d391b3-d708-43a1-9d4b-28da08bc8175",
      "name": "Sort by Reach or Days Running",
      "type": "n8n-nodes-base.sort",
      "position": [
        960,
        380
      ]
    },
    {
      "id": "82f7bdd7-5d20-4431-9772-4255e21ea963",
      "name": "Filter only Video Ads",
      "type": "n8n-nodes-base.filter",
      "position": [
        1200,
        380
      ]
    },
    {
      "id": "b0a7273e-f540-49e9-98c2-f0437ea2749d",
      "name": "Limit Videos to Analyze",
      "type": "n8n-nodes-base.limit",
      "position": [
        1460,
        380
      ]
    }
  ],
  "connections": {
    "Settings": {
      "main": [
        [
          {
            "node": "Clean Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Prompt": {
      "main": [
        [
          {
            "node": "Scrape Meta Ad Library with Apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Change Filetype to Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pass relevant Fields": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter only Video Ads": {
      "main": [
        [
          {
            "node": "Limit Videos to Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pass Values for Gemini": {
      "main": [
        [
          {
            "node": "Wait for Upload Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video to Gemini": {
      "main": [
        [
          {
            "node": "Pass Values for Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit Videos to Analyze": {
      "main": [
        [
          {
            "node": "Pass relevant Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change Filetype to Video": {
      "main": [
        [
          {
            "node": "Upload Video to Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Structured Output Parsing Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Structured Output Parsing Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Video with Gemini": {
      "main": [
        [
          {
            "node": "Structured Output Parsing Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Runtime in Days": {
      "main": [
        [
          {
            "node": "Sort by Reach or Days Running",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait for Upload Processing": {
      "main": [
        [
          {
            "node": "Analyze Video with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sort by Reach or Days Running": {
      "main": [
        [
          {
            "node": "Filter only Video Ads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parsing Agent": {
      "main": [
        [
          {
            "node": "Store Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Meta Ad Library with Apify": {
      "main": [
        [
          {
            "node": "Calculate Runtime in Days",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}