Automatic Slack Notifications from Windows

I often execute long running scripts on my development machine and want to get notified when their done, even when I’m not in the room. I’d prefer to do this without installing anything extra, because nobody hates software more than software developers. I’m already running Slack, so one practical way to do this is by exploiting Slack’s Incoming Webhooks. Unfortunately, all Slack’s examples for web hooks use cURL and I’m developing on Windows 10. There are solutions for getting cURL on Windows, but I’d prefer something that works on a fresh install. This is where Powershell’s Invoke-RestMethod comes in.

First, lets set up the Incoming Webhooks integration in slack. Log into the web app, and click on your team’s name in the top left corner. Select Team settings from the dropdown. TeamSettings.png In the menu on the left select Configure Apps. In the Apps Directory search bar at the top search for Incoming Webhooks. Search.png Then hit Add Configuration. AddConfiguration.png In the dropdown select a default channel you’d like your automated posts to go to, don’t worry, you can change this programmatically in the future. Next hit the big green button: Add Incoming Webhooks integration PostToChannel.png The next page you get has documentation and some settings you can adjust. Most of the settings here are just defaults which can be overridden by your scripts. The only thing we’re interested in at the moment is the Webhook URL. Copy it to your clipboard. URL.png Go to the search bar in Windows 10 by hitting the Windows key and typing Powershell ISE to open the integrated powershell editor. Hit File > New to create your new script. Fill it with the following, but make sure you relplace the -Uri argument with your own Webhook URL

$payload = @{
	text = 'Hello World'
$json = $payload | ConvertTo-Json
Invoke-RestMethod -Uri -Method POST -Body $json

In PowerShell ISE hit the green Run Script button to test your script out, you should get ok as a return value, and you should see your message in Slack. Make sure you check the right channel! HelloWorld.png You can do a lot more interesting stuff with this once you get the basics working, such as sending different notifications when builds fail or succeed. This script can be called on the command line with your Webhook URL and a bool to indicate success or failure:

param (

$message = 'Build Failed'
$emoji = ':rage:'

	$message = 'Build Succeeded'
	$emoji = ':nerd_face:'

$payload = @{

$json = $payload | ConvertTo-Json
$response = Invoke-RestMethod -Uri $uri -Method POST -Body $json

You can invoke it from plain old windows shell like so:

powershell -command .\buildStatus.ps1 0

I’d love to hear about the awesome things you automate after trying this out!

I’m actually pretty excited about Powershell, batch and bash scripting are just about the most obscure programming languages out there short of LOLCODE. So it’s great to see a more useful programming interface integrated directly into the OS. Don’t get all pedantic on me and call them scripting languages, that line is looking pretty smudged these days.


A Procedural Planet Generator

Progeny was the capstone project of my engineering degree at Memorial University. It was a group project where I worked with Chad Levesque, Shawn Josey, and Andrew Carter. Each group worked with a project advisor from a relevant industry. Source Studio proposed the concept for our project as “a library for procedural generation of 3D art assets for games”. We focused on creating large-scale planetary bodies; we felt it would offer a great demonstration of the strengths of procedural techniques. A big thanks to Source Studio for use of their game engine, as well as the expert advise of Alex Brown. Above is a video demonstrating the project in action.

We also did presentations. Our team came second in that competition, loosing out to what was admittedly a pretty sweet robotics project.

Cataclysmic Cosmos

Orbital Tower Defence Game

This is a computer game Andrew Carter and I developed for our software design course at Memorial University. We developed the game in Java, so it should run on most machines; though we tested it primarily in windows. I’ve included the game, and some of the documentation we produced so you can get an idea for how we developed it.