{
  "name": "Amazon Affiliate Marketing Automation",
  "nodes": [
    {
      "parameters": {
        "url": "=https://real-time-amazon-data.p.rapidapi.com/product-details?asin={{ $json.output }}&country=US",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "real-time-amazon-data.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "ace80b82bdmshb578a2ed9980994p192523jsn6748a45cc7b5"
            },
            {
              "name": "country",
              "value": "US"
            }
          ]
        },
        "options": {}
      },
      "id": "7a0764a1-f43a-4100-8a65-a2b9abc70376",
      "name": "Amazon Product Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1520,
        672
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "url": "={{ $('Amazon Product Details').item.json.data.product_photo }}",
        "options": {}
      },
      "id": "d134d14b-f994-40e2-b603-83a52d86f34f",
      "name": "Product Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -848,
        1024
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://generativelanguage.googleapis.com/upload/v1beta/files?key=AIzaSyA-ggbBMub-ReSVXUgZsEUY8GsHrp9oevQ",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Goog-Upload-Command",
              "value": "start,upload,finalize"
            },
            {
              "name": "X-Goog-Upload-Header-Content-Length",
              "value": "123"
            },
            {
              "name": "X-Goog-Upload-Header-Content-Type",
              "value": "image/png"
            },
            {
              "name": "Content-Type",
              "value": "image/png"
            }
          ]
        },
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "id": "aad5cc31-0bd5-4822-aee8-165d9a85e2b2",
      "name": "Image Upload To Server",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -640,
        1024
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "candidates[0].content.parts[0].inlineData.data",
        "options": {}
      },
      "id": "770c372f-e36e-4ea5-9542-5b05c1fd09ac",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        464,
        992
      ],
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "httpRequestMethod": "POST",
        "graphApiVersion": "v22.0",
        "node": "me",
        "edge": "photos",
        "sendBinaryData": true,
        "binaryPropertyName": "data",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $('FB caption').item.json.output }}"
              }
            ]
          }
        }
      },
      "id": "fd38df8d-4b5e-4dc5-87e6-8d6252f84a47",
      "name": "Facebook Graph API",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        896,
        992
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1unoIMG4dKLP1Fw0euo64deo_FyBJp4viN4_Sy4LT0Dc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1unoIMG4dKLP1Fw0euo64deo_FyBJp4viN4_Sy4LT0Dc/edit?usp=drivesdk",
          "cachedResultName": "Affiliate Automation"
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1unoIMG4dKLP1Fw0euo64deo_FyBJp4viN4_Sy4LT0Dc/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "value": {
            "Product Link": "={{ $('Google Sheets Trigger').item.json['Product Link'] }}",
            "Facebook Upload": "Done ✅"
          },
          "schema": [
            {
              "id": "Product Link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Product Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Facebook Upload",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Facebook Upload",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Product Link"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "9219bd00-42bb-43dd-87e9-df24b530f1e5",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1104,
        992
      ],
      "typeVersion": 4.5
    },
    {
      "parameters": {
        "amount": 10
      },
      "id": "383531e7-d74c-4d0b-bdcf-da54ee72031d",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        672,
        992
      ],
      "webhookId": "fe8a2c4f-1f11-4f61-843b-a14ce0fefd74",
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You are a copywriter helping an Amazon affiliate marketer write high-converting, scroll-stopping Facebook captions.\n\nFor each product, generate a short and engaging caption (1–3 lines max) that:\n- Grabs attention fast\n- Focuses on the product’s top benefit or unique feature\n- Sounds casual and native to Facebook\n- Includes a CTA to buy\n- Ends with the affiliate link\n\nHere is the product name and features:\n\nProduct: {{ $('Amazon Product Details').item.json.data.product_title }}\n\nAbout Product : {{ $('Amazon Product Details').item.json.data.about_product[3] }}\n\nAffiliate Link: {{ $('Amazon Product Details').item.json.data.product_url }}?tag=rakin114-20\n\n\nGive only 1 caption directly and don't contain any symbol. Add emojis and with the affiliate link add here's the poduct or purchase link any thing that goes well.",
        "options": {}
      },
      "id": "1038d9a1-2947-4b81-8a38-f2f3afa7a010",
      "name": "FB caption",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1248,
        672
      ],
      "typeVersion": 1.8
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Create a very short prompt for an AI image generator that will be fed a photo of a product, to ultimately have professional product photography. \n\n- If the product is wearable you have to include the product worn by a human model, if it's not wearable then include a model holding it or doing something with it. The product should ALWAYS be with a human model, and with the model's face visible.\n\n- Make sure to include instructions to get the best realism, the best lighting, the best angle, the best colors, the best model positioning, etc. according to the type of product.\n\n- Always prompt it as referring to the product, eg. \"this [PRODUCT]\" so that the AI image generator knows that it's gonna be sent an input photo of the product.\n\n- Make sure to always instruct to include subtle grain for a cinematic look.\n\nThe description of the product will be sent to you. Only reply with the final prompt inside double quotes.\n\nThe prompt must be under 100 words and very simple.\n\n\nHere is the Product Description:\nProduct Title: {{ $('Amazon Product Details').item.json.data.product_title }}\n\nAbout Product:{{ $('Get row(s) in sheet').item.json['Product Details'] }}\n\n",
        "options": {}
      },
      "id": "17c8e9f0-d016-40d4-bb09-fd7f7c91e6cb",
      "name": "Image Prompt Generate",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -304,
        688
      ],
      "typeVersion": 1.8
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=You only have to give the asin number from this amazon product url:  {{ $json.Link }}",
        "options": {}
      },
      "id": "09b3c1f6-0bb7-49f1-ba08-5814f8ad6370",
      "name": "asin number",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1952,
        912
      ],
      "typeVersion": 1.8
    },
    {
      "parameters": {
        "content": "---\n\n## 1️⃣ Purpose of This Agent\n\nThis workflow automates:\n\n* **Fetching Amazon product details** from a product link (via ASIN extraction).\n* **Generating Facebook captions** and **product images** with AI.\n* **Uploading** final creatives directly to **Facebook** and updating a **Google Sheet** for tracking.\n\n---\n",
        "height": 272,
        "width": 528
      },
      "id": "f5005508-34c6-4adf-bb4c-a88f216075e3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1360,
        176
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "\n## 2️⃣ How to Use\n\n* Add a **Product Link** to the connected **Google Sheet**.\n* The workflow will:\n\n  * **Extract** the ASIN number.\n  * **Fetch product details** via **RapidAPI**.\n  * **Generate Facebook captions** using OpenRouter AI.\n  * **Create product image prompts** and send them to **Google Gemini** image generator.\n  * **Upload** the generated creative to Facebook automatically.\n  * **Mark the sheet** as “Done ✅” once complete.\n\n---",
        "height": 320,
        "width": 608
      },
      "id": "7c7519a9-1ae4-42f8-9adc-57a45234cac4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        128
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## 🛠 Setup Guide\n\n1. **Google Sheets**\n\n   * Connect your sheet to the **Google Sheets Trigger** node.\n   * Ensure columns: “Product Link” & “Facebook Upload” exist.\n\n2. **RapidAPI**\n\n   * Get your [RapidAPI Key](https://rapidapi.com/) and replace `YOUR_API_KEY` in the **Amazon Product Details** node.\n\n3. **OpenRouter**\n\n   * Add your OpenRouter credentials for AI caption generation.\n\n4. **Google Gemini API**\n\n   * Add your [Gemini API Key](https://aistudio.google.com/apikey) for image prompt generation & image creation.\n\n5. **Facebook Graph API**\n\n   * Connect your Facebook account to allow posting to your page/profile.\n\nOnce connected, the workflow is **ready to run automatically** every time you add a new product link to the sheet. 🚀\n\n---",
        "height": 592,
        "width": 896
      },
      "id": "47fb269b-54aa-4b56-919d-db90b42c3f35",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "typeVersion": 1
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -2416,
        896
      ],
      "id": "d137a029-d820-480a-a88a-efc6db010de0",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "18cTau1jw6ZwGyOkK88iZVgYo-krFdTpJjgepVbzCDFY",
          "mode": "list",
          "cachedResultName": "e ccommerce",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18cTau1jw6ZwGyOkK88iZVgYo-krFdTpJjgepVbzCDFY/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/18cTau1jw6ZwGyOkK88iZVgYo-krFdTpJjgepVbzCDFY/edit#gid=0"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Upload Status"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -2208,
        896
      ],
      "id": "850eef9b-0bd6-47f3-add1-0d5691ed6663",
      "name": "Get row(s) in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "eI6LlJqGRcrJCtWI",
          "name": "Owais Google Sheets"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -2096,
        1120
      ],
      "id": "ca251939-fd4d-4a7e-9904-25eda7a30534",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "0les7y4VAUhmo4CC",
          "name": "Raja - OpenAi"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -1392,
        880
      ],
      "id": "a6368589-2fe2-460d-aec0-5b47a4ac314a",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "id": "0les7y4VAUhmo4CC",
          "name": "Raja - OpenAi"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -352,
        864
      ],
      "id": "7c7f27e7-2e35-41a5-8939-e4342045f01c",
      "name": "OpenAI Chat Model2",
      "credentials": {
        "openAiApi": {
          "id": "0les7y4VAUhmo4CC",
          "name": "Raja - OpenAi"
        }
      }
    },
    {
      "parameters": {
        "resource": "image",
        "prompt": "={{ $json.output }}",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        64,
        688
      ],
      "id": "7388e12c-68d8-4e97-aba2-26e3640c2c0c",
      "name": "Generate an image",
      "credentials": {
        "openAiApi": {
          "id": "0les7y4VAUhmo4CC",
          "name": "Raja - OpenAi"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Facebook Graph API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "FB caption": {
      "main": [
        [
          {
            "node": "Product Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "asin number": {
      "main": [
        [
          {
            "node": "Amazon Product Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Product Image": {
      "main": [
        [
          {
            "node": "Image Upload To Server",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Facebook Graph API": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Prompt Generate": {
      "main": [
        [
          {
            "node": "Generate an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Amazon Product Details": {
      "main": [
        [
          {
            "node": "FB caption",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Upload To Server": {
      "main": [
        [
          {
            "node": "Image Prompt Generate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "asin number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "asin number",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "FB caption",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model2": {
      "ai_languageModel": [
        [
          {
            "node": "Image Prompt Generate",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate an image": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  },
  "versionId": "a25b0694-6b33-4b2b-a488-859bf00f2c92",
  "meta": {
    "instanceId": "089cb37bc0c038203eafef0a664452109ceb0f3b0e0cd089e23fc9c7bc17add3"
  },
  "id": "sj8Gr8QOIld8jIDV",
  "tags": [
    {
      "updatedAt": "2025-12-10T07:27:08.590Z",
      "createdAt": "2025-12-10T07:27:08.590Z",
      "id": "QFtiX4LRrN6tCq1T",
      "name": "Tarun video"
    }
  ]
}