Amazon Affiliate Marketing Automation with AI Image & Facebook Posting

Overview

This workflow automates Amazon affiliate marketing by generating AI-powered product images and Facebook captions, then posting directly to Facebook and tracking progress in Google Sheets. When a new product link is added to a Google Sheet, the workflow extracts the ASIN, fetches product details from Amazon via RapidAPI, uses OpenRouter (Gemini 2.0 Flash) to create a compelling Facebook caption and an image generation prompt, uploads the product photo to Google Gemini's generative AI service to produce a new enhanced image, and finally posts the image with caption to Facebook. It then updates the sheet to mark the row as "Done ✅". Perfect for affiliate marketers who want to scale their content creation and posting with zero manual effort.

Node-by-Node Breakdown

  1. Google Sheets Trigger (OAuth2) — Triggers the workflow whenever a new row is added to a specified Google Sheet. Configured to watch "Sheet1" in the document "Affiliate Automation". Expects columns: "Product Link" and "Facebook Upload".

  2. asin number (OpenRouter / API Key) — An AI agent (using Google Gemini 2.0 Flash via OpenRouter) that extracts the ASIN number from the Amazon product URL provided in the new sheet row. The prompt instructs: "You only have to give the asin number from this amazon product url".

  3. Amazon Product Details (Header Auth — RapidAPI Key) — Sends an HTTP GET request to the RapidAPI endpoint https://real-time-amazon-data.p.rapidapi.com/product-details?asin={{ $json.output }}&country=US. Uses two headers: x-rapidapi-host and x-rapidapi-key (configured with YOUR_API_KEY placeholder). Retrieves product title, description, image URL, etc.

  4. FB caption (OpenRouter / API Key) — An AI agent that generates a short, engaging Facebook caption using the product title and a product feature. The prompt includes instructions to add the affiliate link (with tag ?tag=rakin114-20). Outputs only the final caption.

  5. Image Prompt Generate (OpenRouter / API Key) — An AI agent that creates a concise prompt for AI image generation. It instructs to include a human model (if wearable/usable) and cinematic grain. Outputs the prompt inside double quotes.

  6. Product Image (No Auth) — Simple HTTP GET request to fetch the original product photo from Amazon (URL from step 3). No authentication needed.

  7. Image Upload To Server (API Key — Google Gemini) — Uploads the product photo binary to Google Gemini's file upload API (https://generativelanguage.googleapis.com/upload/v1beta/files?key=YOUR_API_KEY). Uses POST method with binaryData content and headers for upload commands (X-Goog-Upload-Command, X-Goog-Upload-Header-Content-Length, etc.). Returns a file URI.

  8. OpenRouter Chat Model (API Key) — A language model node (Google Gemini 2.0 Flash) that is connected to the Image Prompt Generate agent to provide the AI model.

  9. OpenRouter Chat Model1 (API Key) — Same model connected to the FB caption agent.

  10. OpenRouter Chat Model2 (API Key) — Same model connected to the asin number agent.

  11. ai image generator (API Key — Google Gemini) — Sends a POST request to Google Gemini's content generation API (https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent?key=YOUR_API_KEY). The JSON body includes the uploaded file URI and the generated prompt. Set to return both text and image (responseModalities: ["Text", "Image"]).

  12. Convert to File (Internal) — Converts the base64-encoded image from the Gemini response into a binary file that can be posted to Facebook.

  13. Wait (No Auth) — Pauses for 10 seconds before posting to Facebook (to ensure the image is ready).

  14. Facebook Graph API (OAuth2) — Posts the generated image to the authenticated Facebook user's profile (me/photos). Uses the caption from the FB caption node as a query parameter message. Sends binary data from the converted file.

  15. Google Sheets (OAuth2) — Updates the same Google Sheet row by matching the "Product Link" column and setting the "Facebook Upload" column to "Done ✅".

Setup Instructions

  1. Google Sheets: Create a Google Sheet with at least two columns: "Product Link" and "Facebook Upload". Connect your Google account in the Google Sheets Trigger and Google Sheets nodes (OAuth2).
  2. RapidAPI: Sign up at RapidAPI and subscribe to the "Real-Time Amazon Data" API. Copy your API key and replace YOUR_API_KEY in the Amazon Product Details node's header parameters.
  3. OpenRouter: Create an account at OpenRouter and get an API key. Create a credential in n8n named "OpenRouter" and select it in the three OpenRouter nodes.
  4. Google Gemini API: Get a free API key from Google AI Studio. Replace YOUR_API_KEY in the Image Upload To Server and ai image generator nodes (both use the same key).
  5. Facebook Graph API: Create a Facebook App and generate a Page Access Token or User Access Token with publish_photo permission. Connect it in the Facebook Graph API node (OAuth2).

Once all credentials are set, add an Amazon product URL (e.g., https://www.amazon.com/dp/B0XXXXXXX) to the "Product Link" column of the sheet. The workflow will trigger automatically and handle the rest.

Use Cases & Variations

  • Multi-platform posting: Add additional nodes (e.g., Twitter, Instagram, Pinterest) after the Wait node to cross-post the same image and caption.
  • Different affiliate tags: Modify the affiliate link suffix in the FB caption prompt to use your own tag.
  • Custom image styles: Edit the prompt in Image Prompt Generate to change the aesthetic (e.g., "flat lay", "minimalist", "lifestyle scene").
  • Scheduling: Instead of a Google Sheets trigger, use a Schedule Trigger to run daily and pull from a list of ASINs in a Google Sheet.
  • Content approval: Add a Manual Approval node (e.g., Telegram or email) before posting to Facebook.
19 nodesmanual triggerMarketing
HTTP RequestLm Chat Open RouterConvert To FileFacebook Graph APIGoogle SheetsWaitAgentSticky Note

Workflow JSON

{
  "id": "EPSFcDt1f8LdRzZU",
  "meta": {
    "instanceId": "061ca141d020a6e1355b8c7fe05f92a699e37e92079ad2e150a506ee8bbe9e11"
  },
  "name": "Amazon Affiliate Marketing Automation",
  "tags": [],
  "nodes": [
    {
      "id": "7c77fce7-01ef-4ab9-898c-f4378cfb12fb",
      "name": "Amazon Product Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1248,
        144
      ],
      "parameters": {
        "url": "=https://real-time-amazon-data.p.rapidapi.com/product-details?asin={{ $json.output }}&country=US",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "real-time-amazon-data.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "YOUR_API_KEY"
            },
            {
              "name": "country",
              "value": "US"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0a1dc175-1109-475c-908d-f13c4876e5c1",
      "name": "Product Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -576,
        496
      ],
      "parameters": {
        "url": "={{ $('Amazon Product Details').item.json.data.product_photo }}",
        "options": {}
// ... truncated (copy to see full JSON)

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

AI LinkedIn Content Creator with Perplexity Research & Auto-Posting

AI-Powered LinkedIn Content Automation Workflow Overview This workflow automates the entire LinkedIn content lifecycle — from research and ideation to image generation and scheduled posting. It uses Perplexity AI for topic research, an Anthropic Claude model as the content strategist, and OpenAI's image generation model to create branded visuals. The workflow runs on two separate schedules: one for content creation (daily) and one for publishing (twice weekly). It stores all posts in a Google Sheet for review before they go live, giving you full control over what gets published. This is ideal for founders, marketers, and content creators who want to maintain a consistent LinkedIn presence without spending hours writing, designing, and scheduling posts manually. The system learns from past content stored in Google Sheets and uses AI to generate fresh, on-brand posts that resonate with your target audience. Node-by-Node Breakdown Content Creation Pipeline (Runs Daily at 5 AM) Schedule () — No auth. Triggers the content creation workflow daily at 5:00 AM. This is the starting point for generating new post ideas. Get Past Ideas () — OAuth2. Reads all rows from the "LinkedIn Posts" sheet in the Google Sheet "AI Content Database". This provides the AI with context about previously generated posts to avoid repetition. Join Ideas () — No auth. A JavaScript code node that concatenates all past post ideas into a single text string, making it easy for the AI to reference them. LinkedIn Creator Agent () — No auth (uses connected models). This is the core AI agent that generates LinkedIn post content. It uses: - Anthropic Chat Model () — API Key auth. Uses Claude 3.7 Sonnet as the language model for content generation. - Perplexity Research () — API Key auth. A sub-workflow that uses Perplexity AI to research current topics and trends. - Structured Output Parser () — No auth. Ensures the AI output follows a structured JSON format with fields: , , and . Image Style () — OAuth2. Downloads a reference image from Google Drive that serves as the style guide for generating new images. OpenAI Image1 () — Header Auth (HTTP Header Auth). Sends a POST request to OpenAI's image generation API (gpt-image-1 model) with the reference image and a prompt describing the desired image for the LinkedIn post. Convert to File () — No auth. Converts the base64 image data from OpenAI's response into a binary file for saving to Google Drive. Save Image () — OAuth2. Uploads the generated image to a specific folder ("LinkedIn AI Posts") in Google Drive, naming it after the post title. Save Post () — OAuth2. Appends a new row to the "LinkedIn Posts" sheet with the post text, description, image URL, and status set to "review". Publishing Pipeline (Runs Every 3 Days at 2 PM) Schedule 2 () — No auth. Triggers the publishing workflow every 3 days at 2:00 PM. Get Ready Posts () — OAuth2. Filters the Google Sheet for rows where the status column equals "ready", retrieving posts that have been approved for publishing. Pick One () — No auth. Limits the output to a single post (first row) from the filtered results. Download Image () — OAuth2. Downloads the image associated with the selected post from Google Drive using the image URL stored in the sheet. Publish Post () — OAuth2. Publishes the post to LinkedIn with the text content and attached image, set to public visibility. Update Status () — OAuth2. Updates the status of the published post from "ready" to "posted" in the Google Sheet, matching by the "about" column. Setup Instructions Required Accounts & Services Google Account — For Google Sheets and Google Drive access. You'll need to create a Google Cloud Project and enable the Sheets and Drive APIs, then create OAuth2 credentials. Anthropic Account — Sign up at console.anthropic.com to get an API key for Claude 3.7 Sonnet. Perplexity AI Account — Sign up at perplexity.ai and obtain an API key for research capabilities. OpenAI Account — Sign up at platform.openai.com and get an API key for image generation. LinkedIn Account — You'll need a LinkedIn profile or company page to post to. Connect via n8n's LinkedIn OAuth integration. Configuration Steps Create a Google Sheet named "AI Content Database" with a sheet called "LinkedIn Posts" containing columns: , , , . Upload a reference image to Google Drive that represents your brand's visual style. Update the Google Sheet ID and folder IDs in the nodes to match your own. Configure all credential connections in n8n for each service. Adjust the cron schedules to match your desired posting frequency. Customize the AI system prompt in the LinkedIn Creator Agent to match your brand voice. Use Cases & Variations Primary Use Cases Personal Brand Building: Automate daily LinkedIn content for thought leaders and consultants. Agency Content Management: Manage multiple client content calendars from a single workflow. Content Repurposing: Adapt the workflow to generate content for Twitter, Instagram, or newsletters. Possible Variations Platform Swap: Replace the LinkedIn node with Twitter, Facebook, or Slack nodes. Research Source: Swap Perplexity for a Google Search API or RSS feed reader. Image Model: Use DALL-E 3 or Stable Diffusion instead of gpt-image-1. Review Workflow: Add a Slack notification node to alert you when posts are ready for review. Multi-Platform Publishing: Duplicate the publishing pipeline for different social networks. Content Calendar: Add a calendar node to schedule posts for specific dates and times.

23 nodes

Auto-Generate Platform-Specific Posts from YouTube Videos with Dumpling AI

Overview This workflow automatically generates platform-specific social media posts (Instagram, Facebook, LinkedIn) from YouTube videos. It reads a topic from a Google Sheet, searches YouTube via Dumpling AI, selects the best matching video using GPT-4o, fetches its transcript, and creates tailored posts with AI-generated images. The final output is saved back to Google Sheets, making it ideal for content creators and marketers who want to repurpose video content across social media platforms efficiently. Workflow Steps Trigger Search Schedule — Schedule Trigger (No auth) — Runs the workflow on a schedule. Configured to run at regular intervals (default: every hour) but you can customize the cron or interval in the node settings. Get Unsearched Topic from Google Sheet — Google Sheets (OAuth2) — Reads a topic from the "YouTube Topics" sheet. Uses a filter to find rows where the "Searched?" column is empty, returning the first match. Requires Google Sheets OAuth2 credentials. Search YouTube via Dumpling AI — HTTP Request (Header Auth) — Sends a POST request to Dumpling AI's YouTube search endpoint. The query is dynamically populated from the Google Sheets topic. Requires a Dumpling AI API key configured as HTTP Header Auth. Filter + Sort YouTube Videos — Code (No auth) — Custom JavaScript code that extracts video data from the search results, filters for video types, sorts by published time (newest first), and returns the 3 most recent videos. Prepare Video List for AI — Aggregate (No auth) — Combines all video items into a single array, preparing the data for the AI node to process. Select Best Video with GPT-4o — OpenAI (API Key auth) — Uses GPT-4.1 to analyze the search results and pick the most relevant video based on the original topic and current date. Returns a JSON structure with the selected video details. Requires an OpenAI API key. Get Transcript (Dumpling AI) — HTTP Request (Header Auth) — Fetches the YouTube video transcript via Dumpling AI's transcript endpoint. Requires the same Dumpling AI credentials as node 3. Generate Posts with GPT-4o — OpenAI (API Key auth) — Takes the transcript and generates three platform-specific posts (Instagram, Facebook, LinkedIn) with matching image prompts. Each post is tailored to the platform's tone and format. Uses the same OpenAI credentials as node 6. Generate Instagram Image (Dumpling AI) — HTTP Request (Header Auth) — Generates an AI image for the Instagram post using FLUX.1-pro model. Prompt comes from the GPT-4o output. Generate Facebook Image (Dumpling AI) — HTTP Request (Header Auth) — Same as node 9 but for Facebook post image. Generate LinkedIn Image (Dumpling AI) — HTTP Request (Header Auth) — Same as node 9 but for LinkedIn post image. Format Instagram Post — Set (No auth) — Combines the Instagram post text, platform name, and image URL into a structured format for saving. Format Facebook Post — Set (No auth) — Same as node 12 but for Facebook. Format LinkedIn Post — Set (No auth) — Same as node 12 but for LinkedIn. Save Instagram Post to Sheet — Google Sheets (OAuth2) — Appends the formatted Instagram post (platform, content, image URL) to the "Social Media Post" sheet. Save Facebook Post to Sheet — Google Sheets (OAuth2) — Same as node 15 but for Facebook. Save LinkedIn Post to Sheet — Google Sheets (OAuth2) — Same as node 15 but for LinkedIn. Merge Post Results — Merge (No auth) — Combines all three saved post results into a single output. Update Topic Status in Sheet — Google Sheets (OAuth2) — Updates the original topic row in "YouTube Topics" sheet, setting "Searched?" to "Yes" to prevent reprocessing. Setup Instructions Required Accounts & Credentials Google Account — For Google Sheets access. Create OAuth2 credentials in n8n for Google Sheets. OpenAI Account — For GPT-4.1 access. Create an API key from platform.openai.com. Dumpling AI Account — For YouTube search, transcript, and image generation. Sign up at dumplingai.com and get an API key. Google Sheets Setup Create a Google Sheet with two sheets: YouTube Topics (columns: , ) — Add your topics with "Searched?" column empty for unprocessed items. Social Media Post (columns: , , ) — Will store generated posts. Configuring Credentials In n8n, go to Credentials → Add Credential. Add Google Sheets OAuth2 credentials. Add OpenAI credentials with your API key. Add Header Auth credentials with your Dumpling AI API key. Node Configuration Update the in all Google Sheets nodes to your sheet's ID. Verify the values match your sheet tab names. Adjust the schedule trigger interval as needed. Use Cases & Variations Content Repurposing — Automatically turn YouTube videos into social media posts for multiple platforms. Batch Processing — Add multiple topics to the sheet; the workflow processes one per run. Custom Platforms — Modify GPT-4o prompts to add Twitter, TikTok, or other platforms. Brand Voice Customization — Update the system prompt to match your brand's tone. Manual Trigger — Replace the schedule trigger with a webhook for on-demand processing. Review Before Posting — Add a manual approval step before saving to sheets. This workflow saves hours of manual content creation and ensures consistent, platform-optimized posts.

20 nodes

Product Video Generator using AI

Overview This workflow automatically generates personalized, cinematic-quality product videos by combining competitor ad intelligence from Foreplay, creative prompt generation with Google Gemini AI, and text-to-video generation via Kie.ai (Sora 2). It's designed for marketers, brand managers, and content creators who want to produce high-quality video ads quickly without manual scripting or editing. The workflow fetches product images from Google Drive, analyzes competitor video ads from Foreplay, uses Gemini to craft optimized video prompts, generates videos through Kie.ai, and automatically saves the finished videos back to Google Drive. Workflow Steps Manual Trigger (No auth) — Starts the workflow manually for testing or on-demand video generation. Set Workflow Credentials (No auth) — Configures environment variables including Google Drive folder IDs, Foreplay API base URL, API key, and brand ID. These values are referenced throughout the workflow. Set Product Information (No auth) — Defines the product details: name (e.g., "Homyped"), niche (e.g., "fashion"), category (e.g., "shoes"), and target market (e.g., "b2c"). These parameters drive the entire video generation process. Fetch Product Image from Google Drive (OAuth2) — Retrieves the first image file from a specified Google Drive folder. Uses the folder ID set in step 2. Fetch Competitor Video Data (Foreplay API) (Bearer Token auth) — Calls the Foreplay API to get competitor ad data filtered by brand ID, date range (last month), niche, target market, language (English), video duration (5-30 seconds), and platform (Instagram). Returns the top 5 longest-running video ads. Split Foreplay Response (No auth) — Splits the Foreplay API response array into individual items for processing each competitor ad example. Assemble Video Input Data (No auth) — Combines competitor ad data (description, transcript, emotional drivers, duration) with the product image URL into a structured format for prompt generation. Iterate Over Ad Examples (No auth) — Processes each competitor ad example one at a time in batches, allowing the workflow to generate multiple video prompts and videos sequentially. Generate Video Prompt (No auth) — Uses Google Gemini AI (connected via the Google Gemini LLM node) to generate a personalized, cinematic-quality text prompt for video generation. The prompt incorporates product information, competitor ad details, emotional tone, and target duration. Google Gemini LLM (API Key auth) — The language model connection that powers the prompt generation. Requires a Google Gemini API key. Create Video Task (Kie.ai) (Bearer Token auth) — Sends the generated prompt and product image URL to Kie.ai's Sora 2 image-to-video model. Configures portrait aspect ratio, removes watermark, and includes a callback URL. Check Video Generation Status (Bearer Token auth) — Polls Kie.ai's API to check the status of the video generation task using the task ID returned from step 11. Video Generation Status (No auth) — A switch node that evaluates the video generation status: - Success — Proceeds to download the finished video - Failed — Returns to the iteration loop to try the next ad example - Processing — Waits and checks again Wait Before Checking Again (No auth) — Pauses execution for 1 minute before re-checking the video generation status. Download Finished Video (No auth) — Downloads the completed video file from the URL provided by Kie.ai's success response. Upload Generated Video to Google Drive (OAuth2) — Saves the downloaded video to a specified Google Drive folder, named with the current date and time. Setup Instructions Required Accounts & Services Google Account — For Google Drive access (store product images and save generated videos) - Create a Google Cloud Project and enable the Google Drive API - Set up OAuth 2.0 credentials in n8n Foreplay Account — For competitor ad intelligence - Sign up at Foreplay - Get your API key and brand ID from your Foreplay dashboard Google Gemini API Key — For AI prompt generation - Get an API key from Google AI Studio Kie.ai Account — For video generation (Sora 2 model) - Sign up at Kie.ai and obtain API credentials - Configure Bearer Token authentication in n8n Configuration Steps Add all API keys and credentials in the n8n credentials manager Update the Set Workflow Credentials node with your: - Google Drive folder IDs (for product images and generated videos) - Foreplay API key and brand ID - Kie.ai callback URL (optional) Update the Set Product Information node with your product details Ensure your product image folder in Google Drive is set to public access Run the workflow manually to test Use Cases & Variations Primary Use Cases E-commerce product videos — Generate video ads for new product launches Competitor analysis — Create videos inspired by successful competitor ad formats Social media content — Produce Instagram-ready video ads A/B testing — Generate multiple video variations from different competitor examples Adaptation Ideas Change video model — Replace Kie.ai with another video generation service (e.g., Runway, Pika) Add scheduling — Replace Manual Trigger with a Cron trigger for automated daily video generation Multi-product support — Modify the workflow to iterate over a list of products from a Google Sheet Add review step — Insert a human approval node before uploading to Google Drive Different platforms — Change the Foreplay API parameters to target TikTok, Facebook, or YouTube ads Custom branding — Modify the Gemini prompt to include specific brand guidelines or tone of voice

18 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.