Warden meets Slack

Hey, do you remember one of my latest posts in which I’ve described how easy it is to integrate the C# with Slack? I’ve taken this concept a little bit further and created a new type of integration which can do pretty much the same thing but in a more sophisticated way in terms of configuration and available options. So, are you ready to integrate your Warden with the Slack?


 

Let’s start with installing the corresponding NuGet package:

Once it is in place, we can do some actual coding:

Pretty much it can be initialized with this single line of code IntegrateWithSlack() where you need to pass the proper URL of the Webhook. The next parameter being a lambda expression, is, as usual, an optional configuration that you may use but don’t really have to.

In the scenario above, we’re just setting the default message and the username that will be visible as the sender of the message. Eventually, we’re going to send the message whenever some failure occurs which is defined within the OnFailure() hook configured with the SetGlobalWatcherHooks() method.

If you’d like to know more about other possibilities of this extensions, please refer to the available documentation.

Leave A Comment

Your email address will not be published. Required fields are marked *