# Send slack message only on failed build

**URL:** <https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111>\
**Category:** Question & Answer\
**Tags:** step, slack\
**Created:** [October 24, 2017, 5:46pm UTC](https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111 "2017-10-24T17:46:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryce-ifit](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@bryce-ifit](https://discuss.bitrise.io/u/bryce-ifit)\
**Post date:** [October 24, 2017, 5:46pm UTC](https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111/1 "2017-10-24T17:46:25Z")

</div>

How do I set a slack set up to only send the message when a build fails?

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 24, 2017, 7:42pm UTC](https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111/2 "2017-10-24T19:42:41Z")

</div>

Hi @bryce-ifit,

You can run any step on build failure using a `run_if` expression in YML mode. Related docs: [http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed](http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed)

E.g. for Slack step:

```auto
    - slack:
        is_always_run: true
        run_if: .IsBuildFailed

```

with this configuration this Slack step will only run if `.IsBuildFailed` is true, which is only true in case if a previous step failed.

If you have any questions just let us know! 😉

P.S.: in case of the Slack step `is_always_run: true` is optional as that’s the default value for the Slack step ([https://github.com/bitrise-io/steps-slack-message/blob/75c5e8b40c311afcd60934393514093e3fed2b4d/step.yml#L23](https://github.com/bitrise-io/steps-slack-message/blob/75c5e8b40c311afcd60934393514093e3fed2b4d/step.yml#L23)). For other steps this is usually required. For more info see the linked DevCenter guide ([http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed](http://devcenter.bitrise.io/tips-and-tricks/disable-a-step-by-condition/#run-a-step-only-if-the-build-failed)).

---

<div class="post-metadata">

**Author:** ![bryce-ifit](https://avatars.discourse-cdn.com/v4/letter/b/e8c25b/32.png) [@bryce-ifit](https://discuss.bitrise.io/u/bryce-ifit)\
**Post date:** [October 24, 2017, 8:32pm UTC](https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111/3 "2017-10-24T20:32:53Z")

</div>

Great, thank you!

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [October 24, 2017, 8:40pm UTC](https://discuss.bitrise.io/t/send-slack-message-only-on-failed-build/3111/4 "2017-10-24T20:40:25Z")

</div>

Any time 😉
