{
  "name": "Scrape & analyse Meta Ad Library image ads with Apify and OpenAI",
  "nodes": [
    {
      "id": "0d98546f-9c0b-475d-81d3-d63c5dd18bc4",
      "name": "When clicking ‘Test workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -120,
        380
      ]
    },
    {
      "id": "54f05394-221a-4e50-b4f5-50e4b7b4cc8a",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "position": [
        80,
        380
      ]
    },
    {
      "id": "3cac5c6a-bd72-4c39-9232-5926e4ef1cd0",
      "name": "Clean Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        280,
        380
      ]
    },
    {
      "id": "a6418f56-233c-410e-8186-ff40a993c980",
      "name": "Scrape Meta Ad Library with Apify",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        480,
        380
      ]
    },
    {
      "id": "a5502f95-ecc4-47d9-a6ef-0d17257f8255",
      "name": "Pass relevant Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        1700,
        380
      ]
    },
    {
      "id": "32a72f8f-ae54-4c3c-8d1a-5859a5360275",
      "name": "Calculate Runtime in Days",
      "type": "n8n-nodes-base.set",
      "position": [
        720,
        380
      ]
    },
    {
      "id": "4e8f97f3-b65b-4bf3-ab30-8572af490dda",
      "name": "Sort by Reach or Days Running",
      "type": "n8n-nodes-base.sort",
      "position": [
        940,
        380
      ]
    },
    {
      "id": "b709b632-647c-4ff8-8f0a-f1f7163841ef",
      "name": "Filter only Image Ads",
      "type": "n8n-nodes-base.filter",
      "position": [
        1180,
        380
      ]
    },
    {
      "id": "20255e0f-f34c-4499-b2e4-c19330047998",
      "name": "Limit Images to Analyze",
      "type": "n8n-nodes-base.limit",
      "position": [
        1440,
        380
      ]
    },
    {
      "id": "4ccd7e75-f124-481f-be20-2d2dd7b811f9",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2380,
        320
      ]
    },
    {
      "id": "66e268d4-5db5-485d-ba63-f48af4557429",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        2560,
        320
      ]
    },
    {
      "id": "8edfd824-8571-4cc7-b1f4-2172e3d0ad47",
      "name": "Download Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1960,
        380
      ]
    },
    {
      "id": "dcc7f234-14f8-4e71-8c2f-2f6611b1126d",
      "name": "Analyze Image Contents",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2380,
        80
      ]
    },
    {
      "id": "2b3dbff9-da61-4f94-a77a-0728456e5c4e",
      "name": "Save Image to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2440,
        580
      ]
    },
    {
      "id": "34c28c32-a4d2-49da-a2e9-f97bbb131031",
      "name": "Merge Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        2820,
        360
      ]
    },
    {
      "id": "7e2af3a6-2129-4dc0-a88a-92672191b66b",
      "name": "Store Data in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        3120,
        360
      ]
    },
    {
      "id": "0ba0d9b7-2b83-4131-87d1-66c68c8c776b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        260
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    },
    {
      "id": "69c089a0-df87-4723-8362-fb8c198fc130",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2360,
        780
      ],
      "parameters": {
        "width": null,
        "height": null,
        "content": ""
      }
    }
  ],
  "connections": {
    "Settings": {
      "main": [
        [
          {
            "node": "Clean Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Data": {
      "main": [
        [
          {
            "node": "Store Data in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Prompt": {
      "main": [
        [
          {
            "node": "Scrape Meta Ad Library with Apify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Image": {
      "main": [
        [
          {
            "node": "Save Image to Google Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Analyze Image Contents",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analyze Image Contents",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Pass relevant Fields": {
      "main": [
        [
          {
            "node": "Download Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter only Image Ads": {
      "main": [
        [
          {
            "node": "Limit Images to Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Image Contents": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit Images to Analyze": {
      "main": [
        [
          {
            "node": "Pass relevant Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Analyze Image Contents",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Runtime in Days": {
      "main": [
        [
          {
            "node": "Sort by Reach or Days Running",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Image to Google Drive": {
      "main": [
        [
          {
            "node": "Merge Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Store Data in Google Sheets": {
      "main": [
        []
      ]
    },
    "Sort by Reach or Days Running": {
      "main": [
        [
          {
            "node": "Filter only Image Ads",
            "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
          }
        ]
      ]
    }
  }
}