A typical requirement of development teams is to have a message posted to their preferred messaging application like Slack when an action like a pull request or an issue comment happens in the development lifecycle tool. Such requirements are best handled by using Slack Webhook URL.

In this article, you gain a basic understanding of Webhooks. You also understand the steps to set up. At the end of this article, you will explore some of the challenges faced while working with it. So, read along to gain insights and learn how it can be useful to you.

Prerequisites

Before moving forward to create a Slack Webhook URL, you first need to meet the following requirements:

  • A Slack instance with admin privileges.
  • Basic understanding of Enterprise messaging platforms. 

Introduction to Webhooks

  • Webhooks are nothing but web services that can be called with a JSON payload. Their purpose is to accept data from other applications.
  • In the context of Webhooks, the application that receives the data is called the subscribing application. The application that submits the data is the notifying application. 
  • Implementing Webhooks at the subscribing application is just like implementing any web service. The only catch is that the subscribing application must have the ability to generate URLs dynamically for the web services for different purposes.
  • For example, an application like Slack must have a user interface to generate URLs based on the channel to which the user wants to post. Since Webhooks are publicly hosted, it is imperative to have sufficient security measures built into them.
  • At least basic authentication using username and password is recommended. Authentication based on request signing is also a popular practice.

Steps to Set Up Slack Webhook URL

Incoming Webhooks in Slack is meant to accept data from third-party applications. The most common requirement is to post messages to specific channels when something happens in an external application. Slack provides an easy-to-use interface to set up Webhooks. Follow the steps below to generate a URL.

Step 1: The first step is to head to https://api.slack.com/ and log in. Then click on “Create an App“. 

Slack Webhook URL - Create App

Step 2: Select “From Scratch” and give the App a name.

Slack Webhook URL - From Scratch Option

Step 3: Choose the Workspace which needs to be connected to the App.

Slack Webhook URL - Name App

Step 4: On the next screen, you will see the option for “Incoming Webhooks“.

Slack Webhook URL - Incoming Webhooks

Step 5: Toggle the activate button and head to the bottom part of the page.

Slack Webhook URL -Activate Incoming Webhooks

Step 6: Click “Add New Webhook to Workspace” to configure a new Webhook.

Slack Webhook URL - Add Webhook

Step 7: You will be asked to select the channel to which messages are to be posted.

Slack Webhook URL - Test

Step 8: You will be redirected to the page for your Slack App and the Webhook section will now list the new webhook that you created.

Slack Webhook URL - Copy Webhook URL

Step 9: You can copy the URL and use it in the notifying application’s ebook configuration. If you want to test it, you can simply fire a CURL request in the below format.

curl -X POST -H 'Content-type: application/json' --data '{"text":"Hello, World!"}' <your_webhook_url>

That completes the steps involved in setting up Webhooks in Slack.

Challenges Faced While Setting Up Slack Webhook URL

Webhooks in Slack provides an excellent method to send real-time data to Slack from other applications. That said, using Slack Webhook URL integration is not always easy because of the following reasons.

  • The most application does not have support for Webhooks and provides only APIs to access their data. In such cases, you will need a custom code to keep polling the API and then trigger the webhook when required.
  • Subscribing applications like Slack needs the Webhook data to be sent in a specific format. Unless Slack is supported specifically by your notifying application, the data format with which the notifying applications trigger Webhooks will be different.

Learn More About:

Setting up Redash Slack Integration

Conclusion

In this article, you learned about Webhooks and how you can set up a Slack Webhook URL. This article provided you with some easy steps to create your URL. At the end of this article, you explored some of the challenges you might face while setting up.

Share your experience in the comments section below!

Talha
Software Developer, Hevo Data

Talha is a Software Developer with over eight years of experience in the field. He is currently driving advancements in data integration at Hevo Data, where he has been instrumental in shaping a cutting-edge data integration platform for the past four years. Prior to this, he spent 4 years at Flipkart, where he played a key role in projects related to their data integration capabilities. Talha loves to explain complex information related to data engineering to his peers through writing. He has written many blogs related to data integration, data management aspects, and key challenges data practitioners face.