mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-23 02:45:37 -04:00
77efff7c35
Based on real webhook data, added comprehensive output schema including: - Detailed file object properties (id, name, mimeType, createdTime, modifiedTime, etc.) - Nested user objects for owners and lastModifyingUser - Complete subscription object with channel metadata and user details - Proper descriptions for all fields This ensures the event output accurately reflects the actual Google Drive API response structure. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Google Drive Trigger Example
This example Trigger plugin demonstrates how to automatically subscribe to Google Drive change notifications using the Drive v3 API. It provisions a webhook channel through OAuth, validates incoming notification headers, and transforms change feed entries into workflow variables.
Features
- OAuth-based subscription constructor that issues a
changes.watchrequest and stores the generated channel metadata (channel ID, resource ID, expiration, verification token). - Trigger implementation that validates Google-signed headers (
X-Goog-*) and ignores sync handshakes. - Event handler that fetches the Drive change feed, persists the most recent
startPageToken, and exposes structured information about each change to workflows. - Optional filters to include removed items, restrict to "My Drive", and tune the number of changes fetched per notification.
Setup
- Create a Google Cloud project with the Google Drive API enabled.
- Configure an OAuth client (type Web application) and add the Dify callback URL as an authorized redirect URI.
- Copy the OAuth client ID and secret into the plugin provider configuration in Dify.
- Deploy this plugin and add the Google Drive Change Detected trigger to your workflow.
- Authenticate with Google Drive via OAuth and select the Drive spaces you want to monitor. The constructor will start a new watch channel automatically.
Testing
Compile-time validation ensures the module imports cleanly:
python -m compileall python/examples/google_drive_trigger