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 tutorial, 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).
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 Channels and sources page in your dashboard account settings. 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.
With Knockās environment model, you can either create resources directly in your production environment, or create them in your development environment and promote them to production. Learn more about environments.
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.
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 documentation 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 documentation 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.
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.
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.
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 set the same schedule for up to 100 recipients at a time by providing a list of recipients. To set unique schedules for multiple recipients, you can create up to 1,000 schedules at a time with the bulk endpoint.
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 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:
An optional sandbox mode on each of your channels that allows you to generate and preview messages without sending them to your downstream provider for delivery.
Outbound webhooks for real-time updates on events that occur within Knock.
An Analytics page in your Knock dashboard for insight into the messages youāre sending across different workflows and delivery channels.
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 Platform > 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.