{
  "name": "Generate & upload images with Image-to-Image GPT, Google Sheets & Drive",
  "nodes": [
    {
      "id": "1f995205-641d-4a03-a6d4-aada6bb2cb17",
      "name": "Google Sheets2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -480,
        260
      ]
    },
    {
      "id": "36bdf920-27c4-4fb8-9f83-468e8d66a699",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -240,
        260
      ]
    },
    {
      "id": "886a068d-0e1b-40a9-a4f9-5a8cd51ec90c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2000,
        540
      ]
    },
    {
      "id": "5f9b58bc-228e-4cf2-ba1d-76fde79e8af8",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -760,
        260
      ]
    },
    {
      "id": "a46bc160-9ea7-4834-a031-b5b025f5356c",
      "name": "If2",
      "type": "n8n-nodes-base.if",
      "position": [
        20,
        280
      ]
    },
    {
      "id": "8a87ab83-d243-41f3-b85f-a0cbbb1edee2",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        560,
        360
      ]
    },
    {
      "id": "d162216f-c4bb-4f6b-a116-15d3cd986b7c",
      "name": "Google Sheets4",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1260,
        560
      ]
    },
    {
      "id": "84fbc87b-3511-4945-97b2-254bd644bed3",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        940,
        260
      ]
    },
    {
      "id": "7a7b4988-9650-48c5-a9cc-339a9403f090",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        860,
        -100
      ]
    },
    {
      "id": "4d7b5ebe-2df9-4ac2-9b38-5e709654514d",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        240,
        240
      ]
    },
    {
      "id": "abc66cee-05b8-4bb7-976b-55130b761fda",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        540,
        -100
      ]
    },
    {
      "id": "d268cfe7-3ca2-4d96-9965-263fb1d8146a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1780,
        -380
      ],
      "parameters": {
        "width": 720,
        "height": 1280,
        "content": "# 🧠 AI Image Generator with Google Sheets & Drive\n\n## 📌 Purpose\nAutomatically generate images from prompts in Google Sheets, upload them to Google Drive, and log the link back to the sheet.\n\n---\n\n## ✅"
      }
    },
    {
      "id": "61abe854-c306-488c-b427-bfd51b88cde1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -840,
        120
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "### 1. **Manual Trigger**\nManually starts the workflow for testing or controlled execution."
      }
    },
    {
      "id": "1e81a32e-5e79-4b20-8067-0258d068f874",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        80
      ],
      "parameters": {
        "width": null,
        "height": 340,
        "content": "### 2. **Google Sheets2 – Fetch Prompts**\n- Connects to a specific Google Sheet.\n- Reads rows that include prompts.\n- These prompts will be used to generate images."
      }
    },
    {
      "id": "880542b2-bf17-48ad-951e-466073fc0008",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -300,
        100
      ],
      "parameters": {
        "width": 220,
        "height": 280,
        "content": "### 3. **Loop Over Items**\n- Loops through each row one by one.\n- This ensures each prompt is handled independently.\n"
      }
    },
    {
      "id": "27299667-dba0-4ea4-99d3-1ccaac9342bc",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        40
      ],
      "parameters": {
        "width": 220,
        "height": 360,
        "content": "### 4. **If2 – Filter Valid Rows**\n- Checks two conditions:\n  1. Whether the \"Prompt\" column has text\n  2. Whether the \"drive path\" column is empty (i.e., not processed yet)\n- If both conditions pass,"
      }
    },
    {
      "id": "23efdf34-796a-41b7-9b32-ef18e0ce408f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        200,
        20
      ],
      "parameters": {
        "width": null,
        "height": 340,
        "content": "### 5. **HTTP Request – Call Image API**\n- Sends a POST or GET request to the AI image generator API (like RapidAPI or Replicate).\n- Includes the prompt as a parameter.\n- Receives the image in base64 "
      }
    },
    {
      "id": "c8555a0b-fd48-4776-bb95-f9148fbaaaa5",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        480,
        180
      ],
      "parameters": {
        "width": null,
        "height": 300,
        "content": "### 6. **Try Catch – Error Handling**\n- Wraps around the API call and upload step.\n- If image generation or upload fails, the error is caught here and handled without breaking the loop."
      }
    },
    {
      "id": "d5c01bf8-aa58-4dd3-a066-96c177e723bf",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -320
      ],
      "parameters": {
        "width": null,
        "height": 380,
        "content": "### 7. **Google Drive – Upload Image**\n- Converts base64 image (if needed).\n- Uploads the image to a specified Google Drive folder.\n- Retrieves the public/shared URL of the uploaded image.\n"
      }
    },
    {
      "id": "1c9adb0e-e7ff-418f-ace3-6064f5ea6ea5",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        -240
      ],
      "parameters": {
        "width": null,
        "height": 280,
        "content": "### 8. **Set – Prepare Image Link**\n- Formats the image URL from Drive to make it user-friendly or shareable.\n- Prepares this value to update back into the sheet."
      }
    },
    {
      "id": "5f0d6cd1-9c02-4883-9574-1886c7ecaad4",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        80
      ],
      "parameters": {
        "width": null,
        "height": 320,
        "content": "### 9. **Google Sheets1 – Update Sheet**\n- Writes the image link into the same row from which the prompt came.\n- Marks the row as \"processed\" by updating the drive path field."
      }
    },
    {
      "id": "b1f0dccc-5124-4d89-af0b-8cead135c300",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1180,
        360
      ],
      "parameters": {
        "width": null,
        "height": 300,
        "content": "### 10. **Google Sheets3 – Log Status**\n- Appends a new row in a separate log sheet or tab.\n- Records status (success/failure), prompt, and time.\n- Useful for tracking flow execution over time."
      }
    },
    {
      "id": "30397d7d-206e-4a64-b262-05858e226f1a",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1940,
        380
      ],
      "parameters": {
        "width": null,
        "height": 320,
        "content": "This node is used to insert a delay before proceeding to the next step in the workflow. In your case, the node waits for `10 seconds`."
      }
    }
  ],
  "connections": {
    "If1": {
      "main": [
        [
          {
            "node": "Google Sheets4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If2": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code1": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets4": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "If2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Google Sheets2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}