n8n_stack/imports/workflows/ollama-chat-cleanup.json
dschlueter 60143b8061 feat: Chatbot-Workflows mit Ollama-Memory und Session-Management
- docker-compose: extra_hosts für host.docker.internal (Ollama-Zugang)
- ollama-chatbot: Gesprächsverlauf per session_id in PostgreSQL
- ollama-chat-cleanup: stündliche TTL-Bereinigung (2h Inaktivität)
- ollama-chat-delete: DELETE /webhook/chat-session Endpoint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 02:44:13 +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": "SETUP_REQUIRED",
"name": "n8n PostgreSQL"
}
}
},
{
"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": []
}