Skip to content

[➕ Feature]: Trigger workflows when alert is assigned via UI #5570

@alexmorbo

Description

@alexmorbo

Problem

When a user clicks "Self-Assign" or changes the assignee in Keep's web UI, workflows with only_on_change: [assignee] are NOT triggered.

This prevents external integrations (like Mattermost/Slack bridges) from receiving notifications when alerts are assigned through the UI.

Current Behavior

The /alerts/{fingerprint}/assign/{last_received} endpoint in keep/api/routes/alerts.py:

  1. ✅ Updates assignee in enrichments table
  2. ✅ Changes alert status to "acknowledged"
  3. ✅ Sends email notification
  4. ❌ Does NOT call workflow_manager.insert_events()
@router.post("/{fingerprint}/assign/{last_received}")
def assign_alert(...):
    enrichment_bl.enrich_entity(...)
    send_email(...)
    return {"status": "ok"}
    # Missing: workflow_manager.insert_events()

Expected Behavior

When an alert is assigned via UI, workflows with matching triggers should be executed, similar to how /enrich and /batch_enrich endpoints work.

Proposed Solution

Add workflow_manager.insert_events() call to the assign endpoint:

@router.post("/{fingerprint}/assign/{last_received}")
def assign_alert(...):
    enrichment_bl.enrich_entity(...)
    send_email(...)
    
    # Trigger workflows for assignee change
    alert_dto = get_alert_by_fingerprint(tenant_id, fingerprint)
    workflow_manager.insert_events(tenant_id=tenant_id, events=[alert_dto])
    
    return {"status": "ok"}

This would allow workflows like:

workflow:
  id: notify-on-assign
  triggers:
    - type: alert
      only_on_change:
        - assignee
  actions:
    - name: send-webhook
      provider:
        type: webhook
      with:
        url: "https://my-bridge/webhook"
        body:
          fingerprint: "{{ alert.fingerprint }}"
          assignee: "{{ alert.assignee }}"

Use Case

I'm building a Mattermost bridge that syncs Keep alerts bidirectionally. When someone acknowledges an alert in Mattermost, it updates Keep. However, when someone assigns an alert in Keep's UI, Mattermost doesn't get notified because no workflow is triggered.

Environment

  • Keep version: latest (main branch)
  • Affected endpoints: /alerts/{fingerprint}/assign/{last_received}

Related Code

  • keep/api/routes/alerts.py - assign endpoint
  • keep/workflowmanager/workflowmanager.py - insert_events() method
  • Similar pattern already exists in /enrich endpoint

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions