See llms.txt for all machine-readable content.

Back to Templates

Turn TikTok trends into Instagram and Facebook posts with Apify, Gemini, and PostWire

Quick Overview

This workflow runs daily, scrapes top TikTok videos for chosen hashtags via Apify, uses Google Gemini to identify a repeatable trend and generate captions plus an image prompt, creates an image with Gemini, publishes to Instagram and Facebook using PostWire, and logs results to Google Sheets with Gmail alerts on failures.

How it works

  1. Runs every morning at 7:00 on a schedule.
  2. Calls the Apify TikTok Scraper API to collect recent top videos for the configured hashtags, and emails you via Gmail if the scrape fails.
  3. Filters out videos that are too old or under the minimum view count, removes videos already used in previous executions, sorts by views, and keeps the top 15.
  4. Sends the shortlisted videos to Google Gemini to identify a single repeatable trend for the brand, generate Instagram and Facebook captions, and produce an image prompt.
  5. If a trend is found, uses Google Gemini (image generation) to create an image and publishes it to Instagram and Facebook through PostWire.
  6. Aggregates the publish results and appends a “posted” row to Google Sheets with the trend, rationale, sources, and post links.
  7. If no trend is found or posting/image generation fails, logs the issue to Google Sheets and emails you the problem details and any partial links via Gmail.

Setup

  1. Add an Apify API token as an HTTP Bearer Auth credential for the Apify request.
  2. Add Google Gemini credentials for both the text (trend/captions) and image-generation steps.
  3. Install the PostWire community node, create a PostWire account, connect your Instagram and Facebook profiles, and add your PostWire API key credential.
  4. Connect a Google Sheets account, select the target spreadsheet and sheet in both Google Sheets steps, and ensure it has columns: date, trend, why, sources, status, links, and note.
  5. Connect a Gmail account for the notification emails and update the recipient email plus trend settings (hashtags, thresholds, voice, and image style).