Liquid Templating

An introduction to our powerful templating language

What is Liquid?

Liquid is a templating language created by Shopify and used extensively by others to create dynamic content. It's useful for referencing variables, modifying text (for example truncating) and for creating basic logic (if statements, for loops etc).

Liquid can be used in most areas throughout our product, including:

  • Input boxes in Workflows

  • LLM Prompts

  • Text Steps

  • Memory Search Steps

  • JSON Steps

Code Steps do NOT use Liquid Syntax!

How to Reference Inputs with Liquid

This section will walk through how to reference your pre-defined input variables.

  1. Ensure that you have configured an Input step

  2. If you did not enter a separate variable name, use the default variable name to reference the input value

  3. Click the purple Variable Selector to see a list of your available inputs and select the desired input

In the example below, we walk through using our input variable value, and referencing it in our LLM Step using Liquid syntax.

How to Reference Outputs with Liquid

Just like with inputs, you can reference the outputs of any prior step of your Workflow in any subsequent step.

Currently, step names are automatically defined incrementally, e.g. step_1 ,step_2 , step_3 , etc.

To reference the output of a step, simply click the step_number pill or manually type it in in the format {{step_12.output}} . If that step outputs JSON, then you can reference any of the sub-keys.

In the example below, we walk through how you can view the full list of available variables and use the proper syntax to call them within your Workflow.

We encourage you to explore our built-in templates, as many of them cover complex and useful references to input or output variables. We'll cover a couple of the more popular use-cases here.

For Loops

Liquid syntax is particularly useful for referencing variables as you iterate through values.

The screenshot below is taken from our "Article Merge" template. In this case, the highlighted syntax shows how you can loop over the results of our step_12 Iterator step to consolidate the information.

Additional useful looping cases include:

Pass the results of your Memory Search step into an LLM Step:

{% for result in step_x.output %}
    {{result.content}}
{% endfor %}

Manage your Memory Search Step with Metadata:

{% for result in step_x.output %}
    Title: {{result.metadata.title}}
    Description: {{result.metadata.description}}
{% endfor %}

Formatting

One of the more useful applications for Liquid syntax is combining it with our Text Step to perform additional formatting and ensure your output looks exactly the way you desire.

The screenshot below is taken from our "Personalized B2B Welcome Email" template. It showcases how we reference the output of previous steps (even pulling specific array elements as variables) to format our "step_2" into a more readable and organized output.

More Information

For additional information regarding Liquid, we recommend reviewing Shopify's Documentation.

Last updated