{
  "name": "Generate Instagram content from top trends with AI image generation",
  "nodes": [
    {
      "id": "8c49be2b-6320-4eb0-8303-6448ced34636",
      "name": "If media status is finished",
      "type": "n8n-nodes-base.if",
      "position": [
        1420,
        260
      ]
    },
    {
      "id": "f0cc0be5-6d35-4334-a124-139fa8676d07",
      "name": "If media status is finished1",
      "type": "n8n-nodes-base.if",
      "position": [
        2000,
        260
      ]
    },
    {
      "id": "c8d8d8cd-8501-4d1b-ac28-8cb3fa74d9d7",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1580,
        440
      ]
    },
    {
      "id": "ae91a5e0-4f70-4a1c-afa5-41f5449facab",
      "name": "Telegram1",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2160,
        100
      ]
    },
    {
      "id": "b8b38440-14a7-43f6-ac49-6ca9502ff54d",
      "name": "Telegram2",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2160,
        440
      ]
    },
    {
      "id": "82e0e5d0-bf50-4b2e-8693-2612dffe53e2",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1000,
        220
      ]
    },
    {
      "id": "fb72beb1-1a6a-4148-9ee4-cdc564c4dc5c",
      "name": "Schedule Trigger1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -3080,
        300
      ]
    },
    {
      "id": "470f3406-19d2-420c-8f33-7031237d882c",
      "name": "Telegram Params",
      "type": "n8n-nodes-base.set",
      "position": [
        -2320,
        300
      ]
    },
    {
      "id": "12971505-7061-4d32-8921-d2e731eae9db",
      "name": "Instagram params",
      "type": "n8n-nodes-base.set",
      "position": [
        -2560,
        300
      ]
    },
    {
      "id": "3cb5f27d-eb3b-4fdc-bb55-1b54f85298e5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2860,
        20
      ],
      "parameters": {
        "width": 1000,
        "height": 600,
        "content": "## All Credentials You Need\n**  Instagram Business Account Id\n** Telegram Chat Id\n**  Rapid Api Key\n** Replicate Token"
      }
    },
    {
      "id": "2bc617b8-835c-48ba-8de6-341a6c87b853",
      "name": "Rapid Api params",
      "type": "n8n-nodes-base.set",
      "position": [
        -2080,
        300
      ]
    },
    {
      "id": "23bad41e-40ac-4488-8b2f-0d54d22a927a",
      "name": "filter the image content",
      "type": "n8n-nodes-base.code",
      "position": [
        -1480,
        380
      ]
    },
    {
      "id": "a65690cd-4d30-4541-b80d-aae872326a77",
      "name": "get  top trends on instagram #blender3d",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1720,
        180
      ]
    },
    {
      "id": "8707c475-7e28-4d80-92b8-ba24033c4632",
      "name": "get top trends on instagram #isometric",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1720,
        380
      ]
    },
    {
      "id": "1c1bfd8f-b086-4147-ba08-578877f2a315",
      "name": "merge the array content",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1280,
        280
      ]
    },
    {
      "id": "dcc2b6b6-9880-4676-8a1a-a3c21e583bba",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3180,
        20
      ],
      "parameters": {
        "width": 280,
        "height": 600,
        "content": "## Schedule Your Time To  Post\n"
      }
    },
    {
      "id": "c1e0ac33-c4b7-47d8-bd2b-0b74b02afe38",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2600,
        160
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "## Guide \n** [Guide](https://docs.matillion.com/metl/docs/6957316//) of getting  of Instagram Business Account Id "
      }
    },
    {
      "id": "321680da-ca7a-4c6f-98d4-a0d8f8d0347f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2360,
        160
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "## Guide \n** [Guide](https://rapidapi.com/i-yqerddkq0t/api/telegram92/tutorials/how-to-get-the-id-of-a-telegram-channel,-chat,-user-or-bot%3F) of Getting  of Telegram Chat Id "
      }
    },
    {
      "id": "b3d07cf7-8d03-4644-88f7-2e94de0c43c2",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        160
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "## Guide \n** [Guide](https://docs.rapidapi.com/docs/keys-and-key-rotation) of Getting  of Rapid Api Key "
      }
    },
    {
      "id": "b6dbdfaa-fc71-4def-a723-bf6c0facd372",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2360,
        480
      ],
      "parameters": {
        "width": 180,
        "height": 120,
        "content": "## Warning\n**Don't forgot the create bot and send a message to bot first"
      }
    },
    {
      "id": "81d598e2-8993-4315-9894-2e78dc26ad10",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1820,
        20
      ],
      "parameters": {
        "width": 660,
        "height": 600,
        "content": "## Getting Top Trend Posts On Instagram\n** Change the topic you want to get on http request"
      }
    },
    {
      "id": "6beb79ef-8205-4882-9bb0-6a2e1a33f1d4",
      "name": "Check Data on Database Is Exist",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -760,
        220
      ]
    },
    {
      "id": "5b0c05a8-3eb7-4ad8-88e8-ceef81fe7a61",
      "name": "If Data is Exist",
      "type": "n8n-nodes-base.if",
      "position": [
        -540,
        240
      ]
    },
    {
      "id": "557aa2c3-8d0b-42c4-b444-953a538d7ff4",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        20
      ],
      "parameters": {
        "width": 1060,
        "height": 600,
        "content": "## Looping Data And Checking For Is Exist On Database\n**We are checking until find a data we did not insert because we don't want to create content about in same content"
      }
    },
    {
      "id": "9b510f11-9a44-4d54-b162-3ffb55d66677",
      "name": "send error message to telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -1000,
        440
      ]
    },
    {
      "id": "48bc61de-d416-4673-9e9b-8331ea841891",
      "name": "insert data on db",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -260,
        240
      ]
    },
    {
      "id": "15e7d69d-a10f-48a1-b240-046e9950d077",
      "name": "Analyze Image and give the content",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        80,
        240
      ]
    },
    {
      "id": "93e253b1-da7d-4193-b899-a38e6fd9f4e4",
      "name": "Analyze Content And Generate Instagram Caption",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        280,
        240
      ]
    },
    {
      "id": "9af1dc59-1d9e-4900-8f80-1eba946c4057",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        20
      ],
      "parameters": {
        "width": 860,
        "height": 600,
        "content": "## Analyze Post Content\n** We are analyzing the image\n** We are generating a instagram caption by content\n** Then we are generating the image"
      }
    },
    {
      "id": "2259f6df-dca9-4a7e-babb-e63375f7207f",
      "name": "Prepare data on Instagram",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        980,
        260
      ]
    },
    {
      "id": "bcbb6058-1966-4bb5-915a-1e65b9131117",
      "name": "Check Status Of Media Before Uploaded",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1200,
        260
      ]
    },
    {
      "id": "518d87ff-7808-4c06-b137-4e97d8f2ca28",
      "name": "Publish Media on Instagram",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1600,
        100
      ]
    },
    {
      "id": "a033d12b-524f-40e8-9208-5300bbc823d3",
      "name": "Check status of post ",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1800,
        260
      ]
    },
    {
      "id": "f136e907-2938-4175-b51f-4201fbe3477d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        20
      ],
      "parameters": {
        "width": 1580,
        "height": 600,
        "content": "## Publish On Instagram And Send Message When Published via Telegram\n"
      }
    },
    {
      "id": "8145986c-5453-43ac-8d5c-c50a84a62136",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1800,
        100
      ],
      "parameters": {
        "width": 260,
        "height": 500,
        "content": "## For More About Api\n** [Facebook Scraper Api Guide](https://rapidapi.com/social-api1-instagram/api/instagram-scraper-api2/playground/apiendpoint_a45552b2-9850-4da9-b5cb-bbdd3ac2199d)"
      }
    },
    {
      "id": "02416fbb-4250-4278-af23-1f9189787123",
      "name": "filter the image content-2",
      "type": "n8n-nodes-base.code",
      "position": [
        -1480,
        180
      ]
    },
    {
      "id": "2d1ea53d-1d32-4b86-8944-ce2ad4a69847",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2820,
        160
      ],
      "parameters": {
        "width": 180,
        "height": 300,
        "content": "## Guide \n** [Guide](https://replicate.com) of getting  of Replicate Token "
      }
    },
    {
      "id": "c8b933af-356e-49ae-92d3-42eaf4ee3e9f",
      "name": "Replicate params",
      "type": "n8n-nodes-base.set",
      "position": [
        -2780,
        300
      ]
    },
    {
      "id": "2c73cc9c-d436-459b-9b3c-bd870810b9b4",
      "name": "Generate image on flux",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        680,
        260
      ]
    },
    {
      "id": "6f9e7dc6-1287-4235-8631-198d729f367f",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -340
      ],
      "parameters": {
        "width": 1060,
        "height": 320,
        "content": "## For top_trends Table\n```\nCREATE TABLE top_trends (\n    id SERIAL PRIMARY KEY,\n    isposted BOOLEAN DEFAULT false,\n    createdat TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,\n    updatedat "
      }
    },
    {
      "id": "b19951bb-6346-44a7-a4c8-1bd0806c6019",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -120
      ],
      "parameters": {
        "width": 160,
        "height": 120,
        "content": "## Warning\n** Don't forgot the create top_trends table"
      }
    },
    {
      "id": "3de6b8e5-c5e0-4999-871a-c349cb9b3ac0",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3180,
        -940
      ],
      "parameters": {
        "width": 620,
        "height": 840,
        "content": "\n## Automated Instagram Content Creation from Trending Posts\n\nThis workflow automates the process of discovering and recreating trending content on Instagram:\n\n1. Content Discovery:\n   - Scrapes top t"
      }
    },
    {
      "id": "dfd0d182-177c-4336-8950-4792ea739123",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        480
      ],
      "parameters": {
        "width": 180,
        "height": 120,
        "content": "##Warning\n** Dont forgot the subscribe [Instagram Scraper Api](https://rapidapi.com/social-api1-instagram/api/instagram-scraper-api2/playground/apiendpoint_a45552b2-9850-4da9-b5cb-bbdd3ac2199d)"
      }
    },
    {
      "id": "03330941-3c6e-4152-8c51-f1d53f4424bc",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2120,
        640
      ],
      "parameters": {
        "width": 180,
        "height": 180,
        "content": "## Warning\n** You can check the  [rate limit](https://rapidapi.com/social-api1-instagram/api/instagram-scraper-api2) of the Instagram Scraper Api on Rapid Api\n** Free version is monthly 500 request\n"
      }
    }
  ],
  "connections": {
    "Telegram": {
      "main": [
        []
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Check Data on Database Is Exist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Params": {
      "main": [
        [
          {
            "node": "Rapid Api params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Data is Exist": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "insert data on db",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram params": {
      "main": [
        [
          {
            "node": "Telegram Params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rapid Api params": {
      "main": [
        [
          {
            "node": "get top trends on instagram #isometric",
            "type": "main",
            "index": 0
          },
          {
            "node": "get  top trends on instagram #blender3d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replicate params": {
      "main": [
        [
          {
            "node": "Instagram params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "Replicate params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "insert data on db": {
      "main": [
        [
          {
            "node": "Analyze Image and give the content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check status of post ": {
      "main": [
        [
          {
            "node": "If media status is finished1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate image on flux": {
      "main": [
        [
          {
            "node": "Prepare data on Instagram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "merge the array content": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter the image content": {
      "main": [
        [
          {
            "node": "merge the array content",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Prepare data on Instagram": {
      "main": [
        [
          {
            "node": "Check Status Of Media Before Uploaded",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish Media on Instagram": {
      "main": [
        [
          {
            "node": "Check status of post ",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "filter the image content-2": {
      "main": [
        [
          {
            "node": "merge the array content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If media status is finished": {
      "main": [
        [
          {
            "node": "Publish Media on Instagram",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If media status is finished1": {
      "main": [
        [
          {
            "node": "Telegram1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Data on Database Is Exist": {
      "main": [
        [
          {
            "node": "If Data is Exist",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "send error message to telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Image and give the content": {
      "main": [
        [
          {
            "node": "Analyze Content And Generate Instagram Caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status Of Media Before Uploaded": {
      "main": [
        [
          {
            "node": "If media status is finished",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get top trends on instagram #isometric": {
      "main": [
        [
          {
            "node": "filter the image content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "get  top trends on instagram #blender3d": {
      "main": [
        [
          {
            "node": "filter the image content-2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Content And Generate Instagram Caption": {
      "main": [
        [
          {
            "node": "Generate image on flux",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}