Skip to content

feat(trigger): add Google Sheets, Drive, and Calendar polling triggers#4081

Merged
waleedlatif1 merged 19 commits intostagingfrom
waleedlatif1/polling-research
Apr 10, 2026
Merged

feat(trigger): add Google Sheets, Drive, and Calendar polling triggers#4081
waleedlatif1 merged 19 commits intostagingfrom
waleedlatif1/polling-research

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

@waleedlatif1 waleedlatif1 commented Apr 9, 2026

Summary

  • Add polling triggers for Google Sheets (new rows), Google Drive (file changes), and Google Calendar (event updates)
  • Google Drive uses changes.list API with opaque cursor (no clock skew, catches deletes)
  • Google Calendar uses updatedMin + singleEvents=true (expanded recurring events)
  • Google Sheets uses row count comparison + Drive modifiedTime pre-check (saves Sheets quota)
  • Each poller supports: OAuth credentials, configurable filters (event type, MIME type, folder, search term, render options), idempotency, first-poll seeding
  • Wire triggers into block configs so trigger UI appears and generate-docs.ts discovers them
  • Regenerate integrations.json with new trigger entries
  • Update add-trigger skill with polling instructions and versioned block wiring guidance
  • Added trigger-advanced mode for subblocks for advanced mode fields in trigger mode

Type of Change

  • New feature

Testing

Tested manually — type-check passes, lint passes, integrations.json regenerated correctly

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 10, 2026 6:04am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 9, 2026

PR Summary

Medium Risk
Adds new polling-based trigger execution paths (new cron jobs, provider handlers, and idempotency retry behavior) and extends trigger-mode rendering logic, which could affect workflow execution volume and UI visibility if misconfigured.

Overview
Adds new polling triggers for Google Calendar, Google Drive, and Google Sheets, including new poller trigger configs and polling provider handlers wired into POLLING_PROVIDERS, the polling handler registry, and the trigger registry, plus new Helm cron jobs to run the poll endpoints.

Updates block configs for Google Calendar/Drive/Sheets to expose these triggers in the UI by spreading trigger subBlocks and enabling the new trigger IDs, and regenerates integrations.json to list the new triggers.

Introduces a new sub-block mode trigger-advanced and updates editor/preview rendering, trigger config aggregation/deploy, copilot block metadata, canonical visibility grouping, and validation to treat trigger + trigger-advanced as trigger-only fields. Polling idempotency now supports retrying failures by deleting failed keys instead of caching them.

Reviewed by Cursor Bugbot for commit 9a33570. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR adds polling triggers for Google Sheets (new rows), Google Drive (file changes), and Google Calendar (event updates), wires them into the existing block configs, introduces a new trigger-advanced subblock mode for advanced canonical-pair fields in trigger context, and adds retryFailures support to the IdempotencyService. The polling handlers follow the established pattern from Gmail/Outlook, and the previous round of review comments (cursor revert on failure, timestamp guard, rate-limit handling, etc.) have all been addressed.

Confidence Score: 5/5

Safe to merge — all previously flagged P0/P1 concerns have been addressed; remaining findings are P2 style/quality suggestions only.

The cursor-revert-on-failure logic, timestamp guard for Calendar, rate-limit handling, and idempotency with retryFailures are all correctly implemented. The two remaining P2 comments (Drive 403/429 descriptive messages and Calendar no-op timestamp update) are non-blocking improvements that do not affect correctness or data integrity.

apps/sim/lib/webhooks/polling/google-drive.ts (rate-limit error messaging) and apps/sim/lib/webhooks/polling/google-calendar.ts (empty-poll timestamp update).

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/polling/google-calendar.ts New Calendar polling handler; timestamp revert on failure is correct, latestUpdated advance for filtered events is intentional, but lastCheckedTimestamp is not updated on empty polls (same updatedMin reused indefinitely until events appear).
apps/sim/lib/webhooks/polling/google-drive.ts New Drive polling handler; cursor revert on any failure is correct; fetchChanges lacks explicit 403/429 detection — generic error thrown but behavior is still safe (cursor doesn't advance).
apps/sim/lib/webhooks/polling/google-sheets.ts New Sheets polling handler; rate-limit handling added to all API calls; row-count revert on any failure is correct; Drive pre-check optimization is correct.
apps/sim/lib/core/idempotency/service.ts Adds retryFailures config option — failures are deleted rather than stored so the operation retries next cycle; recursive retry depth is bounded; correct.
apps/sim/lib/workflows/subblocks/visibility.ts Adds trigger-advanced to canonical index: correctly classified as advancedIds, trigger mode correctly blocked from overwriting an existing basicId.
apps/sim/triggers/google-calendar/poller.ts New Calendar trigger config with correct subblock modes; trigger-advanced used correctly for manualCalendarId.
apps/sim/triggers/google-drive/poller.ts New Drive trigger config; trigger-advanced used correctly for manualFolderId; MIME type prefix matching config aligns with handler logic.
apps/sim/triggers/google-sheets/poller.ts New Sheets trigger config; dependsOn for sheetName correctly uses any to accept either spreadsheet selector or manual ID.
apps/sim/blocks/blocks/google_sheets.ts Spreads trigger subBlocks into the block and registers triggers.available; pattern matches other trigger-enabled blocks.
apps/sim/blocks/blocks.test.ts Test exclusions for trigger-advanced mode added in all the right places; consistent with the trigger exclusion pattern already in place.
apps/sim/triggers/constants.ts Three new provider IDs added to POLLING_PROVIDERS; alphabetically sorted and correctly named.

Sequence Diagram

sequenceDiagram
    participant Scheduler as Trigger.dev Scheduler
    participant Poller as Polling Handler<br/>(Calendar / Drive / Sheets)
    participant GoogleAPI as Google API
    participant Idempotency as IdempotencyService<br/>(retryFailures=true)
    participant Processor as processPolledWebhookEvent
    participant DB as Webhook Config (DB)

    Scheduler->>Poller: pollWebhook(ctx)
    Poller->>DB: read providerConfig (cursor / timestamp / rowCount)

    alt First poll (no state)
        Poller->>GoogleAPI: getStartPageToken / now.toISOString()
        Poller->>DB: seed initial state
        Poller-->>Scheduler: success (no events fired)
    else Subsequent poll
        Poller->>GoogleAPI: fetch changes since cursor/timestamp
        GoogleAPI-->>Poller: events / changes / rows

        alt No results
            Poller->>DB: update state (Sheets/Drive) or keep timestamp (Calendar)
            Poller-->>Scheduler: success
        else Results found
            loop for each event/change/row
                Poller->>Idempotency: executeWithIdempotency(key, operation)
                alt Cache hit (completed)
                    Idempotency-->>Poller: cached result (no re-fire)
                else Cache hit (failed) + retryFailures=true
                    Idempotency->>DB: delete failed key
                    Idempotency->>Processor: re-execute operation
                else First time
                    Idempotency->>Processor: execute operation
                    Processor-->>Idempotency: success / failure
                end
            end

            alt Any failures
                Poller->>DB: revert cursor/timestamp/rowCount
            else All success
                Poller->>DB: advance cursor/timestamp/rowCount
            end
            Poller-->>Scheduler: success or failure
        end
    end
Loading

Reviews (11): Last reviewed commit: "fix(polling): advance calendar cursor pa..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9a33570. Configure here.

@waleedlatif1 waleedlatif1 merged commit 6099683 into staging Apr 10, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/polling-research branch April 10, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant