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.
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
idof this channel when you store
channel dataon your
- 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
objectsin Knock so we know where to send a Slack notification for a given recipient.
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.
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
object that you want to notify.
To recap, here are the steps you'll take to build your customer-facing Slack integration.
- Configure your Slack app in the Slack app dashboard.
- Create a Knock channel for your Slack app.
- Build an OAuth flow between your product and Slack.
- Store the credentials received in that OAuth flow on Knock
objectsas channel data.
- Build your Slack notification templates in a Knock workflow.
- Trigger that workflow with a recipient (
object) that has channel data.
In the guides that follow you'll find details on how to accomplish all of the steps above.