AI Virtual TryOn for WooCommerce from Google Sheets
Overview
This workflow automates the creation of realistic "virtual try-on" images for WooCommerce clothing products. It eliminates the need for expensive photoshoots by using an AI model (fal.ai's Nano Banana) to generate an image of a model wearing a specific clothing item. The workflow reads product data from a Google Sheet, triggers the AI image generation, waits for completion, downloads the result, uploads it to Google Drive, updates the Google Sheet with the new image URL, and finally updates the WooCommerce product with the generated image.
This is particularly useful for eCommerce stores with large catalogs, allowing them to quickly generate high-quality product images for all their clothing items without manual photoshoots. The entire process is automated and can be run on a schedule or manually triggered.
Workflow Steps
-
When clicking 'Test workflow' (Manual Trigger) — Starts the workflow manually for testing or on-demand execution.
-
Google Sheets (Google Sheets - OAuth2) — Fetches all rows from a specified Google Sheet. The sheet must contain columns for 'IMAGE MODEL', 'IMAGE PRODUCT', 'PRODUCT ID', and 'IMAGE RESULT' (which will be filled by the workflow).
-
Loop Over Items (Split In Batches) — Iterates over each row from the Google Sheet, processing one product at a time.
-
Set data (Set) — Extracts the 'IMAGE MODEL' and 'IMAGE PRODUCT' URLs from the current row and assigns them to variables named 'model' and 'shirt' for use in subsequent nodes.
-
Create Image (HTTP Request - Header Auth) — Sends a POST request to the fal.ai Nano Banana API endpoint (
https://queue.fal.run/fal-ai/nano-banana/edit). The request body includes a prompt instructing the AI to generate a photo of the model wearing the clothing item. It uses Header Auth with anAuthorization: Key YOURAPIKEYheader. -
Wait 60 sec. (Wait) — Pauses execution for 10 seconds (configured as 10 seconds in the JSON, despite the node name) to allow the AI image generation to complete.
-
Get status (HTTP Request - Header Auth) — Polls the fal.ai API status endpoint (
https://queue.fal.run/fal-ai/nano-banana/requests/{{request_id}}/status) to check if the image generation is complete. Uses Header Auth. -
Completed? (IF) — Checks if the status from the previous node equals "COMPLETED". If yes, the workflow proceeds to download the image. If not, it loops back to the Wait node to poll again.
-
Get Url image (HTTP Request - Header Auth) — Once the status is COMPLETED, this node fetches the result data from the fal.ai API to get the URL of the generated image. Uses Header Auth.
-
Get File image (HTTP Request - No Auth) — Downloads the actual image file from the URL provided by the previous node. This is a simple GET request with no authentication.
-
Upload Image (Google Drive - OAuth2) — Uploads the downloaded image file to a specified folder in Google Drive. The filename is timestamped to avoid conflicts.
-
Update result (Google Sheets - OAuth2) — Updates the current row in the Google Sheet, writing the URL of the generated image into the 'IMAGE RESULT' column.
-
WooCommerce (WooCommerce - API Key Auth) — Updates the WooCommerce product (identified by the 'PRODUCT ID' from the sheet) by setting its main image to the newly generated image URL.
Setup Instructions
Required Accounts & Services
- Google Account — For Google Sheets and Google Drive access. You'll need to create OAuth2 credentials in the Google Cloud Console.
- fal.ai Account — Sign up at fal.ai to get an API key. This is the AI image generation service.
- WooCommerce Store — A WooCommerce site with API credentials (Consumer Key and Consumer Secret) enabled.
Configuration Steps
- Google Sheet: Create a Google Sheet with columns:
IMAGE MODEL,IMAGE PRODUCT,PRODUCT ID,IMAGE RESULT. Populate the first three columns with the model image URL, product image URL, and WooCommerce product ID respectively. LeaveIMAGE RESULTempty. - fal.ai API Key: In the 'Create Image', 'Get status', and 'Get Url image' nodes, configure Header Auth with:
- Name:
Authorization - Value:
Key YOUR_API_KEY(replaceYOUR_API_KEYwith your actual key)
- Name:
- WooCommerce Credentials: Configure the WooCommerce node with your site URL, Consumer Key, and Consumer Secret.
- Google Drive Folder: (Optional) Specify a folder ID in the 'Upload Image' node to organize generated images.
Use Cases & Variations
- Scheduled Runs: Replace the Manual Trigger with a Cron or Schedule trigger to run daily/weekly for new products.
- Multiple AI Models: Swap the fal.ai endpoint with other image generation APIs (e.g., Stable Diffusion, DALL-E) by changing the URL and request body.
- Different Outputs: Instead of updating WooCommerce, you could send the image URL via email, post to social media, or save to a different storage service.
- Error Handling: Add error handling nodes (e.g., IF node for failed status) to notify you if image generation fails.
- Batch Processing: Adjust the 'Loop Over Items' batch size to control how many products are processed concurrently.
Workflow JSON
{
"id": "HQcHQhEaig6JXOH4",
"meta": {
"instanceId": "a4bfc93e975ca233ac45ed7c9227d84cf5a2329310525917adaf3312e10d5462"
},
"name": "AI Virtual TryOn for WooCommerce Nano Banana",
"tags": [],
"nodes": [
{
"id": "614bb588-3180-47e7-8dd6-fd61883d6042",
"name": "When clicking ‘Test workflow’",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-480,
1600
],
"parameters": {},
"typeVersion": 1
},
{
"id": "9f15348f-8e76-43d7-a17a-3efb1b9d5724",
"name": "Get File image",
"type": "n8n-nodes-base.httpRequest",
"position": [
448,
1872
],
"parameters": {
"url": "={{ $json.images[0].url }}",
"options": {}
},
"typeVersion": 4.2
},
{
"id": "44d01abf-6b54-432a-a21c-a4b94c1487c7",
"name": "Get Url image",
"type": "n8n-nodes-base.httpRequest",
"position": [
224,
1872
],
"parameters": {
"url": "=https://queue.fal.run/fal-ai/nano-banana/requests/{{ $json.request_id }}",
"options": {},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"credentials": {
"httpHeaderAuth": {
"id": "credential-id",
// ... truncated (copy to see full JSON)How to Import This Workflow
- 1Copy the workflow JSON above using the Copy Workflow JSON button.
- 2Open your n8n instance and go to Workflows.
- 3Click Import from JSON and paste the copied workflow.
Don't have an n8n instance? Start your free trial at n8nautomation.cloud