From be2068b7e44f8d143ccb99f48c96136bbc7a9d0f Mon Sep 17 00:00:00 2001 From: Claude Code Date: Tue, 17 Mar 2026 11:29:32 +0100 Subject: [PATCH] fix: add error handling and fallback values in Parse AI Response node - Add optional chaining (?.) for safe navigation of response properties - Add fallback values if response fields are missing - Extract vertrauen field directly in Parse node for easier reference - Update Check Confidence node to reference $json.vertrauen instead of nested path - Handles cases where LLM response format is unexpected --- n8n-workflows/workflow-a-http.json | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/n8n-workflows/workflow-a-http.json b/n8n-workflows/workflow-a-http.json index cabafc9..2ccc5cc 100644 --- a/n8n-workflows/workflow-a-http.json +++ b/n8n-workflows/workflow-a-http.json @@ -110,13 +110,18 @@ "assignments": [ { "name": "response_text", - "value": "={{ $json.choices[0].message.content }}", + "value": "={{ $json.choices?.[0]?.message?.content || '{}' }}", "type": "string" }, { "name": "ai_response", - "value": "={{ JSON.parse($json.response_text) }}", + "value": "={{ typeof $json.response_text === 'string' ? JSON.parse($json.response_text) : $json.response_text }}", "type": "object" + }, + { + "name": "vertrauen", + "value": "={{ $json.ai_response?.vertrauen || 0.5 }}", + "type": "number" } ] } @@ -138,7 +143,7 @@ "conditions": [ { "id": "condition_1", - "leftValue": "={{ $json.ai_response.vertrauen }}", + "leftValue": "={{ $json.vertrauen }}", "rightValue": 0.6, "operator": { "name": "filter.operator.gte", @@ -183,7 +188,7 @@ }, { "name": "reason", - "value": "Confidence {{$json.ai_response.vertrauen}} < 0.6", + "value": "Confidence {{$json.vertrauen}} < 0.6", "type": "string" } ]