📱 Publish brand-compliant Instagram posts with OpenAI, Google Sheets and S3

⚡ 90 views · 📱 Social Media & Email Marketing

💡 Pro Tip — Heads up — if this workflow’s Instagram scraping breaks (it happens whenever Meta updates their frontend), ScraperNode is a community node that handles profiles, posts, reels, and comments without any HTML parsing.

View All Scrapers

Description

Quick overview

This workflow runs daily to read a Google Sheets content calendar, use OpenAI to generate brand-compliant Instagram captions and images from a master brand context file, watermark each image with your logo, publish posts via the Facebook Graph API, and write publishing results back to Google Sheets.

How it works

  1. Runs on a daily schedule and loads configuration values like your logo URL, Google Sheet URL, brand context URL, S3 bucket name, and Instagram Business ID.
  2. Downloads the brand context file and your logo image, then resizes the logo for watermarking.
  3. Reads Google Sheets to find today’s posts with Status set to Pending, and stops if no posts are found.
  4. Sorts the pending posts by their scheduled time, then processes them one at a time and waits until each post’s exact scheduled Date/Time.
  5. Uses OpenAI (gpt-4o-mini) to generate an Instagram caption plus layout metadata in a strict JSON format, then parses and sanitizes the JSON for downstream use.
  6. Uses OpenAI (gpt-image-2) to generate a 1024×1024 image based on the brand context and the selected layout, then downloads the generated image and composites the resized logo at the calculated position.
  7. Uploads the final image to Amazon S3 to obtain a public URL, creates and publishes an Instagram media container via the Facebook Graph API, and updates Google Sheets with Published/Failed status, caption, image URL, timestamp, and any error message.

Setup

  1. Add credentials for Google Sheets OAuth2, OpenAI API, AWS (IAM) for S3, and Facebook Graph API (Meta) with permissions to publish to your Instagram Business account.
  2. Update the Set Config values with a public logoUrl, your googleSheetUrl, a direct raw-text/markdown masterContextUrl, your awsS3BucketName, and your instagramBusinessId.
  3. Create or update your Google Sheet with the required headers (at minimum: Date, Time, Topic, Context, Status, Publish Time, Post Image, Post Caption, Error Message) and share it with the Google account used by the Google Sheets credential.
  4. Ensure your S3 bucket allows public-read objects (or adjust the upload ACL strategy) so Instagram can fetch the image_url from the S3 URL.
  5. Keep the Date and Time values in the sheet consistent with the workflow’s expectations (Date as YYYY-MM-DD and Time as HH:MM) so the wait step resumes correctly.

Requirements

Customization

🔗 Nodes Used

Edit Image, Google Sheets, HTTP Request, AWS S3, Facebook Graph API, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup