Slack Webhooks: A Deep Dive

Mio
5 min readSep 28, 2020

--

Slack Webhooks

Slack webhooks are the tools used to facilitate how Slack apps receive, process, and send information and events in real-time. If you’re new to Slack webhooks, you’ve come to the right place.

In this post, we walk through the ins and outs of Slack webhooks:

  1. What is a Slack webhook?
  2. Is a webhook an API?
  3. What is the purpose of a webhook?
  4. How do I get a webhook?
  5. What is a webhook example?
  6. How do I use Slack webhooks?
  7. How we use the Slack webhook to create Mio Universal Channels

What is a Slack webhook?

Have you ever wondered how Slack apps are able to receive events from Slack seemingly as they happen? The answer is a webhook — or specifically on Slack, their Events API.

A webhook gives external applications (like Mio) the ability to get data pushed to them in real-time instead of having to go ask Slack if there are any relevant updates and then pull in that updated data for their users.

Is a webhook an API?

A webhook is a subset of the API family. Creating an API (Application Programmable Interface) is another way of saying that you are creating a way for other programmers to interface with the data in my application.

Traditional APIs follow a request/response pattern. If I want to manipulate data, I need to first send a request to the API endpoint, and then check the response status to make sure the system was able to handle my request without error.

Webhooks, also referred to as subscription or notification based APIs, cut the request/response loop in half.

Instead of initiating a data request from your external system, a subscription model allows programmers to sign up to be sent responses automatically anytime a relevant change is made to relevant data.

What is the purpose of a webhook?

Prior to the existence of new data being pushed on-demand, developers had to use a pattern called polling.

A polling algorithm would continuously loop and check for updates using the request/response pattern.

This model took at least twice as long to get the data into your system and was more expensive from a computational resources perspective because the polling had to be running continuously.

How do I get a webhook?

In Texas, we have a saying “it is as easy as pie”.

In order to start receiving webhooks, all you have to do is sign up for subscriptions and they get sent to the URL of your choice!

Below we will take you through the setup steps in our example.

What is a Webhook example?

A common use case within the Slack App community is to receive a notification when the home tab of your app is viewed so you can track interest and begin onboarding users.

Let’s take a look at how this can work using Slack’s Events API.

How do I use Slack webhooks?

Step 1: Navigate to https://api.slack.com/apps and click “Create an App”.

Create a Slack app

Step 2: Turn on Event Subscriptions for your app and enter the webhook URL that you want your events posted.

This must be a valid URL that can receive HTTP POST, otherwise the Slack webhook will fail.

In order to verify your URL you must implement the webhook endpoint URL to handle the slack challenge successfully and respond with a 200 status code.

Slack event subscriptions

Step 3: Subscribe to the app_home_opened event.

Slack bot events

Step 4: Enable a home tab for your app by first visiting the app home page and then scrolling down to the bottom to toggle the home screen to the on position.

Show tabs Slack webhooks

How do I receive Slack webhooks?

Now all you have to do is wait…well mostly.

You must first have the app installed into your development workspace.

Then you should see your app on the bottom left-hand side of the navigation menu in the “Apps” section.

Click on your app and navigate to the “Home” section of your app then your webhook should receive a post from slack.

What format will I receive Slack webhooks?

The HTTP POST payload sent by slack will be in JSON format.

Here is an example of what the body of the posted payload should look when it is received at your webhook URL endpoint.

Slack webhook format

How we use the Slack webhook to create Mio Universal Channels

At Mio, our core product, Universal Channels, utilizes the Events API to listen in Slack channels for messages and relay these to connected channels on other platforms.

Open APIs and webhooks have allowed us to translate messages from Slack to Microsoft Teams and vice versa.

Universal channels allow you to stay in one messaging tool and chat with your external business contacts as if they were a colleague.

By enabling clients, freelancers, and suppliers to chat in universal channels, everyone can collaborate together, share files, reply to threads, and edit messages — all from their tool of choice.

Connect Slack, Microsoft Teams, and Cisco Webex Teams

Universal channels support the following functionality to enable better intercompany collaboration:

  • Basic messages
  • Threaded messages
  • File uploads
  • Editing messages
  • Deleting messages
  • Emojis
  • GIFs

Like shared channels, but cross-platform

From a single shared channel to Slack Connect for up to 20 organizations, Slack has led the way in promoting channel-based communication between Slack customers.

The success of Slack’s shared channels has fundamentally changed the way that tens of thousands of companies work together.

Universal channels are the next step.

Universal Channels are available to install for Microsoft Teams, Slack, and Webex Teams.

Learn more about what we do and how we can help unlock your business communication here.

--

--

Mio
Mio

Written by Mio

Chat better, together. Mio powers cross-platform messaging across Microsoft Teams, Slack, Webex, and Zoom. Learn more at https://m.io

No responses yet