From 77c3d6543ddd0c2a64ce67c3f193d411535c0a4b Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Wed, 4 Feb 2026 16:00:07 -0500 Subject: [PATCH] fix(10-07): add fuzzy matching to logs and fix chatId reference - Send Logs Response now uses Prepare Text Logs Input for chatId - Container logs sub-workflow uses .includes() for fuzzy matching - Multiple match handling added with helpful error message --- n8n-container-logs.json | 2 +- n8n-workflow.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/n8n-container-logs.json b/n8n-container-logs.json index e596ea1..1763370 100644 --- a/n8n-container-logs.json +++ b/n8n-container-logs.json @@ -95,7 +95,7 @@ }, { "parameters": { - "jsCode": "// Find container by name\nconst dockerOutput = $input.item.json.stdout;\nconst data = $('Check Container ID').item.json;\nconst containerName = data.containerName.toLowerCase();\n\n// Parse Docker response\nlet containers;\ntry {\n containers = JSON.parse(dockerOutput);\n} catch (e) {\n throw new Error('Failed to parse Docker response');\n}\n\n// Normalize name function\nfunction normalizeName(name) {\n return name\n .replace(/^\\//, '')\n .replace(/^(linuxserver[-_]|binhex[-_])/i, '')\n .toLowerCase();\n}\n\n// Find exact match\nconst container = containers.find(c => normalizeName(c.Names[0]) === containerName);\n\nif (!container) {\n throw new Error(`Container \"${containerName}\" not found`);\n}\n\nreturn {\n json: {\n ...data,\n containerId: container.Id,\n containerName: normalizeName(container.Names[0])\n }\n};" + "jsCode": "// Find container by name (supports fuzzy matching)\nconst dockerOutput = $input.item.json.stdout;\nconst data = $('Check Container ID').item.json;\nconst containerName = data.containerName.toLowerCase();\n\n// Parse Docker response\nlet containers;\ntry {\n containers = JSON.parse(dockerOutput);\n} catch (e) {\n throw new Error('Failed to parse Docker response');\n}\n\n// Normalize name function\nfunction normalizeName(name) {\n return name\n .replace(/^\\//, '')\n .replace(/^(linuxserver[-_]|binhex[-_])/i, '')\n .toLowerCase();\n}\n\n// Find containers that match (fuzzy - includes search term)\nconst matches = containers.filter(c => normalizeName(c.Names[0]).includes(containerName));\n\nif (matches.length === 0) {\n throw new Error(`Container \"${containerName}\" not found`);\n}\n\nif (matches.length > 1) {\n const matchNames = matches.map(c => normalizeName(c.Names[0])).join(', ');\n throw new Error(`Multiple containers match \"${containerName}\": ${matchNames}`);\n}\n\nconst container = matches[0];\n\nreturn {\n json: {\n ...data,\n containerId: container.Id,\n containerName: normalizeName(container.Names[0])\n }\n};" }, "id": "52dd705b-dd3b-4fdc-8484-276845857ad0", "name": "Find Container", diff --git a/n8n-workflow.json b/n8n-workflow.json index 8c87b31..52a3d8a 100644 --- a/n8n-workflow.json +++ b/n8n-workflow.json @@ -1798,7 +1798,7 @@ "parameters": { "resource": "message", "operation": "sendMessage", - "chatId": "={{ $json.chatId }}", + "chatId": "={{ $('Prepare Text Logs Input').item.json.chatId }}", "text": "={{ $json.message }}", "additionalFields": { "parse_mode": "HTML"