{
  "id": "uiHy8QXs5YlW7NGD",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Use AI to generate advertising photos",
  "tags": [],
  "nodes": [
    {
      "id": "496a71a4-198f-4ac8-985f-6b033ae583a0",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1696,
        592
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "715cb1c8-f96c-4315-a4bc-81bc9eedc554",
      "name": "Read Image URLs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        448,
        576
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE/edit#gid=0",
          "cachedResultName": "Product Images"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE/edit?usp=drivesdk",
          "cachedResultName": "product marketing"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2d6165ed-9657-4481-be24-e6c04b8fcda0",
      "name": "Download Images",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        656,
        576
      ],
      "parameters": {
        "url": "={{ $json['Image-URL'] }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "2181b7b1-2156-4d86-ab7f-27787caefb55",
      "name": "Product Photography Prompt",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1216,
        896
      ],
      "parameters": {
        "text": "=Image description: {{ $json.content }}",
        "messages": {
          "messageValues": [
            {
              "message": "=Create a short prompt for an AI image generator that receives 2 photos: a photo of a product to ultimately produce professional product photography and  a photo of model\n\nIf the product is wearable, it must be worn by a human model with visible face; if it's not wearable, it must be held or interacted with by a model.\n\nThe product must ALWAYS be shown together with a human model with the model's face visible.\n\nEnsure that instructions for optimal realism, best lighting, best angle, best colors, best model positioning, etc. are included according to the product type.\n\nAlways formulate the prompt to refer to the product as \"this [PRODUCT]\" so the AI image generator knows that an input photo of the product is being submitted.\n\nAlways add subtle grain for a cinematic look.\nThe description of the product will be sent to you. Respond exclusively with the final prompt, nothing else, not even quotation marks."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.6
    },
    {
      "id": "9cbc8467-d119-408b-853b-bd21d6fd6eda",
      "name": "Upload to Drive",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueRegularOutput",
      "position": [
        2608,
        608
      ],
      "parameters": {
        "name": "={{ $json.fileName + '_' + $now.toMillis() }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "12lAlOc_1c2a35L45F7Zv5ImpvWgfdf19",
          "cachedResultUrl": "https://drive.google.com/drive/folders/12lAlOc_1c2a35L45F7Zv5ImpvWgfdf19",
          "cachedResultName": "H\u00ecnh AI"
        },
        "inputDataFieldName": "edited"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "afe3c6c3-8fa4-4c09-99f5-2d33b0731ebf",
      "name": "Insert Image URL in Table",
      "type": "n8n-nodes-base.googleSheets",
      "onError": "continueRegularOutput",
      "position": [
        2832,
        608
      ],
      "parameters": {
        "columns": {
          "value": {
            "Output": "={{ $json.webViewLink }}",
            "Prompt": "={{ $('Product Photography Prompt').item.json.text }}",
            "Image-URL": "={{ $('Read Image URLs').item.json['Image-URL'] }}"
          },
          "schema": [
            {
              "id": "Image-URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Image-URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Prompt",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Prompt",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Output",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Output",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Image-URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1899842219,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE/edit#gid=1899842219",
          "cachedResultName": "Output Images"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1OXVh751Azye8D4-3DNfKgYcn8w2aKtGu_6AliAubbyE/edit?usp=drivesdk",
          "cachedResultName": "product marketing"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "e3d08de8-af32-4047-91c7-ff55281458ea",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        384
      ],
      "parameters": {
        "color": 7,
        "width": 712,
        "height": 440,
        "content": "## Phase 1 \u2013 Input & Load Product Images\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9a75717d-6f37-4ea5-9c49-ef60457054bb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        928,
        736
      ],
      "parameters": {
        "color": 7,
        "width": 744,
        "height": 664,
        "content": "## Phase 2 \u2013 Analyze Image & Create Prompt\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6f82c51a-1d95-4b86-899b-621d9454aeba",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1680,
        384
      ],
      "parameters": {
        "color": 7,
        "width": 796,
        "height": 456,
        "content": "## Phase 3 \u2013 Combine Product + Model + Prompt"
      },
      "typeVersion": 1
    },
    {
      "id": "79eee7b9-81ef-48cf-8f6a-2e4f14754a73",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        480
      ],
      "parameters": {
        "color": 7,
        "width": 520,
        "height": 360,
        "content": "## Phase 4 \u2013 Generate AI Image & Save Results"
      },
      "typeVersion": 1
    },
    {
      "id": "bc6c7779-08f1-4457-8641-ebb57aa6e344",
      "name": "When clicking 'Test workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        256,
        576
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "d46a35cc-58b1-48df-b942-701e1f9e5b52",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1152,
        1088
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f9009c1f-5b64-4b9c-8160-46dfa9a71177",
      "name": "Analyze an image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        992,
        896
      ],
      "parameters": {
        "text": "Briefly explain in less than 5 words what this image is about.",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash-lite-preview-09-2025",
          "cachedResultName": "models/gemini-2.5-flash-lite-preview-09-2025"
        },
        "options": {},
        "resource": "image",
        "inputType": "binary",
        "operation": "analyze"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "2a99e199-9825-4377-a2fc-244505ab9dde",
      "name": "Edit an image",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        2336,
        608
      ],
      "parameters": {
        "images": {
          "values": [
            {},
            {
              "binaryPropertyName": "=model"
            }
          ]
        },
        "prompt": "={{ $json.text }}",
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-3-pro-image-preview",
          "cachedResultName": "models/gemini-3-pro-image-preview (Nano Banana Pro)"
        },
        "options": {},
        "resource": "image",
        "operation": "edit"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "1646e2eb-46fb-42a2-ae8c-f763d2e5c619",
      "name": "Download model image",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        800,
        448
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "list",
          "value": "1zStAVhgIRstxC44pqWUAiB7DTNog38E1",
          "cachedResultUrl": "https://drive.google.com/file/d/1zStAVhgIRstxC44pqWUAiB7DTNog38E1/view?usp=drivesdk",
          "cachedResultName": "Model.png"
        },
        "options": {
          "binaryPropertyName": "model"
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "2a003814-e5e9-4f67-870a-a38449ea0a3d",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        1888,
        464
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3.1
    },
    {
      "id": "81d1a41d-fd7e-4753-bd96-6077ae19f2c8",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2096,
        592
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "960e3db4-b29b-4312-8ddc-abf738c2cb08",
      "name": "Sample Promt",
      "type": "n8n-nodes-base.set",
      "disabled": true,
      "position": [
        976,
        1264
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "f96241e5-2a3b-47a3-84ef-8637f5a1472f",
      "name": "Main overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -192
      ],
      "parameters": {
        "color": 1,
        "width": 784,
        "height": 720,
        "content": "## AI Product Advertising Photos\n\n### How it works\nThis workflow turns product image links in a Google Sheet into AI-generated advertising photos. It reads each `Image-URL`, downloads the product image plus a fixed model image, analyzes the product image with Gemini, then builds an edit prompt to combine the product + model into a single marketing-style photo. The resulting image is uploaded to Google Drive and the workflow upserts the `Prompt` and output URL into the `Output Images` sheet (matching by `Image-URL`).\n\n### Setup steps\n1) Connect credentials used in this workflow: Google Sheets, Google Drive, and Google Gemini.\n2) In Google Sheets, keep an input sheet with an `Image-URL` column and an output sheet with `Image-URL`, `Prompt`, and `Output` columns.\n3) Set the target Drive folder in the upload node, and (optional) change the model image file in the download node.\n4) Click **Execute/Test workflow** to process new or updated rows."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "a50e7ebf-4f9a-4867-a7b2-71973d29a8c1",
  "connections": {
    "Merge": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Sample Promt": {
      "main": [
        []
      ]
    },
    "Edit an image": {
      "main": [
        [
          {
            "node": "Upload to Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Images": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          },
          {
            "node": "Download model image",
            "type": "main",
            "index": 0
          },
          {
            "node": "Analyze an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Edit an image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Image URLs": {
      "main": [
        [
          {
            "node": "Download Images",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Drive": {
      "main": [
        [
          {
            "node": "Insert Image URL in Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze an image": {
      "main": [
        [
          {
            "node": "Product Photography Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download model image": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Product Photography Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Insert Image URL in Table": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Product Photography Prompt": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "When clicking 'Test workflow'": {
      "main": [
        [
          {
            "node": "Read Image URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}