# Add multiple conditional for slack notification?

**URL:** <https://forum.buildkite.community/t/add-multiple-conditional-for-slack-notification/2323>\
**Category:** General\
**Created:** [October 24, 2022, 4:15am UTC](https://forum.buildkite.community/t/add-multiple-conditional-for-slack-notification/2323 "2022-10-24T04:15:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/joe/32/1080_2.png) [@Joe](https://forum.buildkite.community/u/Joe)\
**Post date:** [October 24, 2022, 4:15am UTC](https://forum.buildkite.community/t/add-multiple-conditional-for-slack-notification/2323/1 "2022-10-24T04:15:17Z")

</div>

Does notify accept multiple condition?

```auto
      notify:
        - slack:
            channels:
              - "#test"
            message: "Hurray! build was recently successful in main branch"
        if: build.state == "passed"

        - slack:
            channels:
              - "#test"
            message: "The most recent main branch build has failed, please take a look ."
        if: build.state == "failed"

```

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [October 24, 2022, 6:24am UTC](https://forum.buildkite.community/t/add-multiple-conditional-for-slack-notification/2323/2 "2022-10-24T06:24:52Z")

</div>

Hi @Joe

You can do this sort of thing with multiple notifications to the same channel. However, conditionals (the parts in `if:`) are evaluated at the time the YAML is uploaded.  
So the problem here is that for YAML to be uploaded to a build, it has to be running - which usually implies its passed or “running”. I suspect this might be where you are having troubles if any. When you upload the step that includes this `notify`, the `build.state` is probably “running” so you aren’t getting any notification.

I can think of a few ways around this. The first one is to use our default slack notifications which you can configure to send on passed or failed and includes a link to the build - you can’t configure the message exactly that way but perhaps it’ll still suit your needs.  
Otherwise, you need to make use of, soft-failure and dynamic pipelines to upload a new step that can send the notification for you. We have an example at the bottom of this section in our docs: [Triggering notifications | Buildkite Documentation](https://buildkite.com/docs/pipelines/notifications#slack-channel-and-direct-messages)

```yaml
steps:
  - command: exit -1
    soft_fail: true
    key: 'step1'
  - wait: ~
  - command: |
      if [$$(buildkite-agent step get "outcome" --step "step1") == "soft_failed"]; then
         cat <<- YAML | buildkite-agent pipeline upload 
         steps:
           - label: "Notify slack about soft failed step"
             command: echo "Notifying slack about the soft_failed step"
             notify:
               - slack:
                   channels:
                     - "#general"
                   message: "Step1 has soft failed."
      YAML
      fi

```

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [August 29, 2023, 5:39am UTC](https://forum.buildkite.community/t/add-multiple-conditional-for-slack-notification/2323/3 "2023-08-29T05:39:32Z")

</div>


