{
  "id": "7O2maMFxskf4vIWu",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Fashion size estimator v2",
  "tags": [],
  "nodes": [
    {
      "id": "c0525703-797e-4706-a2bb-3df23b1420fa",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -368,
        -496
      ],
      "parameters": {
        "options": {
          "appendAttribution": false
        },
        "formTitle": "Fashion Size Estimator",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Image",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Insert the url of your image"
      },
      "typeVersion": 2.2
    },
    {
      "id": "986178bc-7fb5-46d9-9f75-50bd98709a1d",
      "name": "Get status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        -496
      ],
      "parameters": {
        "url": "=https://queue.fal.run/easel-ai/fashion-size-estimator/requests/{{ $('Send image to estimator').item.json.request_id }}/status ",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "93cb9833-b123-4a74-8315-9ec1a5e37b8b",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "position": [
        592,
        -496
      ],
      "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": "40f19156-1d95-45ce-86ea-cb47096fc4c3",
      "name": "Form",
      "type": "n8n-nodes-base.form",
      "position": [
        -64,
        -16
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Fashion size estimator",
        "completionMessage": "=The result is:\n\nSize: {{ $json.size }}\nHeight: {{ $json.height }}\nBust: {{ $json.bust }}\nWaist: {{ $json.waist }}\nHip: {{ $json.hip }}"
      },
      "typeVersion": 1
    },
    {
      "id": "1afcbceb-c947-4b1d-8c9d-f490fc056c70",
      "name": "Wait 10 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        224,
        -496
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "3d4433b5-05ff-46ed-be1c-dc424b1548b1",
      "name": "Send image to estimator",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -80,
        -496
      ],
      "parameters": {
        "url": "https://queue.fal.run/easel-ai/fashion-size-estimator",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"image\": \"{{$json.Image}}\"\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": "e2d4e2ad-19f6-43ee-b865-a655497b70a6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -1344
      ],
      "parameters": {
        "color": 6,
        "width": 340,
        "height": 556,
        "content": "## Image\n![image](https://n3wstorage.b-cdn.net/n3witalia/model.jpg)"
      },
      "typeVersion": 1
    },
    {
      "id": "27d1974f-caf9-4d97-b978-7c03ded6e371",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -1344
      ],
      "parameters": {
        "color": 6,
        "width": 360,
        "height": 556,
        "content": "## Result\n\n\"size\": \"S\",\n\"height\": \"5'9\",\n\"bust\": 31,\n\"waist\": 25,\n\"hip\": 37"
      },
      "typeVersion": 1
    },
    {
      "id": "41410621-8711-4a18-aa30-f5ab7dffc0cb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -608,
        -1632
      ],
      "parameters": {
        "color": 3,
        "width": 740,
        "height": 248,
        "content": "# AI-Powered Body Measurement & Clothing Size Estimator from Image\n\nThis workflow automates the process of estimating a person\u2019s fashion size from an uploaded image using an AI model.\n\nThis workflow is an automated pipeline that uses an AI model to estimate a person's body measurements and clothing size from an image URL and send it via email.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fe3edd90-e501-49ec-8e3f-da444b7fd377",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -192,
        -720
      ],
      "parameters": {
        "color": 3,
        "width": 980,
        "height": 428,
        "content": "## STEP 1 - GET API KEY (YOURAPIKEY)\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": "3afee985-f999-4289-8843-85760d6737bf",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 208,
        "content": "Send the image url to Fashion size estimator model"
      },
      "typeVersion": 1
    },
    {
      "id": "95f36724-4e7f-4b8d-bc64-c0213f6b6346",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        352,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 208,
        "content": "Is the result ready?"
      },
      "typeVersion": 1
    },
    {
      "id": "6973ea50-3d57-40b8-847a-6f2c3fbefe84",
      "name": "Get result",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -336,
        -16
      ],
      "parameters": {
        "url": "=https://queue.fal.run/easel-ai/fashion-size-estimator/requests/{{ $json.request_id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "f31f0a19-ca0d-4f92-85ca-8a9ade8b5301",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        -240
      ],
      "parameters": {
        "color": 6,
        "width": 496,
        "height": 544,
        "content": "## STEP 2\nGet result and send to thank you page, email or webhook\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e8e75382-8e4d-4fd2-87ca-7d60363bcf60",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -368,
        -656
      ],
      "parameters": {
        "path": "5e2d6316-210c-479a-8624-7b831945c338",
        "options": {}
      },
      "typeVersion": 2.1
    },
    {
      "id": "0f655c73-d23e-4a92-a931-ef4e960a7c75",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        -64,
        160
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "a4ea5edc-bb79-448c-967c-75c15a4d7bf6",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        592,
        -160
      ],
      "parameters": {
        "sendTo": "YOUR_EMAIL",
        "message": "={{ $json.email_text }}",
        "options": {},
        "subject": "Size estimator"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "1b67b462-687e-4db9-a161-8a9fb3c80a7a",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        -160
      ],
      "parameters": {
        "text": "=You are a system that, upon receiving the following inputs:\n\nSize: {{ $json.size }}\n\nHeight: {{ $json.height }}\n\nBust: {{ $json.bust }}\n\nWaist: {{ $json.waist }}\n\nHip: {{ $json.hip }}\n\nmust generate an HTML email using the template provided ",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "2d8ac08f-519d-492a-9137-157422a9a889",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        224,
        32
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "33331621-a804-4ee6-9727-63749509fe42",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        432,
        32
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n\t\"type\": \"object\",\n\t\"properties\": {\n\t\t\"email_text\": {\n\t\t\t\"type\": \"string\"\n\t\t}\n\t}\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "170b37ec-72dd-4d15-980f-159d5479d8ff",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -240
      ],
      "parameters": {
        "color": 4,
        "width": 592,
        "height": 544,
        "content": "## STEP 3\nCreate an email and send the result\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2d6d46c0-9473-46d2-ab9d-6e95d7940d51",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -1632
      ],
      "parameters": {
        "width": 752,
        "height": 464,
        "content": "## How it works\n\n\n1.  **Form Trigger:** The workflow starts with a public form where a user submits a URL of an image.\n2.  **AI Processing Request:** The submitted image URL is sent to the `fal.run` AI service (specifically, the \"fashion-size-estimator\" model) via a POST request. This initial request places the job in a queue and returns a unique `request_id`.\n3.  **Polling for Completion:** The AI processing is asynchronous and takes some time. The workflow enters a loop where it:\n    *   **Waits:** Pauses for 10 seconds to give the AI model time to process the request.\n    *   **Checks Status:** Uses the `request_id` to check the status of the job.\n    *   **Conditional Check:** An IF node checks if the status is \"COMPLETED\".\n        *   If `NO` (not completed), the loop repeats (wait, then check again).\n        *   If `YES`, the workflow exits the loop.\n4.  **Fetching and Displaying Results:** Once processing is complete, the workflow retrieves the final result (containing the size, height, bust, waist, and hip measurements) and automatically displays it to the user on a \"thank you\" page."
      },
      "typeVersion": 1
    },
    {
      "id": "3e40a712-9910-4d46-85ee-72985bd4f346",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -1152
      ],
      "parameters": {
        "width": 752,
        "height": 368,
        "content": "## Set up steps\n\nTo make this workflow operational, you need to configure the API authentication.\n\n1.  **Obtain an API Key:**\n    *   Create an account at fal.ai\n    *   Navigate to your account settings to generate an API key.\n\n2.  **Configure Credentials in n8n:**\n    *   In your n8n instance, create a new HTTP Header Auth credential (you can name it \"Fal.run API\").\n    *   Set the **Name** field to `Authorization`.\n    *   Set the **Value** field to `Key YOURAPIKEY`, replacing \"YOURAPIKEY\" with the actual key you obtained from fal.ai.\n    *   Ensure this credential is correctly selected in the three HTTP Request nodes: \"Send image to estimator\", \"Get status\", and \"Get result\".\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "c986a53d-909c-4b78-bb0d-a9af5ae15100",
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Send image to estimator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Get result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get result": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          },
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          },
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 sec.": {
      "main": [
        [
          {
            "node": "Get status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Send image to estimator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send image to estimator": {
      "main": [
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}