feat(n8n-webhook): expand action bus starter workflow

This commit is contained in:
zap
2026-03-12 17:22:58 +00:00
parent 2757527957
commit 9dcc477a98
13 changed files with 386 additions and 97 deletions
+31 -10
View File
@@ -4,7 +4,13 @@ set -euo pipefail
usage() {
cat <<'EOF'
Usage:
scripts/call-action.sh <action> [--args '{"k":"v"}'] [--args-file args.json] [--request-id <id|auto>] [--path openclaw-action] [--test] [--pretty] [--dry-run]
scripts/call-action.sh [action] [--args '{"k":"v"}'] [--args-file args.json] [--request-id <id|auto>] [--path openclaw-action] [--test] [--pretty] [--dry-run]
Notes:
- `action` is optional when --args/--args-file contains a full payload with top-level `action` + `args`.
- `--args` / `--args-file` may contain either:
1) a plain args object, or
2) a full payload object: {"action":"...","args":{...},"request_id":"..."}
Environment:
N8N_ACTION_PATH Default router webhook path (default: openclaw-action)
@@ -14,6 +20,7 @@ Environment:
Examples:
scripts/call-action.sh append_log --args '{"text":"backup complete"}' --request-id auto
scripts/call-action.sh --args-file assets/test-send-email-draft.json --pretty
scripts/call-action.sh notify --args-file notify.json --test --pretty
EOF
}
@@ -84,11 +91,6 @@ while [[ $# -gt 0 ]]; do
esac
done
if [[ -z "$ACTION" ]]; then
usage >&2
exit 2
fi
if [[ ${#EXTRA_ARGS[@]} -gt 0 ]]; then
echo "Unexpected extra arguments: ${EXTRA_ARGS[*]}" >&2
exit 2
@@ -110,13 +112,32 @@ PAYLOAD="$({
python3 - <<'PY' "$ACTION" "$ARGS" "$REQUEST_ID"
import json, sys
action = sys.argv[1]
args = json.loads(sys.argv[2])
request_id = sys.argv[3]
cli_action = sys.argv[1]
raw = json.loads(sys.argv[2])
cli_request_id = sys.argv[3]
if not isinstance(args, dict):
if not isinstance(raw, dict):
raise SystemExit('Action args must decode to a JSON object.')
if 'action' in raw and 'args' in raw:
file_action = raw.get('action', '')
file_args = raw.get('args', {})
file_request_id = raw.get('request_id', '')
if not isinstance(file_args, dict):
raise SystemExit('Full payload args must decode to a JSON object.')
if cli_action and file_action and cli_action != file_action:
raise SystemExit(f'CLI action {cli_action!r} does not match payload action {file_action!r}.')
action = cli_action or file_action
args = file_args
request_id = cli_request_id or file_request_id
else:
action = cli_action
args = raw
request_id = cli_request_id
if not action:
raise SystemExit('Action is required unless provided inside --args/--args-file full payload.')
payload = {
'action': action,
'args': args,