{
  "name": "Analyze Meta ads daily with Google Gemini and Google Sheets",
  "nodes": [
    {
      "id": "fead4f03-9842-47f8-838f-c5137b2f0d5a",
      "name": "Template Guide",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -32
      ],
      "parameters": {
        "width": 486,
        "height": 608,
        "content": "## Analyze Meta ads with Gemini and Google Sheets\n\n**How it works:**\n1.  **Extract:** Fetches Ad and Campaign data from Meta API (Yesterday's data).\n2.  **Process:** Aggregates data by Campaign and Ad"
      }
    },
    {
      "id": "8936023f-8462-4525-aca0-1f76203fcbd6",
      "name": "Get Config",
      "type": "n8n-nodes-base.set",
      "position": [
        1552,
        -240
      ]
    },
    {
      "id": "193a9ee7-1c12-46cb-b318-f767137a316d",
      "name": "Send Error Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1776,
        -240
      ]
    },
    {
      "id": "a9d35f35-e8c1-42f9-bb5b-8ca26eefc6be",
      "name": "Structure Data Hierarchy",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        128
      ]
    },
    {
      "id": "29c78e97-ea13-4ff3-9a9e-329a9ac3eb7d",
      "name": "Write Insights",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1216,
        128
      ]
    },
    {
      "id": "8ccc0b9f-d870-4e5f-a0d0-469bb2bfecc0",
      "name": "Save AI Insights",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2032,
        128
      ]
    },
    {
      "id": "1980b51b-fb7a-4b18-95aa-9cb02ec16158",
      "name": "Save Ad Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        784,
        304
      ]
    },
    {
      "id": "dd95a46b-39ff-49b4-8d34-516a19a8ea73",
      "name": "Save Campaign Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1008,
        -240
      ]
    },
    {
      "id": "574a9644-05f3-4df0-a9d8-4fea57a8f562",
      "name": "Set Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -16,
        -240
      ]
    },
    {
      "id": "e86432fc-a55d-41f6-ad7f-270129ae2f7e",
      "name": "Split AI Insights",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1840,
        128
      ]
    },
    {
      "id": "20e6389f-3feb-4b96-bb12-eaedb5c6cc6a",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1392,
        352
      ]
    },
    {
      "id": "482dd147-d952-4915-adf9-1b7766e47741",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1216,
        352
      ]
    },
    {
      "id": "3650d021-a1db-494c-9869-027994b0131a",
      "name": "Get Ad Insights - Ad Level",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        368,
        128
      ]
    },
    {
      "id": "131c45ee-14b8-457f-b6ea-aabe65961104",
      "name": "Get Ad Insights - Campaign Level",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        352,
        -240
      ]
    },
    {
      "id": "90e8a0dc-3788-4925-94b1-9fbac67d91f4",
      "name": "Split Ad Data",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        592,
        128
      ]
    },
    {
      "id": "132888b7-a5ee-4985-bb70-184345e2eb9a",
      "name": "Filter Zero Spend",
      "type": "n8n-nodes-base.filter",
      "position": [
        800,
        -240
      ]
    },
    {
      "id": "b6db113e-a4e3-48b6-baaf-48a6050b3490",
      "name": "Split Campaign Data",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        592,
        -240
      ]
    },
    {
      "id": "91b6916f-c095-4961-8c12-f4c51dc33453",
      "name": "Error Trigger",
      "type": "n8n-nodes-base.errorTrigger",
      "position": [
        1328,
        -240
      ]
    },
    {
      "id": "39328528-4432-41cb-9928-db5520f8ea1d",
      "name": "Schedule - Once per day",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -320,
        -240
      ]
    },
    {
      "id": "1c62cf57-7a30-4c82-be4e-f5ee409419e8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -368,
        -368
      ],
      "parameters": {
        "width": 480,
        "height": 288,
        "content": "## Configuration & schedule\n• Define run frequency\n• Set account and reporting parameters\n"
      }
    },
    {
      "id": "5990642f-977b-4e46-9ad6-04557dfb58c7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -368
      ],
      "parameters": {
        "width": 880,
        "height": 288,
        "content": "## Campaign-level data collection\n• Fetch campaign performance data\n• Remove zero-spend campaigns\n• Store clean campaign metrics\n"
      }
    },
    {
      "id": "23cf66be-16d5-45fb-bd5e-061ac14560ca",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -16
      ],
      "parameters": {
        "width": 720,
        "height": 496,
        "content": "## Ad-level data collection\n• Fetch ad-level performance data\n• Normalize and structure records\n• Persist raw ad metrics\n"
      }
    },
    {
      "id": "e9927923-b091-4dfc-8b71-026663ca5f86",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -16
      ],
      "parameters": {
        "width": 480,
        "height": 512,
        "content": "## AI analysis & insights\n• Analyze performance with Gemini\n• Detect winners and underperformers\n• Generate actionable recommendations\n"
      }
    },
    {
      "id": "cb8b95e6-7967-4c67-9f7b-cfe41f2362c1",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        -16
      ],
      "parameters": {
        "width": 480,
        "height": 512,
        "content": "## Insights storage\n• Split structured AI output\n• Save insights for reporting\n"
      }
    },
    {
      "id": "e5dcc793-68a0-4f4f-8f1d-2d8a86f710cf",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -368
      ],
      "parameters": {
        "width": 720,
        "height": 288,
        "content": "## Error handling\n• Catch workflow failures\n• Send notification email\n"
      }
    }
  ],
  "connections": {
    "Get Config": {
      "main": [
        [
          {
            "node": "Send Error Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Trigger": {
      "main": [
        [
          {
            "node": "Get Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Ad Data": {
      "main": [
        [
          {
            "node": "Save Ad Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Structure Data Hierarchy",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Insights": {
      "main": [
        [
          {
            "node": "Split AI Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Zero Spend": {
      "main": [
        [
          {
            "node": "Save Campaign Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Configuration": {
      "main": [
        [
          {
            "node": "Get Ad Insights - Campaign Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split AI Insights": {
      "main": [
        [
          {
            "node": "Save AI Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Campaign Data": {
      "main": [
        [
          {
            "node": "Filter Zero Spend",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule - Once per day": {
      "main": [
        [
          {
            "node": "Set Configuration",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Ad Insights - Ad Level",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Write Insights",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structure Data Hierarchy": {
      "main": [
        [
          {
            "node": "Write Insights",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Write Insights",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get Ad Insights - Ad Level": {
      "main": [
        [
          {
            "node": "Split Ad Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Ad Insights - Campaign Level": {
      "main": [
        [
          {
            "node": "Split Campaign Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}