How Knock sends Slack notifications

In this guide we'll provide an overview of how Knock sends notifications to Slack, the key concepts involved, and the steps you'll take to configure your Slack integration in Knock.

Key concepts

Here's a list of terms and concepts we'll be referencing throughout our Slack guides.

  • Slack app. The Slack app you configure within the Slack API platform. This is sometimes referred to as a Slack bot but we'll be using the term "Slack app" throughout this documentation. This is what your customers install into their own Slack workspace during the Slack OAuth flow you start from within your product.
  • Knock channel. The channel you configure within the Knock dashboard. You'll use the id of this channel when you store channel data on your users or objects in Knock.
  • Slack channel. A channel in your customer's Slack workspace that you want to notify. "Channel" is an overloaded term between Knock and Slack, so we'll always refer to channels that live within Slack as "Slack channels". Note that this can refer to a public channel, a private channel, or even a user DM channel.
  • Channel data. The connection data received from the Slack OAuth handshake, either an incoming webhook URL or an access token. You store this data on users and/or objects in Knock so we know where to send a Slack notification for a given recipient.

How Knock powers Slack notifications

As with any other channel type in Knock, you'll need to configure your Slack app as a Knock channel before you can use it in your notification workflows. Once you've created a Knock channel for your Slack app, you're ready to start adding it to your notification workflows.

Supporting multiple Slack bots. In some cases you might have multiple Slack apps you want to power with Knock, such as an app that your customers install in their own Slack workspaces and an internal app you use for internal team-facing notifications (e.g. new signup alerts.)

To support this you'd just create two separate Knock channels, one for each Slack app. Then when you're adding a Slack channel step to a workflow you'll select which Slack app you'd like Knock to notify.

Once you add a Slack channel step to a workflow, it works the same as any other channel step. The workflow engine will look for Slack channel data on the workflow run's recipient (note: this recipient can be either a user or an object) and send the notification generated by your template to that Slack channel.

There's one tricky part about notifying a Slack channel. Unlike an email channel where you'll already have the user's email in your product and just need to store it on the user in Knock, with Slack you'll need to fetch the channel data you want to send to from Slack, then store it on the user or object that you want to notify.

The steps to configure your Slack integration

To recap, here are the steps you'll take to build your customer-facing Slack integration.

  1. Configure your Slack app in the Slack app dashboard.
  2. Create a Knock channel for your Slack app.
  3. Build an OAuth flow between your product and Slack.
  4. Store the credentials received in that OAuth flow on Knock users or objects as channel data.
  5. Build your Slack notification templates in a Knock workflow.
  6. Trigger that workflow with a recipient (user or object) that has channel data.

In the guides that follow you'll find details on how to accomplish all of the steps above.