AI · Automation 2025 Completed

Instagram Trend-to-Post — AI Content Generation Pipeline

A scheduled n8n pipeline that finds trending Instagram posts by hashtag, analyzes them with OpenAI vision, generates new images with Flux on Replicate and auto-publishes to Instagram.

Built by Redoan Uzzaman, Full-Stack Developer & AI Engineer.

Instagram Trend-to-Post — AI Content Generation Pipeline

Overview

Keeping an Instagram account active with fresh, on-trend content takes constant effort. This n8n workflow automates the whole loop, from spotting what is trending to publishing an original AI-generated post.

How it works

On a schedule (twice daily by default), the workflow pulls top posts for chosen hashtags — such as #blender3d and #isometric — from an Instagram scraper API on RapidAPI. A PostgreSQL table records which trending posts have already been used, so the same source is never recreated.

For each new trending post, an OpenAI vision model analyzes the image and produces a detailed visual description, and a second OpenAI step writes an engaging caption with relevant hashtags. The description is used as a prompt for the Flux image model on Replicate, which generates a new, inspired image.

Publishing goes through the Facebook Graph API: the workflow creates an Instagram media container, polls its status until processing is finished, and then publishes it to the Instagram Business account. A Telegram bot reports progress and errors at each stage, so the pipeline can run unattended while still being observable.

Key Features

  • Scheduled trend discovery across multiple hashtags
  • PostgreSQL deduplication of already-used trending posts
  • OpenAI vision analysis of trending images
  • AI-generated captions with hashtags
  • Flux image generation via Replicate
  • Instagram publishing through the Facebook Graph API with status polling
  • Telegram notifications for progress and errors

Tech Stack

  • n8n
  • OpenAI
  • Replicate
  • Flux
  • Facebook Graph API
  • PostgreSQL
  • Telegram Bot API
  • RapidAPI

Want something like this built?

Redoan Uzzaman takes on AI, automation and full-stack projects for clients worldwide.