fix: revert to Set nodes instead of Code nodes for reliability
- Extract node: Use Set node with proper field mappings - Parse node: Use Set node with try-catch error handling for JSON parsing - Set nodes are more stable and better supported in n8n - Both nodes now handle data transformation without code execution issues
This commit is contained in:
@@ -32,11 +32,40 @@
|
||||
{
|
||||
"id": "uuid-extract-data",
|
||||
"name": "Extract Conversation Data",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3,
|
||||
"position": [650, 200],
|
||||
"parameters": {
|
||||
"functionCode": "const data = $input.all()[0].json.data;\nreturn data.map(item => ({\njson: {\nticket_id: item.id,\nticket_number: item.number,\nsubject: item.subject,\nproblem_text: (item.threads_text || 'No description provided').substring(0, 2000),\ncustomer_email: item.customer_email\n}\n}));"
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"name": "ticket_id",
|
||||
"value": "={{ $json.id }}",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "ticket_number",
|
||||
"value": "={{ $json.number }}",
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"name": "subject",
|
||||
"value": "={{ $json.subject }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "problem_text",
|
||||
"value": "={{ ($json.threads_text || 'No description provided').substring(0, 2000) }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "customer_email",
|
||||
"value": "={{ $json.customer_email }}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -59,11 +88,30 @@
|
||||
{
|
||||
"id": "uuid-parse-response",
|
||||
"name": "Parse AI Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3,
|
||||
"position": [1050, 200],
|
||||
"parameters": {
|
||||
"functionCode": "const content = $json.choices?.[0]?.message?.content || '{}';\nlet aiResponse = {};\ntry {\naiResponse = JSON.parse(content);\n} catch(e) {\naiResponse = {kategorie: 'unknown', lösung_typ: 'ESKALATION', vertrauen: 0.3, antwort_text: 'Fehler bei der Analyse'};\n}\nreturn {json: {...$json, response_text: content, ai_response: aiResponse, vertrauen: aiResponse.vertrauen || 0.3}};"
|
||||
"options": {},
|
||||
"assignments": {
|
||||
"assignments": [
|
||||
{
|
||||
"name": "response_text",
|
||||
"value": "={{ $json.choices?.[0]?.message?.content || '{}' }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "ai_response",
|
||||
"value": "={{ (function() { try { return JSON.parse($json.response_text); } catch(e) { return {kategorie: 'unknown', lösung_typ: 'ESKALATION', vertrauen: 0.3}; } })() }}",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"name": "vertrauen",
|
||||
"value": "={{ $json.ai_response?.vertrauen || 0.3 }}",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user