Using Tokens, Editing Templates & Custom Coding

Updated April 03, 2020 17:26

Please note, templates in Arigato Automation use Twig, not Liquid! More on that under Using Twig Syntax below.

Using Tokens

Some actions allow you to insert tokens, which is the data available to your action that is coming from a Shopify webhook event. A "{t}" button will be shown in the field where applicable. Clicking the button will open the searchable Token Browser.

Select a field in your action that you want to insert the token, and then click on the token you want to use in the Token Browser. The token will be automatically inserted wherever your cursor is.

Token Browser Example

Some tokens which are lists (or arrays) of information will automatically create a loop for you.

The example below shows how to display a list of variant titles for a newly paid order:

Step 1: Click the token browser button to open the Token Browser.

Step 2: Type in the token you want to insert, such as "variant". Click somewhere inside the "Message" action field where you'll want the token inserted.

Step 3: Click on the token you want to insert and the token will appear there. Array tokens will automatically create a loop for you.

You may even see cases where there are two or three nested loops, such as:

Functions

There are some helpful built-in functions for making redundant tasks easier. These can be found in the Token Browser by searching for "function". Functions can have arguments which help control how they work. For example, depending on whether you are sending an HTML email or a Slack message, the "html:true" argument will help control whether the function renders HTML.

The following example shows the "format_address()" function which can automatically format an address with street, company, city, state, and ZIP.

Using Twig Syntax

Twig is a templating engine (similar to Shopify's Liquid) that allows you to perform some basic string and array manipulation. Common uses are listed below. You may also read the Official Twig Documentation. See below for additional custom filters in Arigato Automation and filters that act similarly to Liquid.

Custom Filters in Arigato Automation

Twig does not natively provide a matching filter for all the Liquid filters you may be accustomed to. We've added support for these filters in Arigato Automation, and a few other handy filters. Note that Twig syntax is very similar but not identical to Liquid.

to_json

Converts any object or array to json. This is extremely handy when you need to dump all variables in an array to inspect them.

Shortens a string down to the number of characters passed as a parameter. If the number of characters specified is less than the length of the string, an ellipsis (…) is appended to the string and is included in the character count.

Convert one item in an associative multi-dimensional array to a comma-separated list

The array, in this case, has several objects, each containing 3 data points: "code", "amount", and "type". We're only looking for the codes in this case. The end result would look like this: code1, code2, code3.

{{ order.discount_codes | map('code') | join(', ') }}

Strip certain HTML tags

This series of filters ensure that the rendered HTML is not HTML encoded. Add the tags you want to preserve.