Automate Instagram Content Creation with n8n & AI

Discover how this n8n workflow automates Instagram content creation by scraping top trends, generating AI-enhanced images and captions, and posting seamlessly. Save hours weekly while maintaining fresh, unique posts inspired by trending hashtags.
if
telegram
splitInBatches
+9
Learn how to Build this Workflow with AI:
Workflow Identifier: 1262
NODES in Use: If, Telegram, SplitInBatches, ScheduleTrigger, Set, HttpRequest, Code, Merge, Postgres, FacebookGraphApi, OpenAI, StickyNote

Press CTRL+F5 if the workflow didn't load.

Visit through Desktop for Best experience

Opening Problem Statement

Meet Sarah, a freelance digital artist hoping to grow her Instagram audience by posting art that resonates with her followers. She finds herself spending 8+ hours a week just searching for trendy content ideas, drafting captions, and creating eye-catching images from scratch. Despite her efforts, duplications and uninspired captions often lead to reduced engagement. Sarah dreams of a system that can automate this tedious process, keeping her account active with fresh content aligned to trending topics without her constant intervention.

This is precisely the problem tackled by our n8n workflow: automating Instagram content generation by tapping into top Instagram trends, leveraging AI for image analysis and regeneration, caption creation, and streamlined posting. This drastically reduces the time commitment, eliminates repetitive manual checks, and ensures Sarah’s posts remain relevant and engaging.

What This Automation Does ⚙️

When you activate this workflow, here’s what happens automatically:

  • Scheduled Trend Scraping: At specific times daily (1:05 PM and 7:05 PM Istanbul time), the workflow scrapes Instagram for top posts under hashtags like #blender3d and #isometric.
  • Content Filtering and Deduplication: Filters out videos, keeping only image-based posts, then checks a PostgreSQL database to ensure content isn’t duplicated.
  • AI Image Analysis: Uses OpenAI’s GPT-4 Vision to analyze images and extract clear, descriptive content details focusing on the object features.
  • Caption Generation: Automatically generates engaging Instagram captions tailored for 3D modeling and digital art communities with relevant hashtags.
  • AI-Driven Image Generation: Sends the descriptive prompt to Flux AI (via Replicate API) to generate a unique yet visually similar image styled as a 3D isometric miniature toy model.
  • Automated Instagram Posting: Uploads the AI-generated image and caption to your Instagram Business account and monitors the publishing status.
  • Status Notifications: Sends real-time status updates and error alerts through Telegram bot messages.

Impact: Saves Sarah 8+ hours of manual content preparation weekly and ensures fresh, exclusive posts inspired by trending topics without repeated content.

Prerequisites ⚙️

  • n8n account for workflow automation setup ⏱️
  • Instagram Business Account linked via Facebook Graph API 🔐
  • Telegram Bot API credentials for status notifications 💬
  • OpenAI API key for GPT-4 Vision image analysis and caption generation 🔐
  • Replicate API token access for Flux AI image generation 🔑
  • RapidAPI key with subscription to Instagram Scraper API for top trend data 📊
  • PostgreSQL database for storing and de-duplicating Instagram post metadata 📁
  • Optional: Self-hosting option for n8n (recommend Hostinger)

Step-by-Step Guide

1. Set Up Scheduled Trigger

Navigate in n8n to Triggers → Schedule Trigger. Configure the cron expression for 5 13,19 * * * to run the workflow daily at 1:05 PM and 7:05 PM Istanbul time. This schedules automatic scraping of trending posts.

Outcome: Workflow initiates as per schedule.

Tip: Confirm your n8n instance timezone matches ‘Europe/Istanbul’ in workflow settings.

2. Configure API Credentials

Fill in your Instagram Business Account ID, Telegram chat ID (from bot setup and chat with it), RapidAPI key for Instagram Scraper, OpenAI key, and Replicate token in their respective Set nodes:

  • Instagram params node → instagram_business_account_id
  • Telegram Params node → telegram_chat_id
  • Rapid Api params node → x-rapid-api-key
  • Replicate params node → replicate_token

Expected: All credentials correctly stored in workflow context.

3. Fetch Top Trends by Hashtag

Two HTTP Request nodes get top trends on instagram #blender3d and get top trends on instagram #isometric call the Instagram Scraper API via RapidAPI with GET requests, querying top posts under these hashtags.

Note: API headers include ‘x-rapidapi-host’ and your assigned ‘x-rapidapi-key’.

Outcome: Receive JSON data with trending Instagram posts.

4. Filter Out Videos and Merge Arrays

Two Code nodes filter the image content and filter the image content-2 use JavaScript to remove video posts and map the image posts to a simplified object containing id, caption, code, thumbnail URL, and tag.

Then a Merge node combines these filtered arrays into one cohesive list.

5. Loop Over Items and Check Database for Duplicates

The SplitInBatches node Loop Over Items processes each image post in batches.

Each image’s unique ‘content_code’ is checked in the Postgres node Check Data on Database Is Exist against the ‘top_trends’ table to avoid reposting existing content.

6. Insert New Posts to Database

If the image post doesn’t exist in the database (checked by If Data is Exist node), the workflow insert data on db adds the new record with prompt, thumbnail URL, code, and hashtag tag, marking it as not posted.

7. Analyze Image Content Using OpenAI GPT-4 Vision

The Analyze Image and give the content node sends the thumbnail URL to OpenAI’s image analysis model to generate a concise description of the object in the image, focusing on physical features without environmental distractions.

8. Generate Instagram Caption with AI

The Analyze Content And Generate Instagram Caption node uses OpenAI again, this time generating an engaging caption for Instagram under 150 words. It includes relevant hashtags like #Blender3D, #3DArt, and #DigitalArt.

9. Create AI-Generated Image via Replicate API (Flux AI)

The descriptive prompt is passed to the Generate image on flux HTTP Request node, calling Replicate’s Flux AI to generate a new, unique 3D isometric style image.

The POST request includes headers (Authorization: Bearer with Replicate token) and a JSON body specifying the prompt and rendering details like matte textures, lighting, and resolution.

10. Prepare & Upload Content to Instagram

The Prepare data on Instagram Facebook Graph API node uploads the generated image URL and generated caption to your Instagram Business Account as unpublished media.

11. Monitor Upload Status and Publish

Two Facebook Graph API nodes Check Status Of Media Before Uploaded and Check status of post monitor the uploaded media status codes.

If the status updates to FINISHED, the image is published using Publish Media on Instagram.

12. Telegram Notifications About Status

Multiple Telegram nodes send status messages:

  • Errors during upload or database operations.
  • Successful publishing confirmation.
  • Warnings if expected statuses fail.

Customizations ✏️

  • Change Hashtags to Scrape: In get top trends on instagram #blender3d and get top trends on instagram #isometric nodes, edit the “hashtag” query parameter to any preferred niche hashtag to fit your content focus.
  • Modify Image Generation Style: Adjust the JSON body in the Generate image on flux node to change stylistic parameters such as textures, lighting, or resolution for different art styles.
  • Customize Captions: Edit the prompt in the Analyze Content And Generate Instagram Caption node to add different hashtags or change tone to match your brand voice.
  • Adjust Schedule Times: Modify the cron expression in the Schedule Trigger1 node to post content at different times for your audience.
  • Database Table Structure: Customize the top_trends PostgreSQL table schema (shown in Sticky Note12) to add fields like post engagement or source URL if you wish to track more metrics.

Troubleshooting 🔧

  • Problem: “Instagram Scraper API returns no data or errors.”
    • Cause: API key expired, or monthly request quota exceeded.
    • Solution: Renew subscription or check quota limits on RapidAPI dashboard.
  • Problem: “OpenAI nodes fail to analyze images or generate captions.”
    • Cause: Incorrect API key or exceeded usage limits.
    • Solution: Verify OpenAI credentials and account status, check model availability.
  • Problem: “Instagram publishing hangs or fails with ‘status_code’ not changing to FINISHED.”
    • Cause: Issues with Facebook Graph API permissions or network delays.
    • Solution: Verify Facebook Graph API credentials, ensure Instagram Business account permissions are set correctly, retry upload.
  • Problem: “Telegram bot messages not sending.”
    • Cause: Bot not started by sending /start message or wrong Chat ID.
    • Solution: Start bot by messaging it first, verify chat ID with Telegram API.

Pre-Production Checklist ✅

  • Verify Instagram Business Account ID and Facebook Graph API credentials are active and valid.
  • Confirm Telegram Bot is set up, sent a message to, and chat ID is correct.
  • Ensure RapidAPI Instagram Scraper subscription is not expired and keys are accurate.
  • Test OpenAI and Replicate API keys with small manual requests.
  • Validate that PostgreSQL database table ‘top_trends’ exists and schema is correct per Sticky Note12.
  • Run workflow manually to check for errors before scheduling.

Deployment Guide

Activate your workflow by toggling it to “active” in the n8n editor. Monitor its initial runs via the execution log to catch any failed nodes.

Set up alerting by linking Telegram nodes for notifications about failures or successful posts, ensuring you stay updated without manual checks.

Consider recurring review of your RapidAPI usage and Instagram account limitations to avoid disruption.

FAQs

  • Can I use another image generation service instead of Flux AI?
    Yes, replace the Generate image on flux HTTP Request node with your preferred AI image generation API, adjusting the request body accordingly.
  • Does this consume a lot of API calls?
    It depends on your schedule and number of posts scraped. Monitor your RapidAPI and OpenAI usage carefully to avoid hitting quota limits.
  • Is my Instagram content secure?
    Your credentials are stored securely in n8n’s credential manager, but always protect your API keys and limit exposure.
  • Can this workflow handle many hashtags or high volume?
    With slight node expansions (e.g., more SplitInBatches or Merge nodes), yes, but monitor API rate limits closely.

Conclusion

By deploying this detailed n8n workflow, you have automated the challenging task of sourcing trending Instagram content, analyzing images, crafting AI-powered captions, and generating fresh images in a unique style—all posted automatically to your Instagram Business account.

This not only saves you more than 8 hours weekly but also ensures your feed stays unique, relevant, and engaging with minimal manual effort.

Next, consider expanding to multi-platform posting, integrating user comments analysis, or adding sentiment-based content filters to boost engagement further.

With this powerful automation, Sarah and creators like her can focus more on their art and less on content logistics.

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free