Automate AI Image Generation & Storage with n8n and Google

This workflow automates AI-driven image generation from chat prompts using OpenAI, then saves images to Google Drive and logs everything in Google Sheets. It solves time-consuming manual image creation and management tasks.
httpRequest
googleDrive
googleSheets
+8
Workflow Identifier: 1012
NODES in Use: manualTrigger, httpRequest, googleDrive, splitOut, convertToFile, splitInBatches, set, googleSheets, aggregate, chatTrigger, stickyNote

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow takes a chat message that describes an image and turns it into real picture files.
It stops the user from doing slow, error-prone work by making images, saving them in Google Drive, and logging all details in Google Sheets automatically.
The result is saved images with clear info and tracked costs, all without much effort from the user.

The main problem solved is saving time and avoiding mistakes when managing AI-generated images.
It works by catching a chat prompt, sending it to OpenAI’s image generation API, then handling each returned image file step by step.


Who should use this workflow

Anyone who makes AI images from chat text and wants to avoid doing boring manual work.
It fits engineers, makers, or small teams who upload files to Google Drive and track them in Sheets.

The workflow works well for users who want costs tracked and data centrally stored.
It needs a Google Drive and Sheets account plus OpenAI API access.


Tools and services used

  • OpenAI API: Generates AI images from text prompts.
  • Google Drive: Stores image files in organized folders.
  • Google Sheets: Saves image URLs, prompt text, and cost data.
  • n8n workflow automation: Connects services with nodes including Chat Trigger, HTTP Request, and others.

Beginner step-by-step: How to use this workflow in n8n

Import and prepare

  1. Download the workflow file from this page.
  2. Open the n8n editor.
  3. Click the menu and select “Import from File”.
  4. Choose the downloaded workflow file to load it in.

Configure credentials and settings

  1. Add OpenAI API credentials in n8n settings.
  2. Add Google Drive and Google Sheets OAuth2 credentials.
  3. Update the Google Drive folder ID in the Google Drive node if needed.
  4. Update Google Sheets document ID and sheet names in the Google Sheets nodes.

Test and activate

  1. Trigger the workflow using the Chat Trigger by sending a sample chat message describing an image.
  2. Check if images appear in Google Drive and rows append in Google Sheets.
  3. If all works, go back to editor and activate the workflow for production use.

This activates your workflow to run automatically when new chat image prompts arrive.
No need to build from zero, only minor updating of IDs and credentials.

If self hosting n8n, consider self-host n8n for production readiness.


Inputs, Processing, and Outputs

Inputs

  • The workflow starts when a chat message arrives containing the image description.
  • The message data is the main input for the subsequent API call.

Processing Steps

  • Send the prompt to OpenAI image generation API with parameters for model, size, format, and quality.
  • Split the array of returned image data to process each image separately.
  • Loop over each image one at a time to avoid upload conflicts.
  • Generate a unique filename using the current timestamp string.
  • Convert the base64 encoded image JSON into a binary file ready for upload.
  • Upload the image file to a specific Google Drive folder with dynamic file naming.
  • Enrich metadata by adding Google Drive file IDs and web links.
  • Log prompt text, full image URL, and thumbnail into a Google Sheets spreadsheet.
  • Aggregate token usage from the API response to calculate estimated costs.
  • Append usage data including tokens spent and billing estimates to a separate Google Sheets tab.

Outputs

  • Image files saved in Google Drive folder with unique names.
  • Rows in Google Sheets including prompt, file link, thumbnail image, and cost data.
  • Clear tracking of what was generated, when, and how much it cost.

Handling errors and edge cases

If the OpenAI API key is missing or wrong, the workflow will fail at the HTTP Request node step due to authentication error.
Check credentials and re-enter the correct API key.

If Google Drive uploads are missing or scattered, verify that the folder ID in the Google Drive node is correct and accessible by the Google account used.
Wrong folder ID causes files to upload somewhere else or fail.

If rows do not append to Google Sheets, ensure the document ID and sheet names match the spreadsheet setup, and the columns expected exist.
Typos in sheet names or mismatched columns cause append errors.


Customization ideas

  • Change image size or quality in the HTTP Request node by editing the parameters like size or quality.
  • Set how many images are generated per prompt by changing the n number.
  • Use dynamic Google Drive folder creation based on date or other rules to organize uploads better.
  • Add more columns or fields to Google Sheets to save extra metadata like file ID or creation timestamps.
  • Add an email node (Gmail or SMTP) after upload to send image links automatically to a team or user.

Summary and Result

→ This workflow gets a text chat prompt to generate AI images.
→ Automated file upload and metadata logging keeps everything tracked without manual steps.
→ Users save lots of time and avoid errors in managing AI generated images.
→ Detailed cost monitoring helps control API usage spend.


Frequently Asked Questions

The Chat Trigger node activates the workflow when it receives a chat message containing an image description.
The workflow converts images from base64 to files and uploads them to a specified Google Drive folder using the Google Drive node.
Image URLs, thumbnails, prompts, and usage cost data are appended to Google Sheets using the Google Sheets nodes.
Users must add correct credentials for OpenAI and Google, update Google Drive folder ID and Google Sheets document IDs, then test and activate the workflow.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free