Category: Automations › Social Media & Content · Best for: Instagram-first brands · Platform: n8n · Steps: 27
What it does
The AI finds what's trending and makes Instagram posts with pictures.
We are checking until find a data we did not insert because we don't want to create content about in same content
Works with: Postgres, Telegram, OpenAI, Facebook
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- Telegram bot token from @BotFather: how to connect (used by Telegram, Telegram1, Telegram2, send error message to telegram)
- PostgreSQL database: how to connect (used by Check Data on Database Is Exist, insert data on db)
- OpenAI API key: how to connect (used by Analyze Image and give the content, Analyze Content And Generate Instagram Caption)
- Meta / Facebook Graph API: how to connect (used by Prepare data on Instagram, Check Status Of Media Before Uploaded, Publish Media on Instagram, **Check status of post **)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Telegram →
chatId: choose your own - Telegram1 →
chatId: choose your own - Telegram2 →
chatId: choose your own - Check Data on Database Is Exist →
table: choose your own - send error message to telegram →
chatId: choose your own - insert data on db →
table: choose your own
- Telegram →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). Schedule Trigger1 starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- Schedule Trigger1 starts the workflow (Schedule).
- Replicate params reshapes the data for the next step.
- Instagram params reshapes the data for the next step.
- Telegram Params reshapes the data for the next step.
- Rapid Api params reshapes the data for the next step.
- get top trends on instagram #isometric calls an external API (https://instagram-scraper-api2.p.rapidapi.com/v1/hashtag).
- get top trends on instagram #blender3d calls an external API (https://instagram-scraper-api2.p.rapidapi.com/v1/hashtag).
- filter the image content reshapes the data for the next step.
- filter the image content-2 reshapes the data for the next step.
- merge the array content uses Merge.
- Loop Over Items uses Split In Batches.
- Check Data on Database Is Exist uses Postgres to select.
- If Data is Exist checks a condition and routes items accordingly.
- send error message to telegram uses Telegram.
- insert data on db uses Postgres.
- Analyze Image and give the content uses AI (OpenAI).
- Analyze Content And Generate Instagram Caption uses AI (OpenAI).
- Generate image on flux calls an external API (https://api.replicate.com/v1/models/black-forest-labs/flux-s).
- Prepare data on Instagram uses Facebook.
- Check Status Of Media Before Uploaded uses Facebook.
- If media status is finished checks a condition and routes items accordingly.
- Publish Media on Instagram uses Facebook.
- Telegram uses Telegram.
- **Check status of post ** uses Facebook.
- If media status is finished1 checks a condition and routes items accordingly.
- Telegram1 uses Telegram.
- Telegram2 uses Telegram.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
All Credentials You Need
** Instagram Business Account Id ** Telegram Chat Id ** Rapid Api Key ** Replicate Token
Schedule Your Time To Post
Guide
** Guide of getting of Instagram Business Account Id
Guide
** Guide of Getting of Telegram Chat Id
Guide
** Guide of Getting of Rapid Api Key
Warning
**Don't forgot the create bot and send a message to bot first
Getting Top Trend Posts On Instagram
** Change the topic you want to get on http request
Looping Data And Checking For Is Exist On Database
**We are checking until find a data we did not insert because we don't want to create content about in same content
Analyze Post Content
** We are analyzing the image ** We are generating a instagram caption by content ** Then we are generating the image
Publish On Instagram And Send Message When Published via Telegram
For More About Api
Guide
** Guide of getting of Replicate Token
For top_trends Table
CREATE TABLE top_trends (
id SERIAL PRIMARY KEY,
isposted BOOLEAN DEFAULT false,
createdat TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updatedat TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deletedat TIMESTAMP WITHOUT TIME ZONE,
prompt TEXT NOT NULL,
thumbnail_url TEXT,
code TEXT,
tag TEXT
);
Warning
** Don't forgot the create top_trends table
Automated Instagram Content Creation from Trending Posts
This workflow automates the process of discovering and recreating trending content on Instagram:
- Content Discovery:
- Scrapes top trending posts from specific hashtags (#blender3d, #isometric)
- Filters for image-only content (excludes videos)
- Checks database to avoid duplicate content
- AI-Powered Content Generation:
- Analyzes trending images using GPT-4 Vision
- Generates detailed descriptions of visual elements
- Creates engaging Instagram captions with relevant hashtags
- Uses Flux AI to generate similar but unique images
- Publishing & Monitoring:
- Automatically posts content to Instagram Business Account
- Monitors post status and publishing process
- Sends status updates via Telegram
Perfect for content creators and businesses looking to maintain an active Instagram presence with AI-generated content inspired by current trends. The workflow runs on schedule and handles everything from content discovery to publication automatically.
Note: Requires Instagram Business Account, Telegram Bot, OpenAI, and Replicate API credentials.
##Warning
Warning
** You can check the rate limit of the Instagram Scraper Api on Rapid Api ** Free version is monthly 500 request
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method