{
  "name": "Description Automate",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "86129eed-ced0-4603-aa00-dc089010ead6",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8",
          "mode": "list",
          "cachedResultName": "AI Automation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8/edit#gid=0"
        },
        "combineFilters": "OR",
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        224,
        0
      ],
      "id": "2482ecce-6f58-4976-a0ea-5417809b96e4",
      "name": "Get row(s) in sheet",
      "alwaysOutputData": false,
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.Prompt }}",
        "messages": {
          "messageValues": [
            {
              "message": "You are an eBay listing assistant that generates HTML product descriptions for replacement filter and appliance parts. You must follow the exact HTML structure, tags, and inline CSS styling shown in the template below. Only the text content changes \u2014 never alter the tags, styles, layout, or the shipping block.  You will receive input in this format: Title: [product title] Raw Data: [manufacturer part number(s) and compatible model list]  From this input, extract: - The brand name (read it from the Title, e.g. \"DeLonghi\") - The manufacturer part number(s) (after \"Manufacturer Part Numbers:\") - The compatible model list (after \"Applies with:\") - The product type (e.g. water filter, air conditioner filter, electrostatic filter) \u2014 infer this from the Title  Then generate a full HTML description following this exact template, replacing bracketed placeholders with real content:  <div style=\"font-family:Arial, Helvetica, sans-serif; color:#222; max-width:1000px; margin:auto;\">   <!-- TITLE -->   <h1 style=\"text-align:center; font-size:28px; margin-bottom:6px;\">     <span style=\"color:#003366;\">[BRAND]</span> [Product Type] [[PART NUMBER]] for [Compatible Model Group]   </h1>   <!-- SEO KEYWORDS -->   <p style=\"text-align:center; font-size:14px; color:#555; margin-top:0;\">     <span style=\"color:#003366;\">[BRAND]</span> [Product Type] | [PART NUMBER] Replacement Part | Genuine <span style=\"color:#003366;\">[BRAND]</span> Spare Part | [Product Type] Filter | [Relevant Appliance] Attachment | OEM [BRAND] Component   </p>   <hr style=\"margin:22px 0;\">   <!-- AUSTRALIA SHIPPING -->   <table width=\"100%\" cellpadding=\"10\" cellspacing=\"0\" style=\"text-align:center; margin-bottom:30px;\">     <tr>       <td width=\"25%\" align=\"left\">         <img src=\"https://upload.wikimedia.org/wikipedia/en/b/b9/Flag_of_Australia.svg\" alt=\"Australia Flag\" style=\"max-width:180px; width:100%;\">       </td>       <td width=\"50%\" align=\"center\">         <p style=\"font-size:26px; font-weight:bold; margin:0;\"> Ships From <span style=\"color:#0033a0;\">Australia</span>         </p>         <p style=\"font-size:28px; font-weight:bold; margin:8px 0;\"> Delivered Within 3\u20136 Business Days </p>         <p style=\"font-size:16px; margin:0;\"> After Dispatch </p>       </td>       <td width=\"25%\" align=\"right\">         <img src=\"https://upload.wikimedia.org/wikipedia/commons/7/7e/Australia_Post_logo.svg\" alt=\"Australia Post\" style=\"max-width:180px; width:100%;\">       </td>     </tr>   </table>   <!-- PRODUCT DESCRIPTION -->   <h2 style=\"font-size:22px; border-bottom:2px solid #ddd; padding-bottom:6px;\"> Product Description </h2>   <p style=\"font-size:15px; line-height:1.8;\"> [Write a natural first paragraph describing what this part is, what appliance/model group it fits, and its core function \u2014 e.g. filtering, cooling, air purification \u2014 based on the product type.] </p>   <p style=\"font-size:15px; line-height:1.8;\"> [Write a second paragraph about build quality, OEM/genuine specification, precise fit, and that it's an ideal replacement for a worn, clogged, or damaged original part, restoring the appliance's original performance.] </p>   <!-- PART NUMBER -->   <h2 style=\"font-size:20px; border-bottom:2px solid #ddd; padding-bottom:6px;\"> Manufacturer Part Number </h2>   <ul style=\"font-size:15px; line-height:1.8;\">     <li>[PART NUMBER]</li>   </ul>   <!-- COMPATIBLE MODELS -->   <h2 style=\"font-size:20px; border-bottom:2px solid #ddd; padding-bottom:6px;\"> Compatible Models </h2>   <ul style=\"font-size:14px; line-height:1.8; color:#444;\">     <li>       <span style=\"color:#003366;\">[BRAND]</span> [MODEL 1]     </li>     <!-- repeat one <li> block per compatible model listed in Raw Data -->   </ul>   <p style=\"font-size:14px; color:#555;\"> Please verify your appliance model and manufacturer part number before ordering to ensure compatibility. </p>   <!-- SHIPPING -->   <h2 style=\"font-size:20px; border-bottom:2px solid #ddd; padding-bottom:6px;\"> Shipping Information </h2>   <p style=\"font-size:16px; line-height:1.8;\"> \ud83d\udce6 Ships from <span style=\"color:#0033a0; font-weight:bold;\">Australia</span>     <br> \ud83d\ude9a Sent via <span style=\"color:#d50000; font-weight:bold;\">Australia Post</span>     <br> \u23f1 Delivery Time: <strong>3\u20136 Business Days After Dispatch</strong>   </p>   <p style=\"font-size:13px; color:#666; margin-top:25px;\"> Please verify your appliance model and manufacturer part number before ordering to ensure compatibility. </p> </div>  STRICT RULES: - Output ONLY the raw HTML. No markdown code fences (no ```html or ```), no explanations, no commentary before or after. - Do not change any inline CSS styles, class names, colors, image URLs, or the shipping section text. - Create one <li> per compatible model listed in \"Applies with:\" \u2014 do not merge them into one line. - If multiple part numbers are given, list each as its own <li> under Manufacturer Part Number. - Keep both Product Description paragraphs concise, natural, and specific to the actual product type (don't reuse generic food-processor language). - Never invent compatible models, part numbers, or specifications not present in the input."
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        1312,
        0
      ],
      "id": "9a481454-b11e-4ce8-bde5-d9fc1d782e98",
      "name": "Basic LLM Chain"
    },
    {
      "parameters": {
        "modelName": "models/gemini-3.5-flash-lite",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1.1,
      "position": [
        1312,
        144
      ],
      "id": "2efc4cdd-b9c7-468b-829e-ff5ecf4948c9",
      "name": "Google Gemini Chat Model",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8",
          "mode": "list",
          "cachedResultName": "AI Automation",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fLha0QMHVOXZBv4KPqG3TjkfNMNpOn2fJ3zNobWyhm8/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Images Link": "={{ $json.cleanedHtml }}",
            "row_number": "={{ $('Get row(s) in sheet').item.json.row_number }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Titles",
              "displayName": "Titles",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Images Link",
              "displayName": "Images Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1856,
        0
      ],
      "id": "60e57e34-a46b-44a9-adf0-cad5bb32edcb",
      "name": "Update row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "b8d284a4-03f3-4d1c-afb9-85d90806cb69",
              "leftValue": "={{ $json['Images Link'] }}",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "empty",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.filter",
      "typeVersion": 2.3,
      "position": [
        432,
        0
      ],
      "id": "2bb5e7bb-d4e0-48b2-b918-80b3233b412e",
      "name": "Filter"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        640,
        0
      ],
      "id": "a092ca5f-1531-4522-963f-2f97ce3276f9",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "ad9e6e95-1518-4f4e-8496-e88ef1485e52",
              "name": "Prompt",
              "value": "=Title: {{ $json.Titles }}\nRaw Data: {{ $json.Description }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        896,
        0
      ],
      "id": "baf73f8d-1f9d-4fb4-89b2-fc269410f410",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  let html = item.json.text;\n\n  // Remove ALL variants of escaped newlines (one or more backslashes followed by n)\n  html = html.replace(/\\\\+n/g, ' ');\n\n  // Remove any real newline or carriage return characters too\n  html = html.replace(/[\\r\\n]+/g, ' ');\n\n  // Collapse any resulting multiple spaces into one, for tidiness\n  html = html.replace(/[ \\t]{2,}/g, ' ').trim();\n\n  // Remove markdown code fences if present\n  html = html.replace(/```html/g, '').replace(/```/g, '').trim();\n\n  // Safety: if the output accidentally duplicates, keep only the first full div block\n  const firstOpen = html.indexOf('<div');\n  const lastClose = html.lastIndexOf('</div>');\n  if (firstOpen !== -1 && lastClose !== -1) {\n    html = html.substring(firstOpen, lastClose + 6);\n  }\n\n  return {\n    json: {\n      ...item.json,\n      cleanedHtml: html\n    }\n  };\n});"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1648,
        0
      ],
      "id": "a5a67ebe-a48d-4c15-b38e-56773c758116",
      "name": "Code in JavaScript"
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "170710ae-8fa7-4818-a166-783ac16e921e",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodeGroups": [],
  "id": "7sMasnnjHunowYdK",
  "tags": []
}