Tired of manually creating Instagram carousel content? This workflow takes a single content idea from a database, uses GPT-4.1 Nano + Gemini 2.5 Flash to generate unique images and captions, uploads them, and publishes a fully formatted Instagram carousel — all without touching your phone.
Feed it a topic. It does the rest.
When clicking 'Execute workflow'Kicks off the workflow on demand. Swap this with a Schedule Trigger or Webhook to make it fully hands-free and time-based.
Data Table (Get)Fetches the next unprocessed content idea from an n8n Data Table. It filters rows where the status column is empty, ensuring only fresh, unpublished ideas are picked up. Each row contains:
prompt — the core content conceptnumber_of_images — how many carousel slides to generateGPT-4.1 NanoActs as the language model backbone for the prompt engineering agent. Connected to the Generate-Prompt agent as its AI brain, it powers all text reasoning and JSON output generation.
LangChain AI AgentAn expert prompt engineering agent powered by GPT-4.1 Nano. It takes the core idea and produces a structured JSON array containing:
image_prompt — a richly detailed, unique visual prompt per slide (varied angles, styles, lighting)caption — a short Instagram caption per slideIt outputs N distinct prompts based on the number_of_images field.
Code NodeParses the agent's raw JSON string output into proper n8n items, one per image prompt. This allows the loop below to process each prompt individually. Without this step, the array would remain a single unprocessed string.
Split In BatchesIterates over each image prompt one at a time. On the final iteration, it routes to the Collect Image URLs node to assemble everything. On every other pass, it routes to Generate an image to keep generating.
Google Gemini 2.5 Flash ImageUses Gemini 2.5 Flash Image (Nano Banana) to generate a high-quality image for each prompt. The detailed prompt from the agent is passed directly here, ensuring each carousel slide is visually distinct from the others.
Upload To URLTakes the generated binary image and uploads it to a publicly accessible URL via the
uploadtourl service. Instagram requires all carousel images to be hosted at public URLs
before publishing — this node handles that requirement.
🔑 Get your free API key here: uploadtourl.com
Code NodeTwo critical jobs in one node:
Code NodeAfter the loop completes, this node retrieves all accumulated image URLs from global static data, resets the store for the next run, and bundles everything into a single object:
image_urls — array of all carousel image URLscaption — pulled from the first generated itemThis is the final assembly step before publishing.
Instagram NodePublishes the full carousel post to Instagram using the Facebook Graph API. It sends all image URLs in one request along with the AI-generated caption. Targets a specific Instagram Business Account by node ID.
Data Table (Update)After successful publishing, marks the row in the Data Table as Published, writing in the returned post ID. This prevents the same idea from being posted twice and keeps your content queue clean and trackable.
prompt, number_of_images, status