n8n

How to Automate Instagram AI Trend Posting?

Post fresh Instagram content on a set schedule without manual work. The system watches trending hashtags, turns ideas into an AI image and caption, and publishes from your business account. Teams that need steady social output and quick alerts will find it useful.

Two daily runs start on a schedule. The flow gets top posts for chosen hashtags from RapidAPI, filters to image posts, and merges two feeds. A Postgres check prevents duplicates before anything moves forward. OpenAI writes the caption and Replicate renders the image. The Facebook Graph API creates and publishes the media after status checks, while Telegram sends success or failure alerts.

Setup needs an Instagram Business account with Facebook Graph access, a PostgreSQL database, a RapidAPI key, a Replicate token, an OpenAI key, and a Telegram chat id. Expect daily content with less busy work, no repeat posts, and clear status updates. Good for social teams, creators, and small agencies that want reliable posting from real trends.

What are the key features?

  • Scheduled runs at 13 05 and 19 05 using a cron trigger
  • Fetch top posts for two hashtags through RapidAPI
  • Filter to image posts only using a code step to skip videos
  • Merge feeds and loop items while checking PostgreSQL for duplicates
  • Generate Instagram captions with OpenAI based on the source content
  • Create a matching image with Replicate Flux
  • Prepare media and publish through the Facebook Graph API
  • Verify media status before and after publish with If checks
  • Send success and error messages to Telegram

What are the benefits?

  • Reduce manual sourcing and posting from 2 hours to 10 minutes per day
  • Automate about 90 percent of repetitive social tasks
  • Eliminate 100 percent duplicate posts with a database check
  • Connect Telegram, Facebook Graph API, RapidAPI, OpenAI, Replicate and PostgreSQL in one flow
  • Scale to two posts per day without adding staff
  • Get instant success or error alerts in Telegram

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Telegram, Facebook Graph API, RapidAPI, OpenAI, Replicate and PostgreSQL. See the Tools Required section above for links to create accounts with these services.
  3. In the n8n credentials manager, add a PostgreSQL credential. Enter host, port, database, user and password, then test the connection. Create a table with a unique key for the source post id to prevent duplicates.
  4. Open the Facebook Graph API nodes and connect a Facebook Graph API credential. If unsure, double click the node, choose Create new credential, and follow the on screen steps. Make sure your Instagram account is a Business account linked to a Facebook Page.
  5. Open the Instagram params Set node and paste your Instagram Business Account ID.
  6. Create a RapidAPI account and copy your API key. Open the Rapid Api params Set node and paste the key into the x-rapid-api-key field.
  7. Edit both HTTP Request nodes to change the hashtag values to your niche if needed.
  8. In the n8n credentials manager, create an OpenAI credential with your API key and select it on the OpenAI nodes.
  9. Create a Replicate account and copy your API token. Open the Replicate params Set node and paste the token. Confirm the Generate image on flux node reads this token.
  10. Create a Telegram bot with BotFather and send a first message to the bot. In n8n, create a Telegram credential and select it on the Telegram nodes. Open the Telegram Params Set node and paste your chat id.
  11. Run the workflow once manually. Check the HTTP Request nodes return items and the code steps output image only posts.
  12. Verify the PostgreSQL nodes can read and write. Insert a test id and confirm the loop skips duplicates.
  13. Publish a test to Instagram. Watch the If status checks and confirm you receive a success message in Telegram. If you see an error alert, review Facebook Graph permissions and media status.
  14. Adjust the Schedule Trigger to your timezone and preferred times. Save and activate the workflow.
  15. If posts do not publish, check RapidAPI quota, confirm the chat id is correct, ensure the Instagram account is Business, and review node error messages in the execution log.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Facebook Graph API

Sign up

Free: $0 (no direct API charges; usage subject to rate limits)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

RapidAPI

Sign up

Free APIs: $0 (platform supports free plans; typical cap 1,000 requests/hour and 500,000 requests / mo; quotas vary by API)

Replicate

Sign up

Pay-as-you-go: $0 / mo; usage-based. Hardware from $0.000025/sec (CPU Small) and $0.000225/sec (Nvidia T4 GPU).

Telegram

Sign up

Free: $0, Telegram Bot API usage is free for developers

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.