Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Dec 2, 2025

Summary

Adds multi-channel notifications for workflow executions with alerting capabilities.

  • New notification configuration UI in Logs page (3-dot menu → Configure Notifications)
  • Migrated legacy per-workflow webhooks to workspace-scoped system
  • Added 1-hour cooldown for alert notifications to prevent spam
  • Limits: 10 notifications per type, 10 email recipients max (to not have people exploit)

Alerts system

Consecutive failures: Alert after X failures in a row (resets on success)
Failure rate: Alert when error rate exceeds X% over Y hours (requires full window of data)
Latency threshold: Alert when execution duration exceeds X seconds
Latency spike: Alert when execution is X% slower than average (requires 5+ executions for baseline)
Cost threshold: Alert when single execution cost exceeds $X
No activity: Alert when no executions occur within X hours (checked hourly via cron)
Error count: Alert when total errors exceed X within Y hours

Type of Change

  • New feature

Testing

IN PROGRESS

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

vercel bot commented Dec 2, 2025

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

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Dec 5, 2025 1:58am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

This PR implements a comprehensive migration from per-workflow webhook notifications to a workspace-level multi-channel notification system. The changes introduce support for webhook, email, and Slack notifications for workflow executions with sophisticated alerting rules including consecutive failure detection and failure rate monitoring. The new system includes a 1-hour cooldown mechanism to prevent notification spam and enforces limits of10 notifications per type with a maximum of 10 email recipients.

Key architectural changes include removing the legacy workflowLogWebhook tables and replacing them with new workspaceNotificationSubscription and workspaceNotificationDelivery tables. The notification configuration is now centralized in the Logs page UI (accessible via 3-dot menu → Configure Notifications) rather than being scattered across individual workflow settings. The implementation includes a new background task system for reliable notification delivery with retry mechanisms, proper webhook signature verification, and comprehensive payload formatting for each notification channel.

Important Files Changed

Filename Score Overview
packages/db/migrations/0116_huge_ma_gnuci.sql 4/5 Creates new workspace notification tables and migrates existing webhook data
packages/db/schema.ts 4/5 Refactors database schema from workflow webhooks to workspace notifications
apps/sim/background/workspace-notification-delivery.ts 4/5 New background task for multi-channel notification delivery with retry logic
apps/sim/app/api/workspaces/[id]/notifications/route.ts 4/5 API endpoints for creating and fetching workspace notification subscriptions
apps/sim/app/api/workspaces/[id]/notifications/[notificationId]/route.ts 4/5 CRUD operations for individual notification subscription management
apps/sim/app/api/workspaces/[id]/notifications/[notificationId]/test/route.ts 4/5 Testing endpoint for validating notification configurations
apps/sim/app/api/auth/accounts/route.ts 4/5 Fetches OAuth accounts for notification provider integration
apps/sim/hooks/use-slack-accounts.ts 3/5 Custom hook for managing Slack account data with incomplete error handling
apps/docs/content/docs/en/execution/api.mdx 4/5 Documentation updates for new notification system features
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/webhook-settings/webhook-settings.tsx 5/5 Legacy webhook settings component removed as part of migration

Confidence score: 3/5

  • This PR introduces complex architectural changes with potential for integration issues and data migration risks
  • Score reflects concerns about missing TSDoc documentation, incomplete error handling in hooks, and the complexity of migrating legacy webhook data without comprehensive testing coverage
  • Pay close attention to the database migration file, notification delivery background task, and the new API endpoints for proper error handling and data validation

Sequence Diagram

sequenceDiagram
    participant User
    participant LogsPage as "Logs Page"
    participant NotificationSettings as "Notification Settings Modal"
    participant WorkspaceAPI as "Workspace Notifications API"
    participant Database as "Database"
    participant EventSystem as "Log Event System"
    participant DeliveryTask as "Notification Delivery Task"
    participant ExternalService as "External Service (Webhook/Email/Slack)"

    User->>LogsPage: "Click 3-dot menu → Configure Notifications"
    LogsPage->>NotificationSettings: "Open notification settings modal"
    NotificationSettings->>WorkspaceAPI: "GET /api/workspaces/{id}/notifications"
    WorkspaceAPI->>Database: "Query existing notification subscriptions"
    Database-->>WorkspaceAPI: "Return subscription list"
    WorkspaceAPI-->>NotificationSettings: "Return existing notifications"
    
    User->>NotificationSettings: "Configure new notification (webhook/email/slack)"
    User->>NotificationSettings: "Set alert rules (consecutive failures/failure rate)"
    User->>NotificationSettings: "Select workflows and filters"
    NotificationSettings->>WorkspaceAPI: "POST /api/workspaces/{id}/notifications"
    WorkspaceAPI->>Database: "Insert workspace notification subscription"
    Database-->>WorkspaceAPI: "Return created subscription"
    WorkspaceAPI-->>NotificationSettings: "Return success response"
    
    Note over EventSystem: "When workflow execution completes with error"
    EventSystem->>Database: "Query matching notification subscriptions"
    Database-->>EventSystem: "Return active subscriptions for workspace"
    EventSystem->>EventSystem: "Check alert conditions (consecutive failures/failure rate)"
    EventSystem->>Database: "Update lastAlertAt if alert triggered"
    EventSystem->>Database: "Insert notification delivery record"
    EventSystem->>DeliveryTask: "Trigger notification delivery task"
    
    DeliveryTask->>Database: "Claim delivery record"
    DeliveryTask->>DeliveryTask: "Build notification payload with execution details"
    
    alt Webhook Notification
        DeliveryTask->>ExternalService: "POST webhook with HMAC signature"
        ExternalService-->>DeliveryTask: "HTTP response"
    else Email Notification
        DeliveryTask->>ExternalService: "Send formatted email"
        ExternalService-->>DeliveryTask: "Email delivery status"
    else Slack Notification
        DeliveryTask->>ExternalService: "Post message to Slack channel"
        ExternalService-->>DeliveryTask: "Slack API response"
    end
    
    DeliveryTask->>Database: "Update delivery status (success/failed)"
    
    Note over DeliveryTask: "If delivery fails, retry with exponential backoff"
    alt Delivery Failed
        DeliveryTask->>Database: "Schedule retry with backoff delay"
        DeliveryTask->>DeliveryTask: "Wait for retry window"
        DeliveryTask->>ExternalService: "Retry delivery (up to 5 attempts)"
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

17 files reviewed, 10 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321 icecrasher321 merged commit 3b9f0f9 into staging Dec 5, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/notifications-workflow-execs branch December 7, 2025 02:16
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.

2 participants