workflow:
  id: send-slack-message-on-failure
  name: Get alert root cause from OpenAI, notify if workflow fails
  description: Get alert root cause from OpenAI, notify if workflow fails
  triggers:
    - type: alert
      cel: alert.severity == "critical"
  on-failure:
    provider:
      type: slack
      config: "{{ providers.slack }}"
      with:
        channel: "<slack-channel-id>"
        # message will be injected from the workflow engine
        # e.g. "Workflow <workflow-id> failed with error: <error-message>"
  steps:
    - name: openai-step
      provider:
        config: "{{ providers.openai }}"
        type: openai
        with:
          prompt: |
            You are a very talented engineer that receives critical alert and reports back the root
            cause analysis. Here is the context: keep.json_dumps({{alert}}) (it is a JSON of the alert).
            In your answer, also provide the reason why you think it is the root cause and specify what your certainty level is that it is the root cause. (between 1-10, where 1 is low and 10 is high)
  actions:
    - name: slack-action
      provider:
        config: "{{ providers.slack }}"
        type: slack
        with:
          message: "{{steps.openai-step.results}}"
