{
  "name": "Create Image",
  "nodes": [
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        980,
        -40
      ],
      "id": "78f29b79-0abf-480d-a314-d1dac99bd4c4",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "imageTitle"
            },
            {
              "name": "imagePrompt"
            },
            {
              "name": "chatID"
            }
          ]
        }
      },
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        160,
        -40
      ],
      "id": "57504735-56b4-4cfa-ad64-8e3a24f615d8",
      "name": "When Executed by Another Workflow"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/images/generations",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $json.output.replace(/\"/g, '') }}"
            },
            {
              "name": "size",
              "value": "1024x1024"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        800,
        -40
      ],
      "id": "7e2f1e46-416e-4856-865a-53f34c312b6e",
      "name": "Generate Image",
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.imagePrompt }}",
        "options": {
          "systemMessage": "=# Overview\nYou are an expert image prompt engineer. Your role is to take a simple image topic or concept and expand it into a fully detailed image prompt that can be fed into a text-to-image generation model.\n\n## Prompt Instructions\nYour detailed prompt must clearly describe the following:\n1) Main Subject: What is the primary focus of the image?\n2) Background/Setting: What is happening in the background or environment?\n3) Style: Specify the visual style (e.g., hyper-realistic, digital painting, watercolor, anime, 3D render, etc.).\n4) Mood/Lighting: Describe the emotional tone and lighting (e.g., soft warm sunset, moody storm clouds, futuristic neon lights).\n5) Additional Details: Mention any specific objects, clothing, colors, textures, or notable features that should appear.\n\n## Output Format\n- Begin with a clean, natural-sounding descriptive prompt that integrates all of the above elements seamlessly.\n- The description should sound like it\u2019s written specifically for an AI to generate a professional, high-quality image.\n- Avoid repeating the original topic verbatim \u2014 instead, reframe it into a vivid scene or visual concept.\n- Use rich, vivid language and imagery.\n\n## Example\n- Input: \"A futuristic city\"\n- Output: \"A sprawling futuristic city at night, glowing with neon lights in shades of blue and purple. Towering skyscrapers with sleek, glass facades line the horizon. Flying cars zoom between the buildings under a cloudy, electric sky. The streets below are bustling with holographic advertisements and people wearing high-tech fashion. Digital painting style, highly detailed, cinematic perspective, moody atmosphere with soft neon reflections on wet pavement.\""
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        420,
        -40
      ],
      "id": "39125f76-6453-434f-9161-7c9cec4dc3c9",
      "name": "Image Prompt"
    },
    {
      "parameters": {
        "model": "openai/gpt-4.1",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        440,
        200
      ],
      "id": "1ab1ffb3-e899-4088-9190-cbc2c142811f",
      "name": "GPT 4.1",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "name": "={{ $('When Executed by Another Workflow').item.json.imageTitle }}.png",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "value": "1TgQu-5hlOzO1X28TMMzLxfhunhPSUIqy",
          "mode": "list",
          "cachedResultName": "AI Image Generation",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1TgQu-5hlOzO1X28TMMzLxfhunhPSUIqy"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1280,
        100
      ],
      "id": "1a4354e5-957a-4e64-aee9-08675bbd400c",
      "name": "Google Drive",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1JqOTd49heNBdmrf5hSwxI66X724tspAmSjzWoA6-EU0",
          "mode": "list",
          "cachedResultName": "Marketing Team Log",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JqOTd49heNBdmrf5hSwxI66X724tspAmSjzWoA6-EU0/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1JqOTd49heNBdmrf5hSwxI66X724tspAmSjzWoA6-EU0/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Request": "={{ $('When Executed by Another Workflow').item.json.imagePrompt }}",
            "ID": "={{ $json.id }}",
            "Link": "={{ $json.webViewLink }}",
            "Title": "={{ $('When Executed by Another Workflow').item.json.imageTitle }}",
            "Type": "Image"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Type",
              "displayName": "Type",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Request",
              "displayName": "Request",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Post",
              "displayName": "Post",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1500,
        100
      ],
      "id": "cee29401-05d3-4960-b1d3-572a4ce85be5",
      "name": "Image Log",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Image Prompt\n",
        "height": 240,
        "width": 360,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        360,
        -120
      ],
      "id": "4cc035bb-be95-4d97-b9fd-63b3ba2830cd",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "content": "## Model",
        "height": 180,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        360,
        140
      ],
      "id": "4af7f4d9-0213-40ac-bf1e-d0a3d165ee4e",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "# Trigger\n",
        "height": 240,
        "width": 260,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        80,
        -120
      ],
      "id": "106aa5db-6205-49df-aac9-ca6ef970aa3f",
      "name": "Sticky Note5",
      "disabled": true
    },
    {
      "parameters": {
        "content": "# Generate Image\n",
        "height": 240,
        "width": 400,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        740,
        -120
      ],
      "id": "c8b40781-7139-4aa6-927c-aa14059c2d4b",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "content": "# Send Content",
        "height": 240,
        "width": 300,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1180,
        -260
      ],
      "id": "0bd8867d-dec1-45db-9e10-ea1266b7d2c3",
      "name": "Sticky Note7"
    },
    {
      "parameters": {
        "content": "# Write to Drive & Sheets",
        "height": 240,
        "width": 540,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1180,
        20
      ],
      "id": "debd7f64-6f71-4d82-a018-3a93decabe9a",
      "name": "Sticky Note6"
    },
    {
      "parameters": {
        "operation": "sendPhoto",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatID }}",
        "binaryData": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1280,
        -180
      ],
      "id": "2b74621b-58af-4d58-94eb-89a5a10acb12",
      "name": "Send Photo",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Image Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Image": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Image Prompt": {
      "main": [
        [
          {
            "node": "Generate Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT 4.1": {
      "ai_languageModel": [
        [
          {
            "node": "Image Prompt",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Image Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "52b338c5-8df1-4019-a70a-60ab1c810796",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "lsZTPeThp35cB3Hs",
  "tags": []
}