feat(n8n-webhook): add calendar list update delete approval flows
This commit is contained in:
@@ -40,6 +40,9 @@ Keep the integration narrow: let OpenClaw decide what to do, and let n8n execute
|
||||
- `assets/test-send-gmail-draft.json`
|
||||
- `assets/test-send-approved-email.json`
|
||||
- `assets/test-create-calendar-event.json`
|
||||
- `assets/test-list-upcoming-events.json`
|
||||
- `assets/test-update-calendar-event.json`
|
||||
- `assets/test-delete-calendar-event.json`
|
||||
|
||||
## Quick usage
|
||||
|
||||
@@ -61,6 +64,7 @@ Call the preferred action-bus route:
|
||||
scripts/call-action.sh append_log --args '{"text":"backup complete"}' --request-id auto
|
||||
scripts/call-action.sh get_logs --args '{"limit":5}' --pretty
|
||||
scripts/call-action.sh list_email_drafts --args '{"max":10}' --pretty
|
||||
scripts/call-action.sh list_upcoming_events --args '{"days":7,"max":10}' --pretty
|
||||
```
|
||||
|
||||
Call a test webhook while editing a flow:
|
||||
@@ -115,7 +119,10 @@ Use the included workflow asset when you want a ready-made local router for:
|
||||
- `list_email_drafts` → queue approval-gated Gmail draft list requests (read-only, low mutation level)
|
||||
- `delete_email_draft` → queue approval-gated Gmail draft deletion requests
|
||||
- `send_gmail_draft` (alias: `send_approved_email`) → queue approval-gated Gmail draft send requests
|
||||
- `create_calendar_event` → queue approval-gated calendar proposals in workflow static data
|
||||
- `create_calendar_event` → queue approval-gated calendar creation proposals in workflow static data
|
||||
- `list_upcoming_events` → queue approval-gated calendar event listing requests (read-only, low mutation level)
|
||||
- `update_calendar_event` → queue approval-gated calendar event update requests
|
||||
- `delete_calendar_event` → queue approval-gated calendar event deletion requests
|
||||
- `approval_queue_add` / `approval_queue_list` / `approval_queue_resolve` → manage pending approvals and recent history
|
||||
- `approval_history_attach_execution` → let a host-side executor attach real execution metadata back onto approval history entries
|
||||
- `fetch_and_normalize_url` → fetch + normalize URL content using n8n runtime HTTP helpers
|
||||
@@ -144,6 +151,9 @@ Supported host-executed approval kinds:
|
||||
- `email_draft_delete` → `gog gmail drafts delete`
|
||||
- `email_draft_send` → `gog gmail drafts send`
|
||||
- `calendar_event` → `gog calendar create`
|
||||
- `calendar_list_events` → `gog calendar events`
|
||||
- `calendar_event_update` → `gog calendar update`
|
||||
- `calendar_event_delete` → `gog calendar delete`
|
||||
|
||||
Practical note:
|
||||
- unattended execution needs `GOG_KEYRING_PASSWORD` available to the executor because `gog`'s file keyring cannot prompt in non-TTY automation
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"action": "delete_calendar_event",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"event_id": "example-calendar-event-id",
|
||||
"send_updates": "none"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"action": "list_upcoming_events",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"days": 7,
|
||||
"max": 10,
|
||||
"query": "zap"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"action": "update_calendar_event",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"event_id": "example-calendar-event-id",
|
||||
"title": "Updated call with vendor",
|
||||
"start": "2026-03-13T18:15:00Z",
|
||||
"end": "2026-03-13T18:45:00Z",
|
||||
"location": "Updated room",
|
||||
"description": "Updated by OpenClaw action bus.",
|
||||
"send_updates": "none"
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,9 @@ It implements a real local OpenClaw → n8n router.
|
||||
- `delete_email_draft`
|
||||
- `send_gmail_draft` (alias: `send_approved_email`)
|
||||
- `create_calendar_event`
|
||||
- `list_upcoming_events`
|
||||
- `update_calendar_event`
|
||||
- `delete_calendar_event`
|
||||
- `approval_queue_add`
|
||||
- `approval_queue_list`
|
||||
- `approval_queue_resolve`
|
||||
@@ -60,6 +63,9 @@ Actions:
|
||||
- `delete_email_draft`
|
||||
- `send_gmail_draft` (alias: `send_approved_email`)
|
||||
- `create_calendar_event`
|
||||
- `list_upcoming_events`
|
||||
- `update_calendar_event`
|
||||
- `delete_calendar_event`
|
||||
|
||||
Behavior:
|
||||
- queue proposals into workflow static data under key:
|
||||
@@ -70,10 +76,10 @@ Behavior:
|
||||
- are intended for host-side execution via the included `gog` bridge after explicit approval resolution
|
||||
|
||||
Approval policy defaults:
|
||||
- `send_email_draft`, `delete_email_draft`, `send_gmail_draft` / `send_approved_email`, `create_calendar_event`
|
||||
- `send_email_draft`, `delete_email_draft`, `send_gmail_draft` / `send_approved_email`, `create_calendar_event`, `update_calendar_event`, `delete_calendar_event`
|
||||
- `approval.required = true`
|
||||
- `approval.mutation_level = "high"`
|
||||
- `list_email_drafts`
|
||||
- `list_email_drafts`, `list_upcoming_events`
|
||||
- `approval.required = true`
|
||||
- `approval.mutation_level = "low"` (read-only action, still routed through approval queue for explicit operator acknowledgement + audit trail)
|
||||
|
||||
@@ -172,6 +178,9 @@ After import, set this manually in n8n:
|
||||
- `assets/test-send-gmail-draft.json`
|
||||
- `assets/test-send-approved-email.json`
|
||||
- `assets/test-create-calendar-event.json`
|
||||
- `assets/test-list-upcoming-events.json`
|
||||
- `assets/test-update-calendar-event.json`
|
||||
- `assets/test-delete-calendar-event.json`
|
||||
- `assets/test-fetch-and-normalize-url.json`
|
||||
- `assets/test-approval-queue-list.json`
|
||||
- `assets/test-inbound-event-filter.json`
|
||||
@@ -190,6 +199,9 @@ scripts/call-action.sh delete_email_draft --args-file assets/test-delete-email-d
|
||||
scripts/call-action.sh send_gmail_draft --args-file assets/test-send-gmail-draft.json --pretty
|
||||
scripts/call-action.sh send_approved_email --args-file assets/test-send-approved-email.json --pretty
|
||||
scripts/call-action.sh create_calendar_event --args-file assets/test-create-calendar-event.json --pretty
|
||||
scripts/call-action.sh list_upcoming_events --args-file assets/test-list-upcoming-events.json --pretty
|
||||
scripts/call-action.sh update_calendar_event --args-file assets/test-update-calendar-event.json --pretty
|
||||
scripts/call-action.sh delete_calendar_event --args-file assets/test-delete-calendar-event.json --pretty
|
||||
scripts/call-action.sh fetch_and_normalize_url --args '{"url":"http://192.168.153.113:18808/healthz"}' --pretty
|
||||
scripts/call-action.sh fetch_and_normalize_url --args '{"url":"https://example.com","skip_ssl_certificate_validation":true}' --pretty
|
||||
scripts/call-action.sh approval_queue_list --args '{"limit":10,"include_history":true}' --pretty
|
||||
@@ -295,6 +307,56 @@ python3 scripts/resolve-approval-with-gog.py --id <approval-id> --decision appro
|
||||
}
|
||||
```
|
||||
|
||||
### list_upcoming_events
|
||||
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"request_id": "test-list-calendar-events-001",
|
||||
"result": {
|
||||
"action": "list_upcoming_events",
|
||||
"status": "queued_for_approval",
|
||||
"pending_id": "approval-pqr678",
|
||||
"approval_status": "pending",
|
||||
"approval": {
|
||||
"policy": "approval_queue_resolve",
|
||||
"required": true,
|
||||
"mutation_level": "low"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### update_calendar_event
|
||||
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"request_id": "test-update-calendar-event-001",
|
||||
"result": {
|
||||
"action": "update_calendar_event",
|
||||
"status": "queued_for_approval",
|
||||
"pending_id": "approval-stu901",
|
||||
"approval_status": "pending"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### delete_calendar_event
|
||||
|
||||
```json
|
||||
{
|
||||
"ok": true,
|
||||
"request_id": "test-delete-calendar-event-001",
|
||||
"result": {
|
||||
"action": "delete_calendar_event",
|
||||
"status": "queued_for_approval",
|
||||
"pending_id": "approval-vwx234",
|
||||
"approval_status": "pending"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### fetch_and_normalize_url
|
||||
|
||||
```json
|
||||
@@ -339,6 +401,9 @@ Behavior:
|
||||
- `email_draft_delete` → `gog gmail drafts delete`
|
||||
- `email_draft_send` → `gog gmail drafts send`
|
||||
- `calendar_event` → `gog calendar create`
|
||||
- `calendar_list_events` → `gog calendar events`
|
||||
- `calendar_event_update` → `gog calendar update`
|
||||
- `calendar_event_delete` → `gog calendar delete`
|
||||
- writes execution metadata back via `approval_history_attach_execution`
|
||||
|
||||
Important automation note:
|
||||
|
||||
@@ -250,6 +250,80 @@ Sink:
|
||||
- key: `approvalQueue`
|
||||
- retained entries: `200`
|
||||
|
||||
### `list_upcoming_events`
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "list_upcoming_events",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"days": 7,
|
||||
"max": 10,
|
||||
"query": "zap"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Purpose:
|
||||
- queue a host-side upcoming calendar event listing request for approval/audit
|
||||
- defaults to the next `7` days when no explicit `from`/`to` window is provided
|
||||
|
||||
Approval policy:
|
||||
- required: `true`
|
||||
- mutation level: `low` (read-only)
|
||||
|
||||
### `update_calendar_event`
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "update_calendar_event",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"event_id": "example-calendar-event-id",
|
||||
"title": "Updated call with vendor",
|
||||
"start": "2026-03-13T18:15:00Z",
|
||||
"end": "2026-03-13T18:45:00Z",
|
||||
"location": "Updated room",
|
||||
"description": "Updated by OpenClaw action bus.",
|
||||
"send_updates": "none"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Purpose:
|
||||
- queue an update to an existing calendar event behind explicit approval
|
||||
- requires `event_id` and at least one patch field (`title`, `start`, `end`, `location`, `description`, or `attendees`)
|
||||
|
||||
Approval policy:
|
||||
- required: `true`
|
||||
- mutation level: `high`
|
||||
|
||||
### `delete_calendar_event`
|
||||
|
||||
Request:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "delete_calendar_event",
|
||||
"args": {
|
||||
"calendar": "primary",
|
||||
"event_id": "example-calendar-event-id",
|
||||
"send_updates": "none"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Purpose:
|
||||
- queue deletion of an existing calendar event behind explicit approval
|
||||
|
||||
Approval policy:
|
||||
- required: `true`
|
||||
- mutation level: `high`
|
||||
|
||||
### `approval_queue_add`
|
||||
|
||||
Request:
|
||||
|
||||
@@ -199,7 +199,16 @@ def build_email_drafts_list_command(item: dict, account: str, dry_run: bool):
|
||||
return cmd
|
||||
|
||||
|
||||
def build_calendar_command(item: dict, account: str, dry_run: bool):
|
||||
def normalize_send_updates(value: str) -> str:
|
||||
raw = (value or '').strip()
|
||||
if raw == 'all':
|
||||
return 'all'
|
||||
if raw.lower() == 'externalonly':
|
||||
return 'externalOnly'
|
||||
return 'none'
|
||||
|
||||
|
||||
def build_calendar_create_command(item: dict, account: str, dry_run: bool):
|
||||
payload = item.get('payload') or {}
|
||||
calendar = payload.get('calendar') or 'primary'
|
||||
cmd = [
|
||||
@@ -210,7 +219,7 @@ def build_calendar_command(item: dict, account: str, dry_run: bool):
|
||||
'--summary', payload.get('title') or '',
|
||||
'--from', payload.get('start') or '',
|
||||
'--to', payload.get('end') or '',
|
||||
'--send-updates', 'none',
|
||||
'--send-updates', normalize_send_updates(payload.get('send_updates') or 'none'),
|
||||
]
|
||||
if payload.get('description'):
|
||||
cmd.extend(['--description', payload['description']])
|
||||
@@ -224,6 +233,104 @@ def build_calendar_command(item: dict, account: str, dry_run: bool):
|
||||
return cmd
|
||||
|
||||
|
||||
def build_calendar_list_events_command(item: dict, account: str, dry_run: bool):
|
||||
payload = item.get('payload') or {}
|
||||
calendar = (payload.get('calendar') or 'primary').strip() or 'primary'
|
||||
max_results = payload.get('max')
|
||||
if max_results is None:
|
||||
max_results = 20
|
||||
try:
|
||||
max_results = max(1, min(100, int(max_results)))
|
||||
except Exception:
|
||||
max_results = 20
|
||||
|
||||
days = payload.get('days')
|
||||
if days is None:
|
||||
days = 7
|
||||
try:
|
||||
days = max(1, min(90, int(days)))
|
||||
except Exception:
|
||||
days = 7
|
||||
|
||||
cmd = [
|
||||
'gog', 'calendar', 'events', calendar,
|
||||
'--account', account,
|
||||
'--json',
|
||||
'--no-input',
|
||||
'--max', str(max_results),
|
||||
]
|
||||
from_value = (payload.get('from') or '').strip()
|
||||
to_value = (payload.get('to') or '').strip()
|
||||
query = (payload.get('query') or '').strip()
|
||||
if from_value:
|
||||
cmd.extend(['--from', from_value])
|
||||
if to_value:
|
||||
cmd.extend(['--to', to_value])
|
||||
if not from_value and not to_value:
|
||||
cmd.extend(['--days', str(days)])
|
||||
if query:
|
||||
cmd.extend(['--query', query])
|
||||
if payload.get('all_pages') is True:
|
||||
cmd.append('--all-pages')
|
||||
if payload.get('fail_empty') is True:
|
||||
cmd.append('--fail-empty')
|
||||
if dry_run:
|
||||
cmd.append('--dry-run')
|
||||
return cmd
|
||||
|
||||
|
||||
def build_calendar_update_command(item: dict, account: str, dry_run: bool):
|
||||
payload = item.get('payload') or {}
|
||||
calendar = (payload.get('calendar') or 'primary').strip() or 'primary'
|
||||
event_id = (payload.get('event_id') or payload.get('id') or '').strip()
|
||||
if not event_id:
|
||||
fail('calendar_event_update payload missing event_id')
|
||||
cmd = [
|
||||
'gog', 'calendar', 'update', calendar, event_id,
|
||||
'--account', account,
|
||||
'--json',
|
||||
'--no-input',
|
||||
'--send-updates', normalize_send_updates(payload.get('send_updates') or 'none'),
|
||||
]
|
||||
if payload.get('title'):
|
||||
cmd.extend(['--summary', payload['title']])
|
||||
if payload.get('start'):
|
||||
cmd.extend(['--from', payload['start']])
|
||||
if payload.get('end'):
|
||||
cmd.extend(['--to', payload['end']])
|
||||
if payload.get('description'):
|
||||
cmd.extend(['--description', payload['description']])
|
||||
if payload.get('location'):
|
||||
cmd.extend(['--location', payload['location']])
|
||||
attendees = payload.get('attendees')
|
||||
if isinstance(attendees, list):
|
||||
cmd.extend(['--attendees', ','.join(str(x) for x in attendees if str(x).strip())])
|
||||
elif isinstance(attendees, str) and attendees.strip():
|
||||
cmd.extend(['--attendees', attendees.strip()])
|
||||
if dry_run:
|
||||
cmd.append('--dry-run')
|
||||
return cmd
|
||||
|
||||
|
||||
def build_calendar_delete_command(item: dict, account: str, dry_run: bool):
|
||||
payload = item.get('payload') or {}
|
||||
calendar = (payload.get('calendar') or 'primary').strip() or 'primary'
|
||||
event_id = (payload.get('event_id') or payload.get('id') or '').strip()
|
||||
if not event_id:
|
||||
fail('calendar_event_delete payload missing event_id')
|
||||
cmd = [
|
||||
'gog', 'calendar', 'delete', calendar, event_id,
|
||||
'--account', account,
|
||||
'--json',
|
||||
'--no-input',
|
||||
'--force',
|
||||
'--send-updates', normalize_send_updates(payload.get('send_updates') or 'none'),
|
||||
]
|
||||
if dry_run:
|
||||
cmd.append('--dry-run')
|
||||
return cmd
|
||||
|
||||
|
||||
def parse_json(output: str):
|
||||
text = output.strip()
|
||||
if not text:
|
||||
@@ -299,11 +406,29 @@ def main():
|
||||
'uses_tmpfile': False,
|
||||
},
|
||||
'calendar_event': {
|
||||
'builder': build_calendar_command,
|
||||
'builder': build_calendar_create_command,
|
||||
'op': 'calendar.create',
|
||||
'success_status': 'event_created',
|
||||
'uses_tmpfile': False,
|
||||
},
|
||||
'calendar_list_events': {
|
||||
'builder': build_calendar_list_events_command,
|
||||
'op': 'calendar.events.list',
|
||||
'success_status': 'events_listed',
|
||||
'uses_tmpfile': False,
|
||||
},
|
||||
'calendar_event_update': {
|
||||
'builder': build_calendar_update_command,
|
||||
'op': 'calendar.update',
|
||||
'success_status': 'event_updated',
|
||||
'uses_tmpfile': False,
|
||||
},
|
||||
'calendar_event_delete': {
|
||||
'builder': build_calendar_delete_command,
|
||||
'op': 'calendar.delete',
|
||||
'success_status': 'event_deleted',
|
||||
'uses_tmpfile': False,
|
||||
},
|
||||
}
|
||||
|
||||
spec = executors.get(kind)
|
||||
|
||||
@@ -31,6 +31,9 @@ SAMPLE_FILES = [
|
||||
'test-send-gmail-draft.json',
|
||||
'test-send-approved-email.json',
|
||||
'test-create-calendar-event.json',
|
||||
'test-list-upcoming-events.json',
|
||||
'test-update-calendar-event.json',
|
||||
'test-delete-calendar-event.json',
|
||||
'test-fetch-and-normalize-url.json',
|
||||
'test-approval-queue-list.json',
|
||||
'test-inbound-event-filter.json',
|
||||
@@ -47,6 +50,9 @@ ROUTER_SNIPPETS = [
|
||||
'send_gmail_draft',
|
||||
'send_approved_email',
|
||||
'create_calendar_event',
|
||||
'list_upcoming_events',
|
||||
'update_calendar_event',
|
||||
'delete_calendar_event',
|
||||
'approval_queue_add',
|
||||
'approval_queue_list',
|
||||
'approval_queue_resolve',
|
||||
@@ -61,6 +67,9 @@ ROUTER_SNIPPETS = [
|
||||
'email_draft_send',
|
||||
'email_draft_delete',
|
||||
'email_list_drafts',
|
||||
'calendar_list_events',
|
||||
'calendar_event_update',
|
||||
'calendar_event_delete',
|
||||
'makeApprovalPolicy',
|
||||
'inboundEvents',
|
||||
'eventDedup',
|
||||
|
||||
Reference in New Issue
Block a user