Send a Slack Notification with Contentful
12.03.2021With the continued growth of feature rich content management systems like Contentful, teams have become empowered to decouple content creation from engineering work. This separation of concerns allows each person to focus on what they do best without relying heavily on the expertise of another. To automate the process even further and keep the lines of communication fluid, Contentful allows you to set up an integration with Slack, posting a message to a channel when a specified action is taken. Let's take a look and see how this works.
The first thing you'll want to do is create an app on Slack. When you click on Create an App, you may be presented with an option to create an app from scratch or to create an app from an app manifest. For this tutorial, we'll go from scratch. Give the app a name (something like, I dunno...Contentful?), and assign it to a workspace, then click on Create App.
You should be redirected to a dashboard with basic information. Find the Incoming Webhooks button and click it. You'll see a toggle to Activate Incoming Webhooks. Flip the switch. Now. Do it.
You should see a new button that says Add New Webhook to Workspace. If you don't make sure you flipped that toggle from before then refresh the page. Click that webhook button and you'll see a permission screen. Choose a channel and click on Allow.
After being redirected to the Incoming Webhooks screen, you should now see a webhook URL right above the Add New Webhook button. Copy the URL and head back over to Contentful.
From your space home, click on the settings tab and choose Webhooks. You'll see a list of templates to choose from. If you see Slack right away, choose that. If not, click on the See All Templates button and a dialog will appear.
Choose Slack, then select a content type. Remember that URL you copied from Slack? Paste it in the URL field and click Create Webhook. You've done it, you sly dog. You've created a Slack notification any time a new bit of content is created and have further reduced the need for you to talk to other humans. Nicely done.