"jsCode":"// Build Prompt — translate the dashboard payload into the system\n// + user messages the AI Agent expects. The agent reads\n// $json.system_message and $json.user_message from the Code node\n// output.\n//\n// Inputs (from webhook body):\n// - options: array of transformation flags the user ticked\n// ['smartWording','newCode','reformatSpecs','addTechnical']\n// - context: { companyLetterhead, customerName, rfqNumber }\n// - items: [{ id, description, notes }]\n//\n// n8n webhook nodes wrap the parsed JSON body under `.body` on the\n// first item — read from $json.body.* and fall back to $json.* so\n// the node also works when invoked from a non-webhook source.\n\nconst src = ($json.body && typeof $json.body === 'object') ? $json.body : $json;\n\nconst options = Array.isArray(src.options) ? src.options : [];\nconst context = src.context || {};\nconst items = Array.isArray(src.items) ? src.items : [];\n\nconst optionLabels = {\n smartWording: 'SMART WORDING',\n newCode: 'NEW UNIQUE PRODUCT CODE',\n reformatSpecs: 'REFORMAT SPECIFICATIONS',\n addTechnical: 'ADD TECHNICAL DETAILS',\n};\nconst tickedList = options\n .filter((o) => optionLabels[o])\n .map((o) => `- ${optionLabels[o]}`)\n .join('\\n');\n\nconst system_message = \"You are rewriting RFQ quote item descriptions for a B2B procurement team at an industrial tools / fluid power distributor. Your rewrites must be commercially sharper \\u2014 every quote should look more complete, more specific, and harder to undercut than a competitor's.\\n\\nOUTPUT FORMAT \\u2014 every rewritten item MUST follow this exact structure:\\n\\n<MAIN PRODUCT LINE \\u2014 the original description, lightly reworded if smartWording is ticked, preserving the original's casing (ALL CAPS stays ALL CAPS, mixed-case stays mixed-case). This is ALWAYS line 1, never a technical clause, never a generated code.>\\n\\n[STRUCTURED BLOCK \\u2014 ONLY include fields where you can derive a value from the original. NEVER use '(unknown)' / '(n/a)' / '-' placeholders \\u2014 if a field has no derivable value, OMIT that line entirely.]\\nBRAND - <value>\\nPART NR - <value or your generated code when newCode is ticked and there's no real OEM number>\\nMODEL - <value>\\nSIZE - <value>\\nPOWER - <value>\\n\\nLayout rules:\\n- Blank line between the MAIN PRODUCT LINE and the structured block.\\n- Blank line between each field inside the structured block (per the buyer's quote-template convention).\\n- Use ' - ' (space-hyphen-space) as the separator between label and value, never ':'.\\n- Use exact labels: BRAND, PART NR, MODEL, SIZE, POWER. Do NOT use 'TYPE'.\\n\\nSMART WORDING \\u2014 make the rewrite commercially distinct without changing facts:\\n- Keep the MAIN PRODUCT LINE recognisable \\u2014 it's the same product, just phrased more sharply.\\n- Embed scope / completeness / use-case language INTO the main line (not as a separate sentence). Examples of the kind of word or phrase that signals 'this quote covers more ground than a competitor's bare line':\\n 'battery operated' \\u2192 'battery-powered, brushless-drive'\\n '3/4\\\" square drive' \\u2192 '3/4\\\" square drive with retaining pin'\\n '150-1400 Nm' \\u2192 '150-1400 Nm torque range'\\n 'hex bolt' \\u2192 'hex-head bolt, grade 8.8 zinc-plated'\\n- Add specificity a casual reader would miss: drive retention, duty cycle, applicable standard, sealing class, repeatable accuracy \\u2014 but ONLY when derivable from the original.\\n- Substantial rewording is expected \\u2014 verbatim copies are NOT acceptable.\\n- NEVER invent accessories or specs. If it's not derivable from the original, don't claim it.\\n\\nNEW UNIQUE PRODUCT CODE \\u2014 generate a fresh code in the format \\\"BRAND-INITIALS-NNN\\\" (e.g. \\\"MX-9920A\\\", \\\"BT-0816P\\\", \\\"TW-3340C\\\"):\\n- NEVER use a real OEM part-number pattern (all-digits like \\\"2203FS\\\", or hyphenated digit-letter combos like \\\"WP-411\\\").\\n-DONOTprependthecodetothemainline.Instead:\\n-IfPARTNRisempty(norealOEMnumber),putthegenerat