{
  "id": "dSgAoJURz5MofBkE",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Product Pictures Generations",
  "tags": [],
  "nodes": [
    {
      "id": "84245e2f-9eeb-42cb-8c35-2e1bebe40699",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1100,
        -140
      ],
      "parameters": {
        "path": "auto-generated",
        "options": {},
        "formTitle": "\ud83d\ude80 AI Marketing Campaign Generator V2",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Product Image",
              "requiredField": true
            },
            {
              "fieldLabel": "What is the product's name?",
              "requiredField": true
            },
            {
              "fieldLabel": "What is the Product Tagline?"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Product Description",
              "requiredField": true
            },
            {
              "fieldType": "select",
              "fieldLabel": "What is the Product Category?",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Highlighted Benefit"
            }
          ]
        },
        "formDescription": "Upload your product and get a complete professional marketing campaign automatically generated. Our AI analyzes your product and creates everything dynamically."
      },
      "typeVersion": 2
    },
    {
      "id": "33b1b65a-35f8-495e-8427-c2235e35b884",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        -620,
        -140
      ],
      "parameters": {
        "jsCode": "// Dynamic brand profile generator with proper binary data handling\nconst formData = $input.first().json;\nconst binaryData = $input.first().binary;\n\n// Extract product information\nconst productName = formData[\"What is the product's name?\"] || '';\nconst productTagline = formData[\"What is the Product Tagline?\"] || '';\nconst productDescription = formData[\"Product Description\"] || '';\nconst productCategory = formData[\"What is the Product Category?\"] || 'Other';\nconst highlightedBenefit = formData[\"Highlighted Benefit\"] || '';\n\n// Find the uploaded image binary data\nlet imageBinary = null;\nif (binaryData) {\n  // Try different possible field names for the uploaded image\n  imageBinary = binaryData['Product Image'] || \n                binaryData['product_image'] || \n                binaryData['data'] ||\n                binaryData['Product_Image'] ||\n                binaryData[Object.keys(binaryData)[0]]; // Use first available binary\n}\n\n// Validate we have image data\nif (!imageBinary) {\n  throw new Error('No image file found. Please ensure you upload a product image.');\n}\n\n// Convert to base64 for AI processing later\nlet imageBase64 = '';\nif (Buffer.isBuffer(imageBinary)) {\n  imageBase64 = imageBinary.toString('base64');\n} else if (imageBinary.data && Buffer.isBuffer(imageBinary.data)) {\n  imageBase64 = imageBinary.data.toString('base64');\n}\n\n// Create dynamic brand profile\nconst dynamicBrandProfile = {\n  // AI will populate this based on product analysis\n  brandName: productName || \"DYNAMIC BRAND\",\n  brandTone: \"Will be determined by AI based on product analysis\",\n  colorTheme: \"AI will extract from product image and market analysis\",\n  backgroundStyle: \"AI will determine optimal style for product category\",\n  lightingStyle: \"AI will optimize for product type and target audience\",\n  productPlacement: \"AI will create placement rules based on product characteristics\",\n  typographyStyle: \"AI will match typography to brand personality\",\n  compositionGuidelines: \"AI will generate composition rules for brand consistency\",\n  \n  // Metadata for AI processing\n  productInfo: {\n    name: productName,\n    tagline: productTagline,\n    description: productDescription,\n    category: productCategory,\n    benefit: highlightedBenefit,\n    imageBase64: imageBase64\n  },\n  \n  // Processing flags\n  needsAIProcessing: true,\n  timestamp: new Date().toISOString()\n};\n\n// CRITICAL: Return both JSON and binary data\nreturn [{\n  json: dynamicBrandProfile,\n  binary: {\n    data: imageBinary  // Google Drive expects 'data' key\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "990382e9-78e4-4b8b-91d8-04b01eedbb60",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -800,
        -360
      ],
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        },
        "inputDataFieldName": "Product_Image"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "53c8797d-9a1e-4363-8903-68a8610c58b3",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        -660,
        280
      ],
      "parameters": {
        "jsCode": "// Process AI Agent output with robust error handling\nconst input = $input.first();\n\n// Debug: Check what we're getting\nconsole.log('Input structure:', input ? Object.keys(input) : 'input is null');\nconsole.log('Input JSON exists:', !!input?.json);\n\n// Safely get form data\nlet formData = {};\nlet originalBinary = {};\n\ntry {\n  formData = $('On form submission').first()?.json || {};\n  originalBinary = $('On form submission').first()?.binary || {};\n  console.log('Form data keys:', Object.keys(formData));\n  console.log('Binary data keys:', Object.keys(originalBinary));\n} catch (e) {\n  console.log('Error accessing form data:', e.message);\n}\n\n// Safely extract AI Agent output\nlet aiOutput = {};\ntry {\n  if (input?.json?.output?.output) {\n    aiOutput = input.json.output.output;\n  } else if (input?.json?.output) {\n    aiOutput = input.json.output;\n  } else if (input?.json) {\n    aiOutput = input.json;\n  } else {\n    throw new Error('No AI output found');\n  }\n  console.log('AI Output keys:', Object.keys(aiOutput));\n} catch (e) {\n  console.log('Error accessing AI output:', e.message);\n  console.log('Full input:', JSON.stringify(input, null, 2));\n  throw new Error('Cannot access AI Agent output: ' + e.message);\n}\n\n// Safely extract assets and other data\nconst assets = aiOutput.assets || [];\nconst brandStrategy = aiOutput.brandStrategy || {};\nconst campaignStrategy = aiOutput.campaignStrategy || {};\n\nconsole.log('Assets found:', assets.length);\n\nif (assets.length === 0) {\n  console.log('No assets in AI output. Full aiOutput:', JSON.stringify(aiOutput, null, 2));\n  throw new Error('No assets generated by AI Agent');\n}\n\n// Safely prepare product info\nconst productInfo = {\n  name: formData[\"What is the product's name?\"] || 'Unknown Product',\n  tagline: formData[\"What is the Product Tagline?\"] || '',\n  description: formData[\"Product Description\"] || '',\n  category: formData[\"What is the Product Category?\"] || 'General',\n  benefit: formData[\"Highlighted Benefit\"] || ''\n};\n\n// Safely get binary data\nlet productImageBinary = null;\ntry {\n  if (originalBinary && Object.keys(originalBinary).length > 0) {\n    productImageBinary = originalBinary['Product Image'] || \n                        originalBinary['data'] || \n                        originalBinary[Object.keys(originalBinary)[0]];\n  }\n} catch (e) {\n  console.log('Error accessing binary data:', e.message);\n}\n\nif (!productImageBinary) {\n  console.log('Available binary keys:', Object.keys(originalBinary || {}));\n  throw new Error('Product image binary data not found');\n}\n\n// Create outputs with safe property access\nconst processedAssets = assets.map((asset, index) => {\n  const safeAsset = asset || {};\n  return {\n    json: {\n      assetIndex: index,\n      assetType: safeAsset.assetType || `Asset ${index + 1}`,\n      purpose: safeAsset.purpose || 'Marketing',\n      backgroundTone: safeAsset.backgroundTone || 'neutral background',\n      surfaceType: safeAsset.surfaceType || 'clean surface',\n      accentProp: safeAsset.accentProp || 'minimal styling',\n      lighting: safeAsset.lighting || 'natural lighting',\n      cameraAngle: safeAsset.cameraAngle || 'straight-on angle',\n      overlayText: safeAsset.overlayText || 'Premium Quality',\n      priority: safeAsset.priority || 'medium',\n      product: productInfo,\n      brand: brandStrategy,\n      campaignTheme: campaignStrategy.campaignTheme || 'Product Launch',\n      timestamp: new Date().toISOString()\n    },\n    binary: {\n      image: productImageBinary\n    }\n  };\n});\n\nconsole.log('Successfully processed assets:', processedAssets.length);\n\nreturn processedAssets;"
      },
      "typeVersion": 2
    },
    {
      "id": "9e9ebd53-ca10-4d66-9b61-5b5055727fa4",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        -500,
        220
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "be2c4f8d-18f4-48d8-b66d-e44445dfc93e",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.assetType }}",
                    "rightValue": "Instagram Post"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "35895613-ac88-462d-8761-f9d05a530182",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.assetType }}",
                    "rightValue": "=Instagram Story"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c4419368-e947-4b71-9dc6-b52c9167c500",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.assetType }}",
                    "rightValue": "Website Banner"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8cfd9c5d-8529-47c8-b15a-2d68e77e4026",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.assetType }}",
                    "rightValue": "Ad Creative"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "15440eae-ac70-41a2-81e7-908ee7b3b90b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.assetType }}",
                    "rightValue": "Testimonial Graphic"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "9480167f-4aa6-4aa5-aab8-7831818e987f",
      "name": "Google Drive2",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        -180
      ],
      "parameters": {
        "name": "Instagram Story",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "36e0e136-68b7-4448-8ef9-7f05c30ab68a",
      "name": "Google Drive3",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        60
      ],
      "parameters": {
        "name": "Website banner ",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "3e22f2ac-d741-4f7e-a0f3-65c893b88019",
      "name": "Google Drive4",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        360
      ],
      "parameters": {
        "name": "Ad_Creative",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "8d4c01ab-a74a-4d62-b35f-f396d9527262",
      "name": "Google Drive5",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        680
      ],
      "parameters": {
        "name": "Testimonials",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "30294e38-baa6-4038-9059-3a24abe7d6da",
      "name": "Convert to File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        20,
        -500
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e9026e1b-077f-4aea-8687-35369570dace",
      "name": "Google Drive6",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        380,
        -500
      ],
      "parameters": {
        "name": "Instagram_Post",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1W5eLd9HAPWO_6TuTDW2MPMsQDknGrHoZ",
          "cachedResultName": "Product Images "
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "ec6b9238-0959-45bd-8775-a5699c0f336b",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1060,
        480
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d6d8de57-c473-4ff8-9e22-295780ee9e2b",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -820,
        480
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"productAnalysis\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"category\": {\"type\": \"string\"},\n        \"pricePoint\": {\"type\": \"string\"},\n        \"targetAudience\": {\"type\": \"string\"},\n        \"brandPersonality\": {\"type\": \"string\"},\n        \"competitivePosition\": {\"type\": \"string\"},\n        \"keyDifferentiators\": {\n          \"type\": \"array\",\n          \"items\": {\"type\": \"string\"}\n        }\n      }\n    },\n    \"brandStrategy\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"brandName\": {\"type\": \"string\"},\n        \"brandTone\": {\"type\": \"string\"},\n        \"brandVoice\": {\"type\": \"string\"},\n        \"colorTheme\": {\"type\": \"string\"},\n        \"backgroundStyle\": {\"type\": \"string\"},\n        \"lightingStyle\": {\"type\": \"string\"},\n        \"productPlacement\": {\"type\": \"string\"},\n        \"typographyStyle\": {\"type\": \"string\"},\n        \"compositionGuidelines\": {\"type\": \"string\"}\n      }\n    },\n    \"campaignStrategy\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"primaryObjective\": {\"type\": \"string\"},\n        \"secondaryObjectives\": {\n          \"type\": \"array\",\n          \"items\": {\"type\": \"string\"}\n        },\n        \"targetChannels\": {\n          \"type\": \"array\",\n          \"items\": {\"type\": \"string\"}\n        },\n        \"messagingPillars\": {\n          \"type\": \"array\",\n          \"items\": {\"type\": \"string\"}\n        },\n        \"campaignTheme\": {\"type\": \"string\"}\n      }\n    },\n    \"assets\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"type\": \"object\",\n        \"properties\": {\n          \"assetType\": {\"type\": \"string\"},\n          \"purpose\": {\"type\": \"string\"},\n          \"backgroundTone\": {\"type\": \"string\"},\n          \"surfaceType\": {\"type\": \"string\"},\n          \"accentProp\": {\"type\": \"string\"},\n          \"lighting\": {\"type\": \"string\"},\n          \"cameraAngle\": {\"type\": \"string\"},\n          \"overlayText\": {\"type\": \"string\"},\n          \"priority\": {\"type\": \"string\"}\n        }\n      }\n    }\n  }\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "e92ba30b-05c7-490a-9cb7-de7ce6cc4d9e",
      "name": "Convert to File1",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        20,
        -180
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0d788f80-4c13-4d07-b6eb-e3e24a10c4f3",
      "name": "Convert to File2",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        20,
        60
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "56e673b3-b0a2-404d-b386-f8b1c58d52fa",
      "name": "Convert to File3",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        20,
        360
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d4a9ee29-0f83-4b36-bf6c-a9ef19e49e8a",
      "name": "Convert to File4",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        20,
        680
      ],
      "parameters": {
        "options": {},
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json"
      },
      "typeVersion": 1.1
    },
    {
      "id": "e97b0490-bb4b-47f5-a441-5497dceebfee",
      "name": "Instagram_Post",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        -500
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=image"
            },
            {
              "name": "prompt",
              "value": "=Generate a photorealistic Instagram Post of {{ $json.product.name }} on {{ $json.backgroundTone }} background with {{ $json.surfaceType }} surface. Add {{ $json.accentProp }} as accent. Use {{ $json.lighting }} lighting from {{ $json.cameraAngle }}. Brand: {{ $json.brand.brandTone }}. Text: '{{ $json.overlayText }}'. Keep exact product from reference image."
            },
            {
              "name": "size",
              "value": "auto"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f278030b-135f-468a-a89d-721cc755bb62",
      "name": "Instagram_Story",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        -180
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=image"
            },
            {
              "name": "prompt",
              "value": "=Generate a photorealistic Instagram Post of {{ $json.product.name }} on {{ $json.backgroundTone }} background with {{ $json.surfaceType }} surface. Add {{ $json.accentProp }} as accent. Use {{ $json.lighting }} lighting from {{ $json.cameraAngle }}. Brand: {{ $json.brand.brandTone }}. Text: '{{ $json.overlayText }}'. Keep exact product from reference image."
            },
            {
              "name": "size",
              "value": "auto"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8eda58d7-7d0d-4437-b45a-037b58587858",
      "name": "Website_Banner",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        60
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=image"
            },
            {
              "name": "prompt",
              "value": "=Generate a photorealistic Instagram Post of {{ $json.product.name }} on {{ $json.backgroundTone }} background with {{ $json.surfaceType }} surface. Add {{ $json.accentProp }} as accent. Use {{ $json.lighting }} lighting from {{ $json.cameraAngle }}. Brand: {{ $json.brand.brandTone }}. Text: '{{ $json.overlayText }}'. Keep exact product from reference image."
            },
            {
              "name": "size",
              "value": "auto"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fb21eece-d584-408e-ba4b-5d86a43ef9fb",
      "name": "Ad_Creative",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        360
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=image"
            },
            {
              "name": "prompt",
              "value": "=Generate a photorealistic Instagram Post of {{ $json.product.name }} on {{ $json.backgroundTone }} background with {{ $json.surfaceType }} surface. Add {{ $json.accentProp }} as accent. Use {{ $json.lighting }} lighting from {{ $json.cameraAngle }}. Brand: {{ $json.brand.brandTone }}. Text: '{{ $json.overlayText }}'. Keep exact product from reference image."
            },
            {
              "name": "size",
              "value": "auto"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2015afa3-a144-4986-82e6-926646c175e6",
      "name": "Testimonials",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -220,
        680
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/images/edits",
        "method": "POST",
        "options": {
          "timeout": 90000
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "image",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=image"
            },
            {
              "name": "prompt",
              "value": "=Generate a photorealistic Instagram Post of {{ $json.product.name }} on {{ $json.backgroundTone }} background with {{ $json.surfaceType }} surface. Add {{ $json.accentProp }} as accent. Use {{ $json.lighting }} lighting from {{ $json.cameraAngle }}. Brand: {{ $json.brand.brandTone }}. Text: '{{ $json.overlayText }}'. Keep exact product from reference image."
            },
            {
              "name": "size",
              "value": "auto"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "openAiApi"
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "c2619198-0ede-4d30-9548-2e88785b0e69",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1140,
        -420
      ],
      "parameters": {
        "color": 3,
        "width": 720,
        "height": 420,
        "content": "## Product Image and Characteristics Form"
      },
      "typeVersion": 1
    },
    {
      "id": "657cf9bc-40d1-4681-9121-462057ccd630",
      "name": "Image & Text Analyzer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -980,
        280
      ],
      "parameters": {
        "text": "=VISUAL & TEXT ANALYSIS: \nAnalyze the uploaded product image to extract exact colors, materials, styling, and any visible branding. Then combine this with the provided product information.\n\nProduct Name: {{ $('On form submission').item.json[\"What is the product's name?\"] }}\nTagline: {{ $('On form submission').item.json[\"What is the Product Tagline?\"] }}\nDescription: {{ $('On form submission').item.json[\"Product Description\"] }}\nCategory: {{ $('On form submission').item.json[\"What is the Product Category?\"] }}\nBenefit: {{ $('On form submission').item.json[\"Highlighted Benefit\"] }}\n\nBased on BOTH the visual analysis of the image AND the text information above, create a comprehensive marketing campaign strategy.\n\n**CRITICAL**: You must include all sections in your response:\n1. productAnalysis\n2. brandStrategy (using colors from the actual image)\n3. campaignStrategy  \n4. **assets** (REQUIRED: Generate exactly 5 marketing assets)\n\nThe assets array must include these 5 asset types with complete creative direction:\n- Instagram Post\n- Instagram Story  \n- Website Banner\n- Ad Creative\n- Testimonial Graphic\n\nFor each asset, provide: assetType, purpose, backgroundTone, surfaceType, accentProp, lighting, cameraAngle, overlayText, priority\n\nReturn the complete JSON structure as specified in the schema.",
        "options": {
          "systemMessage": "You are an advanced AI marketing strategist and visual analyst. You can see and analyze product images to create comprehensive marketing campaigns.\n\nIMPORTANT: You will receive a product image along with text information. Analyze both the visual and textual data to create the most accurate marketing strategy.\n\nVISUAL ANALYSIS: Use the uploaded image to extract exact colors, materials, style, and branding elements.\n\nYOUR TASK: Create a complete marketing campaign strategy that includes:\n1. Product analysis based on visual and text data\n2. Brand strategy with colors extracted from the image\n3. Campaign strategy \n4. MOST IMPORTANT: Generate 5 specific marketing assets with detailed creative direction\n\nYou MUST return the complete JSON structure including the assets array with all 5 asset types.",
          "passthroughBinaryImages": true
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "c5c5cdab-bf5b-4e78-b4d7-ff0b48dace3b",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -560
      ],
      "parameters": {
        "color": 4,
        "width": 1100,
        "height": 220,
        "content": "## Instagram Post Generation"
      },
      "typeVersion": 1
    },
    {
      "id": "ef4e1ede-11dc-4e45-aa89-9fe99616e2f7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -260
      ],
      "parameters": {
        "color": 6,
        "width": 1100,
        "height": 220,
        "content": "## Instagram Story Generation"
      },
      "typeVersion": 1
    },
    {
      "id": "2e17ad69-bcf7-4dff-9b6f-0e272586e2fe",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 1100,
        "height": 220,
        "content": "## Website Banner Generation"
      },
      "typeVersion": 1
    },
    {
      "id": "6ddca712-6976-40d5-9e3d-39c011043bba",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        280
      ],
      "parameters": {
        "color": 2,
        "width": 1100,
        "height": 260,
        "content": "## Ad Creative Generation"
      },
      "typeVersion": 1
    },
    {
      "id": "48603533-a7bc-44dd-8570-1bef055dce4b",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        580
      ],
      "parameters": {
        "color": 7,
        "width": 1100,
        "height": 260,
        "content": "## Testimonials Generation"
      },
      "typeVersion": 1
    },
    {
      "id": "eee05105-7ba1-4ef9-88e9-b4cbcb081161",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1100,
        140
      ],
      "parameters": {
        "width": 480,
        "height": 500,
        "content": "## Advanced AI marketing strategist"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "57fff9d7-9fd7-4371-aca0-19ded3d54c74",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Instagram_Post",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Instagram_Story",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Website_Banner",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ad_Creative",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Testimonials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ad_Creative": {
      "main": [
        [
          {
            "node": "Convert to File3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Image & Text Analyzer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        []
      ]
    },
    "Testimonials": {
      "main": [
        [
          {
            "node": "Convert to File4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram_Post": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Website_Banner": {
      "main": [
        [
          {
            "node": "Convert to File2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Google Drive6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Instagram_Story": {
      "main": [
        [
          {
            "node": "Convert to File1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File1": {
      "main": [
        [
          {
            "node": "Google Drive2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File2": {
      "main": [
        [
          {
            "node": "Google Drive3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File3": {
      "main": [
        [
          {
            "node": "Google Drive4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File4": {
      "main": [
        [
          {
            "node": "Google Drive5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Image & Text Analyzer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Image & Text Analyzer": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Image & Text Analyzer",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}