<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1678611822423757&amp;ev=PageView&amp;noscript=1">
Defrag This

| Read. Reflect. Reboot.

How to Implement Slack as a Notification Hub

Adam Bertram| August 25 2016

| IT insights

How to Implement Slack as a Notification HubOver a short period of time, Slack communication has become one of the most popular platforms, and it's easy to see why. After all, the easy-to-use platform has an intuitive interface and a robust API with lots of apps that tie into many popular services such as Dropbox, Github and Trello. And it's fairly easy to create your own Slack integrations to use however you see fit.

By using Slack's API and a PowerShell module, you can integrate any kind of messaging you'd like to send to Slack via a simple PowerShell command. Here are some tips on how to establish a Slack channel as a notification hub for your team.

Custom Integration

First off, you'll need to create a custom integration. More specifically, you'll need to create an Incoming Webhook configuration. To do so, when logged into your Slack team, click on "Build" and then on "Make a Custom Integration." At the custom integration screen, click on incoming webhooks, select the channel to which your messages will be posted and click "Add Incoming WebHook integration."

Once you have the incoming webhooks integration created, you should make note of the webhook URI. You will need this URI when you are sending messages from PowerShell.

PSSlack Module

Next, you should install a copy of Warren Frame's PSSlack module. It's possible to establish a notification hub without the help of this module, but using it will save you a lot of time when it comes to figuring out how to interact with Slack's API via PowerShell.

When you're ready to send a message to your Slack channel with PowerShell, you should use the Send-SlackMessage function in the PSSlack module. While there are a couple of different ways to send a slack message, the easiest method may be to simply use the webhook URI. After you ensure that you have the PSSlack module loaded into your session, you can use the Send-SlackMessage function by specifying the webhook URI as well as the message text:

Send-SlackMessage –Uri -Text 'testing'

This will send the message to the channel that you have configured in your incoming webhook configuration on Slack. You can see below that the "user" that posted this message was "EO." That's due to the fact that the default name inside of the webhook configuration was changed.

You can use this technique in a lot of monitoring scripts. For example, if you have monitoring software that can kick off a PowerShell script, you no longer have to just rely on email or text messaging. If your team has a Slack channel open all day, you can now create a notifications channel setup to alert your entire team when a message is posted.

For example, here's a function you can call within your script:

Function Send-Notification {

Param(

[Parameter(Mandatory)]

[string]$Message,

[Parameter()]

[string]$SlackWebhookURI = ''

Send-SlackMessage –Uri $SlackWebhookURI –Message $Message

When you use this function, you no longer have to remember the webhook URI. Instead, you can send quick text notifications through Send-Notification.

There are quite a few other cool things you can do with the Slack API and the PSSlack module. By using this technique to implement Slack Communication into your monitoring solution, you can dive deeper into your own custom integration.

Topics: IT insights

Leave a Reply

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

THIS POST WAS WRITTEN BY Adam Bertram

Adam Bertram is a 20-year veteran of IT. He’s currently an automation engineer, blogger, independent consultant, freelance writer, author, and trainer. Adam focuses on DevOps, system management, and automation technologies as well as various cloud platforms. He is a Microsoft Cloud and Datacenter Management MVP and efficiency nerd that enjoys teaching others a better way to leverage automation.

Free Trials

Getting started has never been easier. Download a trial today.

Download Free Trials

Contact Us

Let us know how we can help you. Focus on what matters. 

Send us a note

Subscribe to our Blog

Let’s stay in touch! Register to receive our blog updates.