Modify workflow function
Learn more about the modify workflow function within Knock's notification engine.
A modify workflow function updates properties on the workflow data state as a step in a workflow. Any data set by a modify workflow 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 a modify workflow 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 a modify workflow 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 modify workflow step overwrites the original workflow run data.
- Top-level attributes are merged, and nested attributes are completely overwritten.
The merged data result from a modify workflow 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 modify workflow functions
#You can use the workflow run logs to debug your modify workflow function steps. For each modify workflow 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.