n8n/workflows/wiki-compile-nudge.json
Travis Herbranson 51f50b4704 feat: add wiki-compile-nudge workflow + document it
Daily Google Chat nudge when wiki-vault is due for a compile (>=10 new
sources or >=7 days stale). Drift query against petalbrain; needs a
wiki.compile_runs table + post-import credential/webhook wiring.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 22:21:46 -04:00

86 lines
3.0 KiB
JSON

{
"name": "wiki-compile-nudge",
"nodes": [
{
"parameters": {
"rule": {
"interval": [
{ "field": "cronExpression", "expression": "7 20 * * *" }
]
}
},
"id": "schedule-trigger",
"name": "Daily @ 20:07",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [260, 300]
},
{
"parameters": {
"operation": "executeQuery",
"query": "WITH last AS (\n SELECT COALESCE(max(compiled_at), 'epoch') AS ts FROM wiki.compile_runs\n),\nn AS (\n SELECT count(*) AS c FROM wiki.artifacts WHERE created_at > (SELECT ts FROM last)\n)\nSELECT\n (SELECT c FROM n) AS new_sources,\n EXTRACT(day FROM now() - (SELECT ts FROM last))::int AS days_since,\n (\n (SELECT c FROM n) >= 10\n OR (EXTRACT(day FROM now() - (SELECT ts FROM last)) >= 7 AND (SELECT c FROM n) >= 1)\n ) AS should_notify;",
"options": {}
},
"id": "postgres-drift",
"name": "Drift query (petalbrain)",
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.5,
"position": [480, 300],
"credentials": {
"postgres": { "id": "REPLACE_WITH_PETALBRAIN_CRED_ID", "name": "Petalbrain Postgres" }
}
},
{
"parameters": {
"conditions": {
"options": { "caseSensitive": true, "typeValidation": "strict", "version": 2 },
"combinator": "and",
"conditions": [
{
"leftValue": "={{ $json.should_notify }}",
"rightValue": true,
"operator": { "type": "boolean", "operation": "true", "singleValue": true }
}
]
},
"options": {}
},
"id": "if-should-notify",
"name": "Compile due?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [700, 300]
},
{
"parameters": {
"method": "POST",
"url": "REPLACE_WITH_GOOGLE_CHAT_SPACE_WEBHOOK_URL",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\n \"text\": \"\\ud83c\\udf3f Wiki compile due \\u2014 {{ $json.new_sources }} new sources, {{ $json.days_since }}d since last compile.\\nRun: \\\"compile the wiki at /opt/projects/wiki-vault\\\"\"\n}",
"options": {}
},
"id": "google-chat-notify",
"name": "Google Chat nudge",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [920, 220]
}
],
"connections": {
"Daily @ 20:07": {
"main": [[{ "node": "Drift query (petalbrain)", "type": "main", "index": 0 }]]
},
"Drift query (petalbrain)": {
"main": [[{ "node": "Compile due?", "type": "main", "index": 0 }]]
},
"Compile due?": {
"main": [
[{ "node": "Google Chat nudge", "type": "main", "index": 0 }],
[]
]
}
},
"settings": { "executionOrder": "v1" }
}