n8n_stack/imports/workflows/ollama-chat-cleanup.json
dschlueter a14ea92dad fix: Chatbot-Workflows korrigiert und Memory-Bug behoben
- Inline SQL-Expressions statt queryParams (Postgres-Node-Kompatibilität)
- CTE-Query garantiert immer eine Zeile (verhindert Abbruch bei neuer Session)
- Delete-Workflow ebenfalls auf inline SQL umgestellt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 03:57:34 +02:00

53 lines
1.6 KiB
JSON

{
"id": "1002",
"name": "Chatbot Session Cleanup (TTL 2h)",
"nodes": [
{
"parameters": {
"rule": {
"interval": [{ "field": "hours", "hoursInterval": 1 }]
}
},
"id": "node-sc-001",
"name": "Jede Stunde",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [100, 300]
},
{
"parameters": {
"operation": "executeQuery",
"query": "DELETE FROM chat_sessions WHERE updated_at < NOW() - INTERVAL '2 hours' RETURNING session_id",
"additionalFields": {}
},
"id": "node-pg-003",
"name": "Delete Expired Sessions",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.5,
"position": [300, 300],
"credentials": {
"postgres": {
"id": "pnmeNZ3ONDWrQP8M",
"name": "Postgres account"
}
}
},
{
"parameters": {
"jsCode": "const deleted = $input.all().map(i => i.json.session_id).filter(Boolean);\nconsole.log(`[Cleanup] ${deleted.length} Session(s) gelöscht:`, deleted);\nreturn [{ json: { deleted_count: deleted.length, deleted_sessions: deleted } }];"
},
"id": "node-cd-004",
"name": "Log Result",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [500, 300]
}
],
"connections": {
"Jede Stunde": { "main": [[{ "node": "Delete Expired Sessions", "type": "main", "index": 0 }]] },
"Delete Expired Sessions": { "main": [[{ "node": "Log Result", "type": "main", "index": 0 }]] }
},
"active": false,
"settings": { "executionOrder": "v1" },
"tags": []
}