{
  "name": "Optimize Instagram hashtags with GPT-4o & real engagement data via Graph API",
  "nodes": [
    {
      "id": "af47f63f-2c54-4e11-9be2-66f9a3983049",
      "name": "Manual Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        1664,
        2752
      ]
    },
    {
      "id": "97f03e91-0108-4fd8-bd0f-c0bf691dab6b",
      "name": "Set Dummy Caption",
      "type": "n8n-nodes-base.set",
      "position": [
        1888,
        2752
      ]
    },
    {
      "id": "51119ee4-4be2-454e-ae24-713849ebb3c5",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2144,
        2912
      ]
    },
    {
      "id": "1cd632c4-cee8-46eb-b334-935dc640d525",
      "name": "Generate Initial Hashtags",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        2144,
        2576
      ]
    },
    {
      "id": "e47315ec-3fa6-48d8-b404-08ab28d165e5",
      "name": "Parse & Clean Tags",
      "type": "n8n-nodes-base.code",
      "position": [
        2448,
        2576
      ]
    },
    {
      "id": "e9f84e2b-ce3b-4078-b1a1-3630f65c8715",
      "name": "Fetch Cached Hashtags",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2448,
        2832
      ]
    },
    {
      "id": "3518e6e7-65ba-45df-b6a8-3e2dcabd741d",
      "name": "Split In Batches",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        3408,
        2576
      ]
    },
    {
      "id": "b4336549-b98d-4c94-ada7-c06671456392",
      "name": "Check if Tag Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        3840,
        2144
      ]
    },
    {
      "id": "1fc9bb2a-9e23-49c5-8ca9-1f93011e96d4",
      "name": "Save to Cache",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        4880,
        2064
      ]
    },
    {
      "id": "db82c644-e0fe-4142-847c-f9f189ac1607",
      "name": "Rate Limit Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        5104,
        2256
      ]
    },
    {
      "id": "a9f06fe5-9133-42eb-976b-aa9b37a0f47d",
      "name": "Merge Cache & Fresh",
      "type": "n8n-nodes-base.merge",
      "position": [
        3696,
        2704
      ]
    },
    {
      "id": "4a59c75e-5769-4496-969e-30a16384b156",
      "name": "Aggregate & Rank Candidates",
      "type": "n8n-nodes-base.code",
      "position": [
        3872,
        2704
      ]
    },
    {
      "id": "cf3d233b-5c53-4977-91af-2b462767a4c3",
      "name": "Format New Hashtag Data",
      "type": "n8n-nodes-base.set",
      "position": [
        4656,
        2064
      ]
    },
    {
      "id": "30863e06-c7f4-4711-85b1-d3d8dff49c3b",
      "name": "Check Cache Status",
      "type": "n8n-nodes-base.code",
      "position": [
        2960,
        2736
      ]
    },
    {
      "id": "684590af-e173-4e7d-8275-8755b053ce65",
      "name": "Merge Input",
      "type": "n8n-nodes-base.merge",
      "position": [
        2784,
        2736
      ]
    },
    {
      "id": "c4accef3-aa36-4f62-8105-2aa5dacad19d",
      "name": "Route Cached vs New",
      "type": "n8n-nodes-base.if",
      "position": [
        3136,
        2736
      ]
    },
    {
      "id": "9257d4bd-8f58-46d4-b076-626c70985a58",
      "name": "Get Hashtag Info",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        3600,
        2224
      ]
    },
    {
      "id": "4421b2d4-e25e-4f85-9cee-e62b009c1243",
      "name": "Get Hashtag Metrics",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        4192,
        2064
      ]
    },
    {
      "id": "7ac65007-39c9-4167-8ad6-677f7eee0ca5",
      "name": "Calculate Average Metrics",
      "type": "n8n-nodes-base.code",
      "position": [
        4432,
        2064
      ]
    },
    {
      "id": "b2314331-1173-4f24-868c-7f37d18d3181",
      "name": "AI Model Selector",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        4064,
        2880
      ]
    },
    {
      "id": "90d1db2f-ba32-4efe-a167-82e9d8a3338e",
      "name": "Select Top 5 Hashtags",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        4064,
        2704
      ]
    },
    {
      "id": "12d15702-4af6-42f5-9262-e14c50dcf0c6",
      "name": "Format Output",
      "type": "n8n-nodes-base.set",
      "position": [
        4384,
        2704
      ]
    },
    {
      "id": "73f9ce86-0afc-4c95-a987-708952547f55",
      "name": "Workflow Trigger",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        1664,
        2576
      ]
    },
    {
      "id": "df67bfb9-558a-41a2-8120-9cae690cb1e3",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        2368
      ],
      "parameters": {
        "width": 643,
        "height": 734,
        "content": "## 🚀 Instagram Hashtag Generator\nThis workflow automatically generates 5 optimized hashtags for your Instagram post by combining AI suggestions with real-time performance data (average likes/comments)"
      }
    },
    {
      "id": "7c59ed3a-9f9e-4f26-b59f-d97b573c41d7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        2368
      ],
      "parameters": {
        "width": 490,
        "height": 736,
        "content": "## 1. Input Processing\nAccepts caption from either Manual Trigger or another Workflow."
      }
    },
    {
      "id": "a239cd2d-02fa-463f-aff2-152e9f4ca955",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2096,
        2368
      ],
      "parameters": {
        "width": 526,
        "height": 736,
        "content": "## 2. Idea Generation\nAI suggests 10 initial candidates based on the caption."
      }
    },
    {
      "id": "3e338bed-c67f-47d9-b08e-0574a5e36c02",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2656,
        2368
      ],
      "parameters": {
        "width": 654,
        "height": 732,
        "content": "## 3. Caching Logic\nChecks Google Sheets to avoid repeated API calls."
      }
    },
    {
      "id": "ce9c3af1-2d4e-4b49-acc3-c1f396a01d49",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3376,
        1984
      ],
      "parameters": {
        "width": 1920,
        "height": 430,
        "content": "## 4. Instagram Data & Caching\nFetches fresh data for new tags and saves to Sheet."
      }
    },
    {
      "id": "715b97b5-a3f9-4ef1-abb1-502418716ed8",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3376,
        2464
      ],
      "parameters": {
        "width": 1304,
        "height": 610,
        "content": "## 5. Final Selection\nAggregates data and AI selects the best 5 tags."
      }
    }
  ],
  "connections": {
    "Merge Input": {
      "main": [
        [
          {
            "node": "Check Cache Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Cache": {
      "main": [
        [
          {
            "node": "Rate Limit Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Trigger": {
      "main": [
        [
          {
            "node": "Set Dummy Caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rate Limit Wait": {
      "main": [
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Hashtag Info": {
      "main": [
        [
          {
            "node": "Check if Tag Exists",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Rate Limit Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split In Batches": {
      "main": [
        [
          {
            "node": "Merge Cache & Fresh",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get Hashtag Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Trigger": {
      "main": [
        [
          {
            "node": "Generate Initial Hashtags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Model Selector": {
      "ai_languageModel": [
        [
          {
            "node": "Select Top 5 Hashtags",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Initial Hashtags",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Set Dummy Caption": {
      "main": [
        [
          {
            "node": "Generate Initial Hashtags",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch Cached Hashtags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Cache Status": {
      "main": [
        [
          {
            "node": "Route Cached vs New",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse & Clean Tags": {
      "main": [
        [
          {
            "node": "Merge Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Tag Exists": {
      "main": [
        [
          {
            "node": "Get Hashtag Metrics",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Rate Limit Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Hashtag Metrics": {
      "main": [
        [
          {
            "node": "Calculate Average Metrics",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Cache & Fresh": {
      "main": [
        [
          {
            "node": "Aggregate & Rank Candidates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route Cached vs New": {
      "main": [
        [
          {
            "node": "Merge Cache & Fresh",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Split In Batches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Cached Hashtags": {
      "main": [
        [
          {
            "node": "Merge Input",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Select Top 5 Hashtags": {
      "main": [
        [
          {
            "node": "Format Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format New Hashtag Data": {
      "main": [
        [
          {
            "node": "Save to Cache",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calculate Average Metrics": {
      "main": [
        [
          {
            "node": "Format New Hashtag Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Initial Hashtags": {
      "main": [
        [
          {
            "node": "Parse & Clean Tags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate & Rank Candidates": {
      "main": [
        [
          {
            "node": "Select Top 5 Hashtags",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}