Skip to content

Commit 408e1bf

Browse files
claude[bot]github-actions[bot]claudehugocasa
authored
native triggers (#1253)
* feat: add native triggers documentation (Nextcloud, Google Drive, Google Calendar) Add documentation for native triggers, a new Enterprise feature that allows Nextcloud, Google Drive, and Google Calendar to push events to Windmill. Ref: windmill-labs/windmill#7837 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * improve --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: hugocasa <hugo@casademont.ch>
1 parent 58abaab commit 408e1bf

File tree

14 files changed

+264
-0
lines changed

14 files changed

+264
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
slug: native-triggers
3+
title: Native triggers
4+
version: v1.636.0
5+
tags: ['Triggers', 'Nextcloud', 'Google']
6+
description: Trigger scripts and flows in real-time from Nextcloud, Google Drive, and Google Calendar events via push notifications.
7+
features:
8+
[
9+
'Nextcloud: file, folder, and calendar event triggers.',
10+
'Google Drive: watch a specific file or all changes.',
11+
'Google Calendar: track event creation, updates, and deletions.'
12+
]
13+
docs: /docs/core_concepts/native_triggers
14+
image: ./native_triggers.png
15+
---
110 KB
Loading
76.1 KB
Loading
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
description: How do I trigger scripts and flows from Nextcloud or Google Drive/Calendar events in Windmill?
3+
---
4+
5+
import DocCard from '@site/src/components/DocCard';
6+
7+
# Native triggers
8+
9+
Native triggers allow external services to push events directly to Windmill and trigger [scripts](../../script_editor/index.mdx) and [flows](../../flows/1_flow_editor.mdx). Unlike [scheduled polls](../../flows/10_flow_trigger.mdx), native triggers receive real-time push notifications from the external service via webhooks, so your runnables execute as soon as events occur.
10+
11+
Currently supported services:
12+
13+
- [Nextcloud](#nextcloud-triggers) - file, folder, and calendar change events
14+
- [Google](#google-triggers) - drive and calendar change events
15+
16+
---
17+
18+
## How it works
19+
20+
Native triggers use [OAuth](../../misc/2_setup_oauth/index.mdx) to authenticate with the external service. Each trigger registers a webhook or watch channel on the external service, which sends notifications to Windmill when events occur. Windmill then executes the configured script or flow with the event data.
21+
22+
The general setup follows two steps:
23+
24+
1. **Connect the service** via workspace settings (OAuth authentication)
25+
2. **Create a trigger** on a script or flow, selecting the service and configuring which events to watch
26+
27+
---
28+
29+
## Setup
30+
31+
### Workspace integration
32+
33+
Before creating native triggers, you need to connect the external service in your workspace settings.
34+
35+
1. Go to **Workspace settings** > **Integrations** > **Native triggers**
36+
2. Click **Connect** on the service you want to use (Nextcloud or Google)
37+
3. Provide the [OAuth](../../misc/2_setup_oauth/index.mdx) credentials (client ID and client secret)
38+
4. Complete the OAuth authorization flow
39+
5. Choose a [resource](../3_resources_and_types/index.mdx) path where the connection will be stored in the workspace
40+
41+
![Workspace integration](./workspace_integration.png "Workspace settings showing native triggers integrations for Nextcloud and Google")
42+
43+
The integration creates a [resource](../3_resources_and_types/index.mdx) in your workspace at the path you specify. The OAuth token is refreshed automatically, so you don't need to re-authenticate manually. You can use this resource in your scripts to query the service API with the same credentials used by the trigger.
44+
45+
For Google integrations, the created [resource](../3_resources_and_types/index.mdx) is of type `gworkspace`. The OAuth scopes used are:
46+
- `https://www.googleapis.com/auth/drive.readonly`
47+
- `https://www.googleapis.com/auth/calendar.readonly`
48+
- `https://www.googleapis.com/auth/calendar.events`
49+
50+
If you need additional scopes (e.g. write access), set up a separate resource with the desired scopes.
51+
52+
A superadmin can share [instance-level](../../advanced/18_instance_settings/index.mdx) Google workspace settings so that workspace admins can connect Google native triggers without configuring their own OAuth client.
53+
The credentials are not exposed to workspace admins.
54+
55+
![Instance gworkspace settings](./instance_gworkspace.png "Instance-level gworkspace settings with shared credentials toggle and redirect URI")
56+
57+
For Nextcloud, you also need to provide the base URL of your Nextcloud instance.
58+
59+
### Create a trigger
60+
61+
Once the workspace integration is configured:
62+
63+
1. Go to **Nextcloud** or **Google** tab (only visible once the corresponding [workspace integration](#workspace-integration) is configured)
64+
2. Click **New trigger**
65+
3. Select the script or flow to trigger
66+
4. Configure the service-specific options (see sections below)
67+
5. Save the trigger
68+
69+
You can also create native triggers directly from a script or flow's **Triggers** tab.
70+
71+
---
72+
73+
## Nextcloud triggers
74+
75+
Nextcloud native triggers watch for file, folder, and calendar changes on a [Nextcloud](https://nextcloud.com/) instance and trigger a script or flow when events occur.
76+
77+
### Prerequisites
78+
79+
- Nextcloud 33 or later
80+
- The [Windmill integration app](https://apps.nextcloud.com/apps/integration_windmill) installed on your Nextcloud instance
81+
- [Pretty URLs](https://docs.nextcloud.com/server/latest/admin_manual/installation/source_installation.html#pretty-urls) enabled on your Nextcloud instance
82+
83+
### Configuration
84+
85+
When creating a Nextcloud trigger, pick a script or flow (or use **Create from template**), then configure:
86+
87+
- **Event** - select the event type to listen for. Available events include:
88+
- Calendar events: object created, moved, trashed, restored, or changed in a Nextcloud calendar
89+
- File/folder events: node created, changed, or written
90+
91+
![Nextcloud trigger configuration](./nextcloud_trigger.png "Nextcloud trigger creation with event type selection")
92+
93+
### Event payload
94+
95+
Nextcloud sends the full event data to your script. The payload includes the authenticated user, a timestamp, and the event details:
96+
97+
```typescript
98+
export async function main(
99+
authentication: {
100+
owner: RT.Nextcloud;
101+
trigger: RT.Nextcloud;
102+
},
103+
user: {
104+
uid: string;
105+
displayName: string;
106+
},
107+
time: number,
108+
event: any
109+
) {
110+
// event contains the Nextcloud event details (file, folder, or calendar object)
111+
}
112+
```
113+
114+
---
115+
116+
## Google triggers
117+
118+
Google native triggers watch for changes in [Google Drive](https://drive.google.com/) or [Google Calendar](https://calendar.google.com/) and trigger a script or flow when events occur.
119+
120+
### Prerequisites
121+
122+
- A Google Cloud project with the relevant API enabled ([Drive API](https://developers.google.com/drive/api), [Calendar API](https://developers.google.com/calendar/api), or both)
123+
- [OAuth 2.0](https://console.cloud.google.com/apis/credentials) credentials (client ID and client secret) configured with the appropriate scopes
124+
125+
### Configuration
126+
127+
When creating a Google trigger, pick a script or flow (or use **Create from template**), then configure:
128+
129+
- **Trigger Type** - choose between **Drive** and **Calendar**
130+
- **Watch Mode** (Drive only) - choose between:
131+
- **Specific file** - watch a single file or folder from My Drive, Shared with me, or Shared drives
132+
- **All changes** - watch all changes across your Google Drive (fires whenever any file is created, modified, or deleted)
133+
- **Calendar** (Calendar only) - select a calendar from your Google account to watch for event changes
134+
135+
![Google trigger configuration](./google_trigger.png "Google trigger creation with trigger type and watch mode selection")
136+
137+
Both use push notifications via Google watch channels. Windmill automatically renews channels before they expire. The expiration period differs by service: 24 hours for Drive, 7 days for Calendar.
138+
139+
### Event payload
140+
141+
Google push notifications only contain metadata about the change, not the full event details. To get the actual content of the change, use the [`gworkspace` resource](../3_resources_and_types/index.mdx) created during workspace integration to query the Google API.
142+
143+
```typescript
144+
type GoogleTriggerPayload = {
145+
channel_id: string;
146+
resource_id: string;
147+
resource_state: string; // "sync" | "exists" | "not_exists" | "update"
148+
resource_uri: string;
149+
message_number: string;
150+
channel_expiration: string;
151+
channel_token: string; // custom token set when creating the watch
152+
changed: string; // Drive-only: comma-separated list (e.g. "content,properties,permissions")
153+
};
154+
155+
export async function main(payload: GoogleTriggerPayload) {
156+
// Use the gworkspace resource to query the Google API for full details
157+
}
158+
```
159+
160+
Use the [Google native trigger template script](https://hub.windmill.dev/scripts/gworkspace/22221/google-native-trigger-template-script-gworkspace) (also available from the UI when creating a trigger) as a starting point.
161+
162+
---
45.7 KB
Loading
110 KB
Loading
104 KB
Loading

docs/core_concepts/index.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ On top of its editors to build endpoints, flows, [low-code apps](../apps/0_app_e
7171
description="Trigger scripts and flows from Google Cloud Pub/Sub messages."
7272
href="/docs/core_concepts/gcp_triggers"
7373
/>
74+
<DocCard
75+
title="Native triggers"
76+
description="Trigger scripts and flows from Nextcloud, Google Drive, and Google Calendar events."
77+
href="/docs/core_concepts/native_triggers"
78+
/>
7479
</div>
7580

7681
## Windmill features

docs/getting_started/8_triggers/index.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Triggers from external events:
3131
- [SQS triggers](#sqs-triggers)
3232
- [MQTT triggers](#mqtt-triggers)
3333
- [GCP triggers](#gcp-triggers)
34+
- [Native triggers](#native-triggers) (Nextcloud, Google Drive, Google Calendar)
3435
- [Scheduled polls](#scheduled-polls-scheduling--trigger-scripts)
3536

3637
:::info Scripts and Flows in Windmill
@@ -364,6 +365,18 @@ Windmill can connect to Google Cloud Pub/Sub, subscribe to specific topics, and
364365
</div>
365366

366367

368+
### Native triggers
369+
370+
Native triggers allow external services like Nextcloud, Google Drive, and Google Calendar to push events directly to Windmill, triggering scripts or flows in real-time via webhooks or watch channels.
371+
372+
<div className="grid grid-cols-2 gap-6 mb-4">
373+
<DocCard
374+
title="Native triggers"
375+
description="Trigger scripts and flows from Nextcloud, Google Drive, and Google Calendar events."
376+
href="/docs/core_concepts/native_triggers"
377+
/>
378+
</div>
379+
367380
### Scheduled polls (Scheduling + Trigger scripts)
368381

369382
A particular use case for schedules are [Trigger scripts](../../flows/10_flow_trigger.mdx).

docs/integrations/gcal.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ Your resource can be used [passed as parameters](../core_concepts/3_resources_an
3838
> Example of a Supabase resource being used in two different manners from a script in Windmill.
3939
<br/>
4040
41+
## Native triggers
42+
43+
You can use [native triggers](../core_concepts/52_native_triggers/index.mdx) to automatically run scripts or flows when calendar events are created, updated, or deleted. Native triggers receive real-time push notifications so your runnables execute as soon as events occur.
44+
4145
:::tip
4246

4347
Find some pre-set interactions with Google Calendar on the [Hub](https://hub.windmill.dev/integrations/gcal).

0 commit comments

Comments
 (0)