feat(n8n): add get-logs action

This commit is contained in:
zap
2026-03-12 16:45:19 +00:00
parent c1f851b451
commit aa0914f734
6 changed files with 90 additions and 22 deletions

View File

@@ -10,8 +10,9 @@ It implements a real local OpenClaw → n8n router.
- accepts `POST /webhook/openclaw-action`
- normalizes incoming JSON into an action contract
- supports two live actions:
- supports three live actions:
- `append_log`
- `get_logs`
- `notify`
- returns normalized JSON responses
- returns `400` for unknown actions
@@ -32,6 +33,24 @@ Example stored record:
{"ts":"2026-03-12T07:00:00Z","source":"openclaw-action","request_id":"abc","text":"backup complete"}
```
### `get_logs`
- reads from workflow static data key:
- `actionLog`
- returns newest-first
- default `limit` is `20`
- clamps `limit` to `1..50`
### `notify`
- sends a Telegram message using credential:
- `Telegram Bot (OpenClaw)`
- sends a Discord message using credential:
- `Discord Bot Auth`
- current targets mirror the already-working reminder workflow
## Why workflow static data for logs
Why this first:
- built-in, no extra credentials
- persists without guessing writable filesystem paths
@@ -43,14 +62,6 @@ When to use MinIO later:
- large/batched exports
- sharing logs outside n8n
### `notify`
- sends a Telegram message using credential:
- `Telegram Bot (OpenClaw)`
- sends a Discord message using credential:
- `Discord Bot Auth`
- current targets mirror the already-working reminder workflow
## Intentional security choice
The exported workflow leaves the Webhook node auth unset in the JSON file.
@@ -92,6 +103,7 @@ After import, set this manually in n8n:
```bash
export N8N_WEBHOOK_SECRET='YOUR_SECRET_HERE'
scripts/call-action.sh append_log --args '{"text":"backup complete"}' --pretty
scripts/call-action.sh get_logs --args '{"limit":5}' --pretty
scripts/call-action.sh notify --args '{"title":"Workflow finished","message":"n8n router test"}' --pretty
```
@@ -118,6 +130,30 @@ scripts/call-action.sh notify --args '{"title":"Workflow finished","message":"n8
}
```
### get_logs
```json
{
"ok": true,
"request_id": "",
"result": {
"action": "get_logs",
"status": "ok",
"count": 1,
"total_retained": 1,
"retained_entries": 200,
"entries": [
{
"ts": "2026-03-12T08:42:37.615Z",
"source": "openclaw-action",
"request_id": "live-log-003",
"text": "n8n append_log static-data verification"
}
]
}
}
```
### notify
```json