{ "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": [] }