Skip to main content

Template Examples

These examples show common ways to use a template. Replace the placeholder names with the fields your workflow provides, and create each one as described in Creating a Template.

JSON request body​

Type: JSON. Build the body for a REST call from workflow data.

{
"customer": "{{customer.name}}",
"points": {{customer.points}},
"items": {{json order.items}}
}

Quote text values. Leave numbers and booleans bare. Use json for a whole object or list. For example, with customer.name set to Ada, customer.points set to 120, and one item, the result is {"customer": "Ada", "points": 120, "items": [{"sku": "A1"}]} in a single document.

XML payload​

Type: XML. Keep a single root element.

<order id="{{order.id}}">
<customer>{{customer.name}}</customer>
{{#each order.items}}
<item sku="{{sku}}" quantity="{{quantity}}"/>
{{/each}}
</order>

Values are escaped for markup, so a name such as Smith & Sons is written safely.

HTML email​

Type: HTTP (HTML). Do not add scripts, inline event handlers, or javascript: links.

<h1>Thank you, {{customer.name}}</h1>
<p>Your order {{order.id}} is confirmed.</p>
<ul>
{{#each order.items}}
<li>{{name}}: {{quantity}}</li>
{{/each}}
</ul>
{{#if order.gift}}
<p>We will include a gift note.</p>
{{/if}}

Plain-text message​

Type: Text. Nothing is escaped, so use it for SMS or log lines.

Hi {{customer.name}}, your order {{order.id}} ships on {{formatDate order.shipDate "YYYY-MM-DD"}}.

Choose between two blocks​

Type: Text. The same blocks work in an HTTP (HTML) template. In a JSON template, make sure each branch writes valid JSON.

{{#if (gt customer.points 1000)}}
Gold member: free shipping.
{{else}}
Standard shipping applies.
{{/if}}

Share one template across workspaces​

  1. Create the template at the Organization level and publish it. To share a template that already exists in a workspace, promote it instead. A promotion cannot be undone and fails if the organization already has a template with that name.
  2. In each workflow, select the template in the Template activity. It shows (Organization) after the name.

Workflows that already used a promoted template keep working.