In-app message types
Knock’s in-app message template system is built on our concept of Message Types. Within the Knock model, a message type represents a type of message that you map to a UI component/element within your application to show to your users.
Knock comes with the following in-app messages types to use as message templates out-of-the-box, each of which maps to a component you’ll find in @knocklabs/react
- Banner (
<Banner />
) - Modal (
<Modal />
) - Card (
<Card />
)
Once a template type exists, you can use it in the Knock in-app template editor:
Variants
Message types can have one or more variants. For example, the card
template type comes with 3 variants:
- Default: content with an action URL to determine where the cell should route to.
- Single action: content with a single primary button.
- Multi-action: content with two buttons, one primary and one secondary.
When creating an in-app template, your content editors can select from the available variants and customize the message's contents based on the selected variant.
Schemas
A schema defines a message type and its variants. The schema indicates the fields a message type will have in the template editor and forms the structure of the message contents generated when a message is produced from an in-app step.
You can think of the schema as a blueprint for how the content editor will create the message template and what fields they can edit within that experience.
The template type schema in Knock determines its template editing experience which governs the content that will be returned by the Knock API and rendered in your UI components.
Customizing message types
Each message type and its variants can be customized or removed entirely. You can also introduce completely new in-app message types to match your product's needs. This can be especially useful if you want to build custom in-app UI elements and power their content generation using Knock.
An in-app message schema has the following structure:
Variants
Your schema must have one or more variants. You can name your variants anything you would like, but the variant key must be unique.
Each variant must have:
- A
key
uniquely identifying the variant for the message type - A
name
to display in the message template editor to select the variant - One or more
fields
(see below)
Fields
All fields must have:
type
: The type of the field to render (see below)key
: A unique key for the field in the variantlabel
: A label to render
Field types
Creating an in-app message template in Knock
To create an in-app message in Knock:
- Add an in-app channel step to your workflow.
- Select which message type to use for the in-app message (and its variant, if applicable).
- Customize the contents of the in-app message in the template editor.
Versioning in-app message types
Message types are versioned using Knock’s commit model, meaning changes to a message type schema are committed into the current environment. Workflows use the latest committed version of a message type.
Triggering in-app messages
In-app messages are just another channel step within the Knock workflow builder, meaning that it’s possible to trigger an in-app message in the same way that you can trigger a workflow today:
- via the API
- via a source event being ingested
- via a recurring or one-off Schedule
- via a subscription to an object
- via being added to an audience
For more information, see the documentation for triggering workflows.