Update workflow data function
Learn more about the update workflow data function within Knock's notification engine.
An update workflow data function updates properties on the workflow data state as a step in a workflow. Any data set by an update workflow data function is merged into the original trigger data provided on workflow trigger and made available to all subsequent steps in the workflow.
Configuring data properties
#To configure an update workflow data function, you can add key-value pairs in the step editor or use the code editor to input a JSON object directly. Each key represents a property name that will be set on the workflow data, and each value can be either a static value or a Liquid expression.
Each value field is a Liquid-compatible input. This means you can use Liquid variables and control flow to inject variable data, access Knock-controlled workflow state attributes (e.g., recipient), and dynamically compute values per workflow run.
Here are some example configurations:
See the Knock template editor reference for detailed information on working with Liquid templates in Knock.
Merging data
#When an update workflow data function executes, Knock will merge the configured properties into the data you originally passed to the workflow trigger call. Knock uses a shallow-merge strategy where:
- Data from the update workflow data step overwrites the original workflow run data.
- Top-level attributes are merged, and nested attributes are completely overwritten.
The merged data result from an update workflow data function step then becomes the global trigger data for all subsequent steps in the workflow run.
The example below illustrates how this could look in practice.
Debugging update workflow data functions
#You can use the workflow run logs to debug your update workflow data function steps. For each update workflow data function, you can expect to see in the logs:
- The computed data that was merged into your workflow run state.
See the documentation on debugging workflows for more details about workflow debugging and run logs.