{
  "name": "Product Mockup Generator Blueprint",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -660,
        80
      ],
      "id": "telegram-trigger",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": "telegram_bot_credentials"
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "voice-check-condition",
              "leftValue": "={{ $json.message.voice.file_id }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "notExists",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        -440,
        80
      ],
      "id": "check-voice-message",
      "name": "Check if Text Message"
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $json.message.voice.file_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -460,
        260
      ],
      "id": "download-voice-file",
      "name": "Download Voice File",
      "credentials": {
        "telegramApi": "telegram_bot_credentials"
      }
    },
    {
      "parameters": {
        "resource": "audio",
        "operation": "transcribe",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        -260,
        260
      ],
      "id": "transcribe-voice",
      "name": "Transcribe Voice Message",
      "credentials": {
        "openAiApi": "openai_api_credentials"
      }
    },
    {
      "parameters": {
        "text": "={{ $('Transcribe Voice Message').isExecuted\n      ? $('Transcribe Voice Message').first().json.text\n      : $('Telegram Trigger').first().json.message.text }}",
        "attributes": {
          "attributes": [
            {
              "name": "Description",
              "description": "How user wants the mockup to look like",
              "required": true
            },
            {
              "name": "number",
              "description": "number of images user want",
              "required": true
            }
          ]
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "typeVersion": 1,
      "position": [
        60,
        60
      ],
      "id": "extract-requirements",
      "name": "Extract Product Requirements"
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "GPT-4.1"
        },
        "messages": {
          "values": [
            {
              "content": "=SYSTEM\nYou are an elite prompt-engineer for GPT-Image-1.\n\nUSER\nGoal → Write {{ $json.output.number }} distinct *image-generation* prompts that will be used to create high-converting product-lifestyle mock-ups for an e-commerce store.\n\nProduct description (verbatim, keep it safe!):\n{{ $json.output.Description }}\n\n🚨  NON-NEGOTIABLE RULES  \n• DO NOT modify, recolor, reshape, or obscure the product that appears in the reference image we will supply at render-time.  \n• Never crop off any part of the product.  \n• The product must remain the single, sharp focal point.  \n• Do not add brand logos—those will be added in a separate step.  \n• Each prompt must fully describe one *different* realistic scene (location, props, lighting, mood) suitable for Shopify / Amazon main images or lifestyle gallery shots.  \n• Every prompt should be self-contained: mention camera angle, background style, lighting, and mood.  \n• Language: concise, professional, present-tense.  \n• Output must be valid **JSON** in this exact shape:  \n\n```json\n{\n  \"prompts\": [\n    \"Prompt #1 text …\",\n    \"Prompt #2 text …\"\n    // …exactly {{ $json.output.number }} items\n  ]\n}"
            }
          ]
        },
        "jsonOutput": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        420,
        60
      ],
      "id": "generate-prompts",
      "name": "Generate Image Prompts",
      "credentials": {
        "openAiApi": "openai_api_credentials"
      }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/images/edits",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "openAiApi",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "image",
              "inputDataFieldName": "Product"
            },
            {
              "name": "prompt",
              "value": "=KEEP THE PRODUCT IN THE OUTPUT IMAGE EXACTLY THE SAME AS REFERENCE IMAGE, THE SIZE/DIMENSIONS OF THE PRODUCT SHOULD BE EXACTLY THE SAME AS INPUT. YOU DON'T NEED TO CHANGE THE PRODUCT'S ANYTHING, JUST IMPROVE THE SCENE AROUND IT.\n\n{{ $('Process Prompts').item.json.imagePrompt }}"
            },
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "n",
              "value": "1"
            },
            {
              "name": "size",
              "value": "1024x1024"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        320
      ],
      "id": "generate-mockup",
      "name": "Generate Product Mockup",
      "credentials": {
        "openAiApi": "openai_api_credentials"
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        60,
        220
      ],
      "id": "chat-model",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": "openai_api_credentials"
      }
    },
    {
      "parameters": {
        "operation": "sendPhoto",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        900,
        320
      ],
      "id": "send-result",
      "name": "Send Generated Mockup",
      "credentials": {
        "telegramApi": "telegram_bot_credentials"
      }
    },
    {
      "parameters": {
        "operation": "sendAndWait",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "message": "Please upload your product image that you want to create mockups for.",
        "responseType": "customForm",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Product Image",
              "fieldType": "file"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        900,
        60
      ],
      "id": "request-product-image",
      "name": "Request Product Image",
      "credentials": {
        "telegramApi": "telegram_bot_credentials"
      }
    },
    {
      "parameters": {
        "jsCode": "const prompts = $('Generate Image Prompts').first().json.message.content.prompts;\nconst binary = $input.first().binary;\n\nif (!Array.isArray(prompts)) {\n  throw new Error('❌ Expected array at message.content.prompts');\n}\n\nreturn prompts.map((prompt, i) => ({\n  json: {\n    index: i + 1,\n    imagePrompt: prompt.trim()\n  },\n  binary // carry over the binary image from original Telegram input\n}));"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        60
      ],
      "id": "process-prompts",
      "name": "Process Prompts"
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        560,
        320
      ],
      "id": "convert-to-file",
      "name": "Convert Generated Image"
    }
  ],
  "pinData": {},
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check if Text Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Text Message": {
      "main": [
        [
          {
            "node": "Extract Product Requirements",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Download Voice File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Voice File": {
      "main": [
        [
          {
            "node": "Transcribe Voice Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe Voice Message": {
      "main": [
        [
          {
            "node": "Extract Product Requirements",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Product Requirements": {
      "main": [
        [
          {
            "node": "Generate Image Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image Prompts": {
      "main": [
        [
          {
            "node": "Request Product Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Product Mockup": {
      "main": [
        [
          {
            "node": "Convert Generated Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Product Requirements",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Request Product Image": {
      "main": [
        [
          {
            "node": "Process Prompts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Prompts": {
      "main": [
        [
          {
            "node": "Generate Product Mockup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Generated Image": {
      "main": [
        [
          {
            "node": "Send Generated Mockup",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [
    "e-commerce",
    "product-mockups",
    "telegram-bot",
    "image-generation",
    "ai"
  ]
}