workflow:
  id: incident-tier-escalation
  name: Incident Tier Escalation
  description: Manages incident escalation tiers based on alert conditions, automatically adjusting notification tiers and sending appropriate Slack notifications for each level.
  triggers:
    # when an incident is created or updated with a new alert
    - type: incident
      events:
        - created
        - updated
  actions:
    - name: send-slack-message-tier-0
      # send tier0 if this is a new incident (no tier set) or if the incident is tier0 but the alert is alert2
      if: "{{ !incident.current_tier || incident.current_tier == 0 && alert.name == 'alert2' }}"
      provider:
        type: slack
        config: "{{ providers.slack }}"
        with:
          message: |
            "Incident created: {{ incident.name }} - {{ incident.description }}
             Tier: 0"
             Alert: {{ alert.name }} - {{ alert.description }}
             Alert details: {{ alert }}"
          # enrich the incident with the current tier
          enrich_incident:
            - key: current_tier
              value: 0
    - name: send-slack-message-tier-1
      if: "{{ incident.current_tier == 0 && alert.name == 'alert1' }}"
      provider:
        type: slack
        config: "{{ providers.slack }}"
        with:
          message: |
            "Incident updated: {{ incident.name }} - {{ incident.description }}
             Tier: 1
             Alert: {{ alert.name }} - {{ alert.description }}
             Alert details: {{ alert }}"
          enrich_incident:
            - key: current_tier
              value: 1
