Variables

A reference guide for the variables available in the template editor.

When you build workflows in Knock, we auto-generate certain pieces of state (as a result of batch functions and other workflow steps) that you can use to control the copy you display to your end users in your notification templates.

VariableDescription
actorA serialized Recipient of the actor that triggered the workflow (may be null). Will include any custom properties set.
actorsA list of up to 10 of the unique actors included within the batch.
recipientA serialized Recipient of the recipient of the workflow. Will include any custom properties set.
activitiesA list of the activity objects included within the batch, where each activity equals the state sent across in your trigger call, and also includes the actor who performed the message and a timestamp of when the activity occurred.
varsAccount and environment-specific variables.
total_activitiesThe count of activities associated with a workflow run.
total_actorsThe count of unique actors associated with a workflow run.
timestampThe time in which the activity occurred, as an ISO-8601 datetime string.
workflowA serialized Workflow (see below).
current_messageA serialized CurrentMessage (see below).
tenantA serialized Tenant (see below) which is set when a tenant is passed to the workflow trigger.
🌠
Note: all of the data supplied to your workflow trigger is always available for use in your template as top-level values (not nested under data) and is deep-merged into the set of variables above.

Recipient (User or Object)

A serialized User or Object. The properties available are:

VariableDescription
__typenameEither User or Object
idThe id of the recipient
collectionThe collection of the object (only set for Object recipients)
*Any custom properties set
created_atA datetime field for when the recipient was created (if set)
updated_atA datetime field for when the recipient was last updated
subscriptionAn optional set of properties set on a subscription. Only available when a workflow is triggered via a Subscription.
scheduleA serialized Schedule including the id, last_occurrence_at, and next_occurrence_at of the schedule. Only available when a workflow is triggered via a Schedule.

Activity

A serialized Activity, which represents a workflow trigger for the recipient. Activities may be accumulated during a batch operation. The properties available are:

VariableDescription
idThe unique id of the activity
*Trigger data sent that generated the activity
inserted_atThe datetime of when the activity was generated
updated_atThe datetime of when the activity was last updated

CurrentMessage

Provides access to the currently generated Message that the template is rendered against. The properties available are:

VariableDescription
idThe id of the message
inserted_atThe datetime of when the message was created
updated_atThe datetime of when the message was last updated

Workflow

Provides access to serialized properties about the currently executing workflow. The properties available are:

VariableDescription
idThe id of the version of the current workflow
keyThe unique key of the workflow
categoriesA list of categories set for the workflow

Tenant

A serialized Tenant. The properties available are:

VariableDescription
idThe id of the tenant
*Any custom properties set on the tenant
created_atA datetime field for when the tenant was created (if set)
updated_atA datetime field for when the tenant was last updated