Create Instagram carousel posts using GPT-4.1 Nano and Gemini 2.5 Flash
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.
π§ How It Works
Feed it a topic. It does the rest.
π Workflow Breakdown
-
βΆοΈ Manual Trigger β 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.
-
π Get Row(s) β 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 concept number_of_images β how many carousel slides to generate
-
π§© OpenAI Chat Model β GPT-4.1 Nano Acts 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.
-
βοΈ Generate-Prompt β LangChain AI Agent An 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 slide
It outputs N distinct prompts based on the number_of_images field.
-
π Parse_Array β Code Node Parses 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.
-
π Loop For Each Prompt β Split In Batches Iterates 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.
-
π¨ Generate an Image β Google Gemini 2.5 Flash Image Uses 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 a File β Upload To URL Takes 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
-
β±οΈ Rate Control β Code Node Two critical jobs in one node: Accumulates the uploaded image URL into global workflow static data so URLs persist across loop iterations. Waits 15 seconds between iterations to respect Instagram and image generation API rate limits, preventing failures during bulk runs.
-
π¦ Collect Image URLs β Code Node After 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 URLs caption β pulled from the first generated item
This is the final assembly step before publishing.
-
πΈ Publish on Instagram β Instagram Node Publishes 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.
-
β Update Row(s) β 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.
π οΈ Tech Stack n8n** β Workflow automation OpenAI GPT-4.1 Nano** β Prompt generation Google Gemini 2.5 Flash Image** β AI image generation UploadToURL** β Image hosting Instagram Graph API** β Carousel publishing n8n Data Table** β Content queue & status tracking
βοΈ Setup Requirements OpenAI API key Google Gemini (PaLM) API key UploadToURL account Instagram Business Account connected via Facebook Graph API n8n Data Table with columns: prompt, number_of_images, status
Related Templates
Use OpenRouter in n8n versions <1.78
What it is: In version 1.78, n8n introduced a dedicated node to use the OpenRouter service, which lets you to use a lot...
AI SEO Readability Audit: Check Website Friendliness for LLMs
Who is this for? This workflow is designed for SEO specialists, content creators, marketers, and website developers who ...
Text automations using Apple Shortcuts
Overview This workflow answers user requests sent via Mac Shortcuts Several Shortcuts call the same webhook, with a quer...
π Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments