app.bettersight.io/n8n/workflows/daily_digest.json

97 lines
3.2 KiB
JSON

{
"name": "Bettersight — Daily Digest (6pm)",
"nodes": [
{
"parameters": {
"rule": {
"interval": [{ "field": "cronExpression", "expression": "0 18 * * *" }]
}
},
"id": "schedule-trigger",
"name": "Schedule Trigger (18:00 daily)",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [0, 0]
},
{
"parameters": {
"method": "GET",
"url": "={{ $env.POCKETBASE_URL }}/api/collections/tenants/records",
"sendQuery": true,
"queryParameters": {
"parameters": [
{ "name": "filter", "value": "status = 'active' || status = 'trial'" },
{ "name": "perPage", "value": "200" }
]
},
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth"
},
"id": "list-active-tenants",
"name": "List active tenants (PocketBase)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [220, 0],
"credentials": {
"httpHeaderAuth": { "id": "pocketbase-admin-auth", "name": "PocketBase Admin Auth" }
}
},
{
"parameters": { "fieldToSplitOut": "items" },
"id": "split-tenants",
"name": "Split into items",
"type": "n8n-nodes-base.splitOut",
"typeVersion": 1,
"position": [440, 0]
},
{
"parameters": { "batchSize": 1 },
"id": "loop-tenants",
"name": "Loop Over Tenants",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [660, 0]
},
{
"parameters": {
"method": "POST",
"url": "={{ $env.BETTERSIGHT_API_BASE_URL }}/internal/daily-digest/{{ $json.id }}",
"sendHeaders": true,
"headerParameters": {
"parameters": [{ "name": "X-API-Key", "value": "={{ $env.API_SECRET_KEY }}" }]
}
},
"id": "trigger-digest",
"name": "POST /internal/daily-digest/{tenant_id}",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [880, 0]
}
],
"connections": {
"Schedule Trigger (18:00 daily)": {
"main": [[{ "node": "List active tenants (PocketBase)", "type": "main", "index": 0 }]]
},
"List active tenants (PocketBase)": {
"main": [[{ "node": "Split into items", "type": "main", "index": 0 }]]
},
"Split into items": {
"main": [[{ "node": "Loop Over Tenants", "type": "main", "index": 0 }]]
},
"Loop Over Tenants": {
"main": [
[],
[{ "node": "POST /internal/daily-digest/{tenant_id}", "type": "main", "index": 0 }]
]
},
"POST /internal/daily-digest/{tenant_id}": {
"main": [[{ "node": "Loop Over Tenants", "type": "main", "index": 0 }]]
}
},
"active": false,
"settings": { "executionOrder": "v1" },
"meta": {
"description": "CLAUDE.md §15 daily digest — one Flask call per active tenant at 6pm. All the real logic (which alerts to include, rendering, sending, marking delivered_email) lives in services/alert_service.py's send_daily_digest(); this workflow only iterates tenants and triggers it. Not yet imported/run against a live n8n instance."
}
}