From 84eb7412a1d4b65974fc10f48f4abea7bf310c08 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 24 Feb 2026 18:33:24 +0000 Subject: [PATCH 1/3] Document subscriptions filter and dynamic data filters - Add subscriptions filter section to 'Referencing data in templates' page with examples for loading subscriptions by static and dynamic identifiers - Add 'Dynamic data filters' section to liquid helpers reference documenting user, object, tenant, and subscriptions filters in a reference table - Add 'Referencing subscriptions in templates' section to subscriptions concept page with usage example and link to full docs - Add callout on referencing-data page linking to the new dynamic data filters reference section - Update frontmatter tags to include new filter keywords Co-authored-by: Chris Bell --- content/concepts/subscriptions.mdx | 13 +++++ .../reference-liquid-helpers.mdx | 33 ++++++++++++- content/template-editor/referencing-data.mdx | 49 ++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/content/concepts/subscriptions.mdx b/content/concepts/subscriptions.mdx index 1efd57ef7..323f66863 100644 --- a/content/concepts/subscriptions.mdx +++ b/content/concepts/subscriptions.mdx @@ -132,6 +132,19 @@ As an example, if you have a property `role` under your subscription properties, } /> +## Referencing subscriptions in templates + +You can use the `subscriptions` Liquid filter to dynamically load up to 25 active subscriptions for a user in your notification templates. This is useful when you want to render content based on what a user is subscribed to without passing subscription data in the workflow trigger. + +```liquid title="Rendering a user's subscriptions in a template" +{% assign subs = recipient.id | subscriptions %} +{% for sub in subs %} + {{ sub.object.id }} - {{ sub.properties.role }} +{% endfor %} +``` + +For more details, see [referencing data in templates](/template-editor/referencing-data#referencing-subscriptions-via-the-subscriptions-filter). + ## Modeling nested subscription hierarchies It's possible to model nested subscription hierarchies by associating child objects as subscribers of a parent object. This allows you to create structures like "organizations" having many "teams" which have many "team members" (users). diff --git a/content/template-editor/reference-liquid-helpers.mdx b/content/template-editor/reference-liquid-helpers.mdx index 791d86328..5e1fb1eb1 100644 --- a/content/template-editor/reference-liquid-helpers.mdx +++ b/content/template-editor/reference-liquid-helpers.mdx @@ -1,7 +1,7 @@ --- title: "Liquid helpers" description: A reference to help you work with the Liquid templating language in Knock. -tags: ["liquid", "template", "variables", "currency", "timezone", "pluralize"] +tags: ["liquid", "template", "variables", "currency", "timezone", "pluralize", "user", "object", "tenant", "subscriptions"] section: Working with templates --- @@ -201,6 +201,37 @@ The Knock template editor uses Liquid syntax for control flow and variable decla ]} /> +## Dynamic data filters + +Knock provides a set of Liquid filters that dynamically load data from your Knock environment at template render time. These filters enable you to reference entities like users, objects, tenants, and subscriptions in your templates without passing all of the data in your workflow trigger call. For more details and examples, see [referencing data in templates](/template-editor/referencing-data). + + + ### Date format options The `format_date_in_locale` and `format_datetime_in_locale` helpers accept date format options that control how the date portion is displayed: diff --git a/content/template-editor/referencing-data.mdx b/content/template-editor/referencing-data.mdx index 6b8cc03df..8d93c1857 100644 --- a/content/template-editor/referencing-data.mdx +++ b/content/template-editor/referencing-data.mdx @@ -1,14 +1,31 @@ --- title: "Referencing data in templates" description: Documentation outlining how to work with data in your templates. -tags: ["liquid", "template", "objects", "users", "tenants"] +tags: ["liquid", "template", "objects", "users", "tenants", "subscriptions"] section: Working with templates --- -In addition to the [variables](/template-editor/variables) available as part of the workflow run scope, you can also reference data from the users, objects, and tenants that exist within your Knock environment. +In addition to the [variables](/template-editor/variables) available as part of the workflow run scope, you can also reference data from the users, objects, tenants, and subscriptions that exist within your Knock environment. Referencing data is a powerful way to share context across entities in your templates without needing to manually pass the data in the `data` argument of your workflow trigger. + + The user, object, tenant, and{" "} + subscriptions filters all dynamically load data from your + Knock environment at render time. You can find a full reference of these + filters in the{" "} + + liquid helpers reference + + . + + } +/> + ## Referencing users via the `user` filter To reference a user, you can use the `user` filter. This will return a serialized `User`, which you can then use to output data in your template. @@ -70,6 +87,34 @@ Tenants returned will have all custom properties available, as well as the `id`, {% assign tenant = data.other_tenant_id | tenant %} ``` +## Referencing subscriptions via the `subscriptions` filter + +To reference the subscriptions for a user, you can use the `subscriptions` filter. This filter loads up to 25 active subscriptions for the given user and returns a list of serialized subscription objects. + +Each subscription returned includes the `object` the user is subscribed to, along with any custom `properties` set on the subscription. You can iterate over the results to render subscription-specific content in your templates. + +```liquid title="Loading subscriptions for the current recipient" +{% assign subs = recipient.id | subscriptions %} +{% for sub in subs %} + {{ sub.object.id }} - {{ sub.properties.role }} +{% endfor %} +``` + +
+ +```liquid title="Loading subscriptions for a user via a dynamic identifier" +{% assign subs = data.user_id | subscriptions %} +{% for sub in subs %} + {{ sub.object.id }} +{% endfor %} +``` + + + ## Frequently asked questions From e213f0a859aafa8a4672c0deba5a2c34d5122ed1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 24 Feb 2026 18:37:21 +0000 Subject: [PATCH 2/3] Fix Prettier formatting in liquid helpers reference Co-authored-by: Chris Bell --- .../template-editor/reference-liquid-helpers.mdx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/content/template-editor/reference-liquid-helpers.mdx b/content/template-editor/reference-liquid-helpers.mdx index 5e1fb1eb1..d3080d6c3 100644 --- a/content/template-editor/reference-liquid-helpers.mdx +++ b/content/template-editor/reference-liquid-helpers.mdx @@ -1,7 +1,19 @@ --- title: "Liquid helpers" description: A reference to help you work with the Liquid templating language in Knock. -tags: ["liquid", "template", "variables", "currency", "timezone", "pluralize", "user", "object", "tenant", "subscriptions"] +tags: + [ + "liquid", + "template", + "variables", + "currency", + "timezone", + "pluralize", + "user", + "object", + "tenant", + "subscriptions", + ] section: Working with templates --- @@ -227,7 +239,7 @@ Knock provides a set of Liquid filters that dynamically load data from your Knoc [ "subscriptions", "Loads up to 25 active subscriptions for a user by their identifier. Returns a list of subscription objects, each containing the subscribed object and any custom properties set on the subscription.", - '{% assign subs = recipient.id | subscriptions %}', + "{% assign subs = recipient.id | subscriptions %}", ], ]} /> From 736bea5a41cfb962dae0da503f33928dd67a27a7 Mon Sep 17 00:00:00 2001 From: Chris Bell Date: Wed, 18 Mar 2026 16:39:13 -0400 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Matt Kufchak --- content/template-editor/reference-liquid-helpers.mdx | 2 +- content/template-editor/referencing-data.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/template-editor/reference-liquid-helpers.mdx b/content/template-editor/reference-liquid-helpers.mdx index d3080d6c3..582f1c221 100644 --- a/content/template-editor/reference-liquid-helpers.mdx +++ b/content/template-editor/reference-liquid-helpers.mdx @@ -238,7 +238,7 @@ Knock provides a set of Liquid filters that dynamically load data from your Knoc ], [ "subscriptions", - "Loads up to 25 active subscriptions for a user by their identifier. Returns a list of subscription objects, each containing the subscribed object and any custom properties set on the subscription.", + "Loads up to 25 active subscriptions for a user by their identifier. Returns a list of subscription objects, each containing the subscribed Object and any custom properties set on the subscription.", "{% assign subs = recipient.id | subscriptions %}", ], ]} diff --git a/content/template-editor/referencing-data.mdx b/content/template-editor/referencing-data.mdx index 8d93c1857..42180da95 100644 --- a/content/template-editor/referencing-data.mdx +++ b/content/template-editor/referencing-data.mdx @@ -19,7 +19,7 @@ Referencing data is a powerful way to share context across entities in your temp Knock environment at render time. You can find a full reference of these filters in the{" "} - liquid helpers reference + Liquid helpers reference .