{
  "id": "XiwLd0JwGmDoY0mr",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automate 3D Body Model Generation",
  "tags": [],
  "nodes": [
    {
      "id": "8cc77575-854f-4359-8faa-fc78b8c23b65",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -224,
        400
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "0dc7e6b8-43b8-4b9a-aa7a-4a100598162f",
      "name": "Get status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        848,
        400
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/sam-3/requests/{{ $('Create 3D Image').item.json.request_id }}/status ",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "7540df1c-35e2-4ac5-871d-4d8410217979",
      "name": "Wait 60 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        672,
        400
      ],
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "44c4b506-2a14-40ca-a75f-7af86ef5a9af",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -224,
        256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ca8b3bcd-3eb6-4723-b2ea-a973582d46af",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -368
      ],
      "parameters": {
        "width": 1236,
        "height": 488,
        "content": "## Automate 3D Body Model Generation from Images Using Fal AI & Google Sheets\nThis workflow automates the process of **generating 3D human body models** (in `.glb` format) from **single image** using  SAM-3D model. It operates by connecting a Google Sheet as a data source with the external AI processing API. \n\nSAM 3D allows for accurate 3D reconstruction of human body shape and position from a single image.\n\n### **How it works:**\n\nThis workflow automatically creates `.glb` 3D human body models from single images using SAM-3D API. It starts by fetching image URLs from a Google Sheet where the \u201c3D RESULT\u201d field is empty. Each image is sent to the API, which returns a `request_id` for job tracking. The workflow then polls the API at intervals to check job status, repeating until completion. When the model is ready, it retrieves the 3D file URL and downloads the `.glb` file. Finally, the workflow updates the corresponding Google Sheet row by writing the result URL to the \u201cIMAGE RESULT\u201d column, marking the process as complete.\n\n### **Setup steps:**\n\nClone the provided Google Sheet and add image URLs under \u201cIMAGE MODEL,\u201d leaving \u201cIMAGE RESULT\u201d empty. Connect n8n with Google Sheets using OAuth2 credentials for the **Get new image** and **Update result** nodes. Create an FAL.AI account to obtain an API key, then configure \u201cHTTP Header Auth\u201d credentials with `Authorization: Key YOUR_API_KEY_HERE` and assign them to all equest nodes. Verify each node\u2019s filters, JSON references, and completion checks. Finally, test the workflow manually with one image before enabling the schedule trigger for automated execution.\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2230e7a5-225d-4538-b091-a9fbeedb1323",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 420,
        "height": 440,
        "content": "## STEP 1 - GOOGLE SHEET\nClone [this Google Sheet](https://docs.google.com/spreadsheets/d/1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY/edit?usp=sharing).\n\nPlease insert:\n- in the \"IMAGE MODEL\" column the basic image of the model to dress\n\nLeave the \"3D RESULT\" column unfilled. It will be inserted by the system once the image has been created"
      },
      "typeVersion": 1
    },
    {
      "id": "3aad3211-e6fc-4e4b-9c59-7dd82827a43b",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "position": [
        1024,
        400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "6ad70838-dbf4-4cb1-9b61-4cf6e1fcdf6a",
      "name": "Update result",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1008,
        720
      ],
      "parameters": {
        "columns": {
          "value": {
            "row_number": "={{ $('Get new image').item.json.row_number }}",
            "IMAGE RESULT": "={{ $('Get Url 3D image').item.json.model_glb.url }}"
          },
          "schema": [
            {
              "id": "IMAGE MODEL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "IMAGE MODEL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "IMAGE PRODUCT",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "IMAGE PRODUCT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PRODUCT ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "PRODUCT ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "IMAGE RESULT",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "IMAGE RESULT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/11ebWJvwwXHgvQld9kxywKQUvIoBw6xMa0g0BuIqHDxE/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY/edit?usp=drivesdk",
          "cachedResultName": "Image to 3D"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "239b45b3-94cc-43a9-aa2e-2c85725f4cc0",
      "name": "Set data",
      "type": "n8n-nodes-base.set",
      "position": [
        224,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c713d31f-9abd-496a-ac79-e8e2efe60aa0",
              "name": "image",
              "type": "string",
              "value": "={{ $json['IMAGE'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d81f8aa0-3302-4a26-9425-aeb2a87674e7",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        160
      ],
      "parameters": {
        "color": 7,
        "width": 772,
        "height": 444,
        "content": "## STEP 2 - GET FAL AI API KEY\nCreate an account [here](https://fal.ai/) and obtain API KEY.\nIn the node \"Create Image\" set \"Header Auth\" and set:\n- Name: \"Authorization\"\n- Value: \"Key YOURAPIKEY\""
      },
      "typeVersion": 1
    },
    {
      "id": "7061d7c1-7da8-473c-98a3-57dc15def557",
      "name": "Get new image",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        400
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "3D RESULT"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1C0Et6X3Zwr_6CxeNjhLpDwjAfIGeUvLGFawckKb0utY/edit?usp=drivesdk",
          "cachedResultName": "Image to 3D"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "edcdc4f0-4e7f-4fec-af9c-bbe8bf6bd8e6",
      "name": "Create 3D Image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        448,
        400
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/sam-3/3d-body",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"image_url\": \"{{ $json.image }}\",\n     \"export_meshes\": true,\n     \"include_3d_keypoints\": true\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9ac6f843-090f-4c15-88e7-46ee494ed1b9",
      "name": "Get Url 3D image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        448,
        720
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/sam-3/requests/{{ $json.request_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a02ac260-c88a-4c5a-9fc6-7230b95c462b",
      "name": "Get File 3D image",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        736,
        720
      ],
      "parameters": {
        "url": "={{ $json.model_glb.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "b929c14d-3f54-47d3-a3fc-c45b10c9e53e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 532,
        "height": 840,
        "content": "\n\n\n\n\n\n\n\n### Result \n![image](https://n3wstorage.b-cdn.net/n3witalia/golf-swing-result.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "b936ab89-4d5e-4abc-b095-2a3a9686c85b",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 532,
        "height": 840,
        "content": "## STEP 4 - Try the model\n\nTry .glb file on https://glb.ee/upload\n\n### Start\n![image](https://n3wstorage.b-cdn.net/n3witalia/golf-swing.jpg)"
      },
      "typeVersion": 1
    },
    {
      "id": "e2033d0e-f541-43ff-8a75-31a00df07169",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        624
      ],
      "parameters": {
        "color": 7,
        "width": 772,
        "height": 268,
        "content": "## STEP 3 - GET 3D FILE\nGet .glb file and save the url to Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "ba37c6c1-84ac-4862-b9c3-d8c3e30f7274",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1232,
        -784
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 784,
        "content": "## My New YouTube Channel\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[![image](https://n3wstorage.b-cdn.net/n3witalia/youtube-n8n-cover.jpg)](https://youtube.com/@n3witalia)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "69915264-c671-4b97-a4b6-d1e48efee456",
  "connections": {
    "Set data": {
      "main": [
        [
          {
            "node": "Create 3D Image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Get Url 3D image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.": {
      "main": [
        [
          {
            "node": "Get status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new image": {
      "main": [
        [
          {
            "node": "Set data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update result": {
      "main": [
        []
      ]
    },
    "Create 3D Image": {
      "main": [
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Url 3D image": {
      "main": [
        [
          {
            "node": "Get File 3D image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File 3D image": {
      "main": [
        [
          {
            "node": "Update result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Get new image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}