Knock implementation guide

Learn how to plan and execute your Knock integration from start to finish.

Knock’s APIs and developer tools make it easy to migrate your notification templates, delivery logic, recipient data, and user preferences into Knock. In this guide, we will walk you through planning and executing your Knock integration from start to finish.

If you’re new to Knock, we recommend taking a look at our What is Knock? page to learn more about our product and how it can be used. You may also want to take a closer look at various Concepts as you familiarize yourself with the product.

Migrating data into Knock to power your notifications

Using Knock as your notifications service means storing all of the logic for your notifications (the who, when, and where of delivery) in Knock. We offer APIs and developer tools that make your migration a smooth and efficient process:

  • A Management API that allows you to work programmatically with the same resources that you create in your Knock dashboard (like Workflows and their associated message templates, email Layouts, and Translations).
  • A command line interface (Knock CLI) that wraps the Management API, allowing you to work with your dashboard resources from the command line while you’re developing.
  • Bulk endpoints to upsert large amounts of data in a single API request (more on specific endpoints below).
🌐
The Knock environment model. Knock uses the concept of logically-separated environments in order to ensure that development occurs separately from your production environment and that sensitive user data only exists in production. Your Knock account comes with two environments (Development and Production) by default, but you can add custom environments between them if you need additional environments in Knock to mirror your own development lifecycle. Keep the environment model in mind when planning the migration for each of the resources below.

While there is no one-size-fits-all approach to planning a migration to Knock, we recommend the following order as a starting point to ensure that any resources which are dependencies of other resources are migrated first:

1

Channels

The first thing you’ll need to do in order to send notifications through Knock is to set up the downstream providers that deliver your messages. In Knock, we refer to these services as Channels.

Channels are configured under the Integrations tab in your Knock dashboard. You can see a full list of supported channel types and providers here.

In addition to first-party integrations with message delivery platforms, Knock also offers convenient connections to customer data platforms (CDPs) and reverse ETL providers to bring your data into Knock (Sources).

You’ll want to configure your channels prior to building any workflows so that you can set the correct delivery methods for each of your notifications.

2

Workflows

Next, you’ll start building your Workflows. Workflows in Knock serve as containers for all of the logic and message templates associated with a given notification in your system. When you’re ready to start sending notifications, you’ll do so by triggering these workflows.

👣
Incremental migration. Sometimes circumstances will require an incremental migration of your notifications into Knock while maintaining your legacy notification system. In these cases, we recommend migrating your notifications by individual use cases/events rather than all use cases for a single delivery channel at a time. The latter approach will often require triggering both your legacy system and Knock for a single event in order to notify your users in the correct places, which can be difficult to maintain and iterate on as you work to complete your migration.

Knock’s environment model means that you’ll be creating all of your workflows and other dashboard resources in your Development environment, where you’ll commit and then promote changes to higher environments (like Production). Read more here.

You can assign one or more categories to your workflows. These can be used to power recipient preferences (which we will cover in more detail below).

Workflows are constructed from a trigger step, channel steps, and optional function steps. To learn more about creating the messages that are delivered by your workflows, you’ll want to become familiar with the building blocks of your notifications content:

  • Message template editor. The message template editor is where you’ll build the content of your notifications. You can use Variables to inject dynamic content at runtime.
  • Partials. Partials are content blocks that you can reuse across multiple templates.
  • Layouts. Layouts are the "frame" of your email notifications, where you define shared structure and styles.
  • Translations. Send message content in a user's preferred language with translations.

Workflows and their building blocks can be created in your Knock dashboard or programmatically with our Management API.

3

Users

Once you’ve configured the logic of the notifications that you’d like to send, you’ll need to give Knock the necessary data about your users in order to deliver those notifications.

The User object in Knock has a number of (optional) reserved attributes like name, email, and phone_number, but it can also store any number of custom properties which can be used in the logic and templates of your workflow; for example, you might want to deliver different messages based on a user’s role. These attributes can be updated at any time with subsequent upserts.

We offer a variety of ways to identify your users to Knock, so you’ll want to look over our guide on identifying recipients before you solidify your migration plan. If you’re planning to send notifications to push or chat channels, you’ll also need to review our guide on setting channel data to ensure that we can deliver your messages to the right place.

Remember, the Knock environment model means that you’ll need to identify production users directly into your Knock Production environment.

4

Objects and Subscriptions

After you’ve planned the migration of users into Knock, you may need to consider advanced use cases for non-user recipients (like a public Slack channel) or a resource in your system (like an order that has been placed) that doesn’t fit neatly under the concept of a “user.” In Knock, these resources can be modeled as Objects.

Subscriptions are an extension of objects and express the relationship between a recipient (the subscriber) and an object. When you trigger a notification to an object recipient, Knock will also fan out individual workflow runs to any recipients that are subscribed to the object. This is especially useful for examples like the order placement use case mentioned above: you can trigger an “order updates” workflow with an object that represents the order as the recipient, and we’ll notify any subscribed Users about the change without you needing to resolve the list of recipients in your system.

5

Tenants

If your notifications should be scoped to a particular workspace or organization, you’ll need to implement Tenants in your Knock integration. A tenant can be applied as context to a workflow trigger in order to apply per-tenant branding, per-tenant preferences, and scope in-app feed messages to particular tenants.

Enterprise plan feature. Per-tenant branding and per-tenant preferences are features of our Enterprise plan. If you’d like to find out more information about Enterprise plan features and pricing, please contact us at sales@knock.app.
6

Preferences

Once your recipients (both users and objects) and tenants have been migrated to Knock, you’ll want to consider delivery preferences for your notifications to give your users control of where and when they receive updates from your product. For more information on building a preference center in your app, check out the section on Completing your client-side integration below.

Knock’s powerful Preferences API allows your users to opt out of notifications based on the notification’s delivery channel_type, the category of the notification, the specific notification workflow, or a combination of these properties. You can also extend these preferences to be tenant-specific or to evaluate conditionally at runtime.

You can set environment-level default preferences (for example, maybe a given workflow should require a user to manually opt in to receive those notifications) as well as tenant-specific default preferences that will be overridden by a recipient’s individual preferences.

7

Schedules

Finally, for any notifications that you’ll send on a recurring basis or reminders that should be sent at a specific future date, our Schedules feature should be considered before you’re ready to finalize your integration.

Schedules can be set, updated, and deleted via API. Although they are recipient-specific, you can create a schedule for up to 100 recipients at a time.

For more information and in-depth guidance on specific use cases, please take a look at our example apps and the following guides:

Completing your client-side integration

Certain implementations will require some client-side work to build in-app UI in order to complete your integration. Knock provides out of the box UI components that you can use, but you can also implement our in-app feed API and React hooks in a headless way if you’d like to bring your own components and styles.

Here are some use cases that will require additional client-side planning:

  • In-app messaging. If you’re planning to use Knock-powered in-app messaging (whether that’s a notification feed for web or mobile, other in-product notifications like modals and banners, or custom components powered by our Message types feature), you’ll need to build a way to display those messages to your users. For more information on your preferred language or framework, visit the Building In-app UI section of our navigation menu.
  • User preferences. In order to power user preferences in Knock, you need to build a preference center in your application that gives your user control over the types of notifications they receive.
  • Chat app authentication. Some delivery channels like Slack require a way for your users to authenticate your app or bot into their workspace. Knock provides drop-in React components (SlackKit and TeamsKit) for both Slack and Microsoft Teams (coming soon!) that will help manage the process of authentication and storing the necessary information (access tokens, etc.) as channel data in Knock so that we can deliver your notifications.

Testing and observability

Testing your notifications and insight into any errors that occur are a key part of developing and deploying your Knock integration. Knock offers many tools and resources to help you ensure that your users are receiving the right messages at the right time:

Enterprise plan feature. In addition to the tools listed above, Enterprise plan customers have access to Extensions, our integrations with downstream providers that enable advanced observability and analytics for your notifications. If you’d like to find out more information about Enterprise plan features and pricing, please contact us at sales@knock.app.

Going to production

You’re finally ready to move to production – congratulations! Before you flip the switch and sit back to admire your work, here are a few last-minute items to check off your list:

  • Be sure to update your application’s API keys to point to your Knock Production environment.
  • Ensure that all of your work has been promoted to your Production environment.
  • If you’re using in-app messaging, generate a signing key and enable enhanced security mode for client-side requests in your Production environment. Both of these actions can be completed by navigating to Developers > API Keys in your Knock dashboard’s Production environment.

As always, we’re here to help. If you have any questions or run into issues as you build with our product, we hope you’ll let us know! Email us at support@knock.app and we’ll be more than happy to assist you.

Knock on. 🤘