SDL Tridion notifications in Slack

I’ve been using Slack for a couple of years now and continue to be impressed by the increase in communication I feel it brings to projects and teams. Bots and apps have been a great evolution, that if used correctly, can easily bring teams closer with their tools. It’s a great central source of information with hundreds of apps and integrations available. I’m going to show how we can easily push notifications to Slack from Tridion.

Tridions built-in notification system is great, but the notifications can often go unnoticed if the user isn’t a daily content manager user. For higher priority notifications, we can easily setup push notifications to Slack channels to let users know when an item comes back from workflow, a new user has been added, or anything else that can be triggered via the event-systems event handlers.

You read read more about implementing event handlers and what’s possible here in SDLs official documentation.

You can find the source code for the project on GitHub.

 

How it works

The setup is pretty simple. We’ll setup a simple Slack app, enable webhooks and write a simple event-system trigger to push the notifications via the hook.

 

Setting up the Slack app

The first thing you need to do is setup a Slack workspace and login. Once logged in, go to “manage apps” which is available as an admin of the workspace.

Creating the app is easy. Give it a title and a description. You can add an icon for the bot posted to Tridion later on.

 

Enable your Slack apps webhooks

You can easily enable webhooks in your Slack app interface by:

  • Clicking “Incoming Webhooks”
  • Flip the switch to “On”
  • Click “Add new Webhook to Workspace”
  • Select the channel you’d like to post to
  • Note down the Webhook URL. That’s the webhook you’ll push to via the Event System.

Setting up the Event System project

Setting up the Event-System project is just as simple. Create a class library project and add the following reference:

  • Tridion.ContentManager.dll

Create a class that extends TcmExtension and subscribe to an event. In the example I’ll show, I am going to be setting up a notification in Slack each time a page is published.

NOTE that you will need to also add your webhook URL in the constant field at the top of the class.

 

 

The only other class in my project is the SlackClient.cs which I use to push the notifications via the webhook.

 

The payload is pretty simple; a string representing the text displayed in the notification.

 

Compile the project into a single DLL and follow along with SDLs documentation on how to deploy the DLL file.

Once I have the event-system deployed, I can test it out by publishing a page to see if I get a Slack notification when the publish is successful.

 


Click to enlarge.

That’s it – simple as that. Of course this is a pretty simple example, but it can easily be extended and integrated into existing event handlers which push notifications to the content manager through the notification API.

Quick Links

Categories SDL