workflow:
  id: opsgenie-alert-monitor
  name: OpsGenie Alert Monitor
  description: Monitors open alerts in OpsGenie and sends detailed Slack notifications with priority levels and timestamps.
  triggers:
    - type: interval
      value: 60
  steps:
    - name: get-open-alerts
      provider:
        type: opsgenie
        config: "{{ providers.opsgenie }}"
        with:
          type: alerts
          query: "status: open"
  actions:
    - name: slack
      provider:
        type: slack
        config: " {{ providers.slack-demo }} "
        with:
          # Message is always mandatory
          message: >
            Opsgenie has {{ steps.get-open-alerts.results.number_of_alerts }} open alerts
          blocks:
            - type: section
              text:
                type: mrkdwn
                text: |-
                  {{#steps.get-open-alerts.results.alerts}}
                    - Alert Id: {{id}} | Priortiy: {{priority}} | Created at: {{created_at}} | Message: {{message}}
                  {{/steps.get-open-alerts.results.alerts}}
