How to use Tokens

Tokens are representations of data. When a workflow runs, tokens are replaced with real data.

A simple example of this can be seen with a workflow that sends a text message to the customer when they place an order. In the image below, you can see that the phone number needs to be specified in the "To phone number" field.

In order to send the text message to the customer that placed the order, we need to use a token that represents the phone number for the order that triggered this workflow.

To insert a token, click on the  {+} button next to the field. This will open up the token selector sidebar. Here, you can view all of the tokens that are available from previous steps in your workflow.

If we search for "phone", quite a few results appear. This is due to how Shopify structures their data. Since we want to send a text message to the customer, we can select the first token.

After selecting the token, we can add in a message and save the changes.

Now, when this workflow runs, the order that triggered it will determine the phone number to send the text to. For example, if we received an order from John Smith (123-456-7890), the workflow will send the text message to 123-456-7890.

Advanced usage

Tokens are parsed similarly to Shopify's Liquid syntax. This can be useful when you wish to manipulate data before it's processed.

In this example, we replace all tags that contain 'Spring Range' with 'Summer Range':

1. Select the token for the product tags

2. Double click on the token to edit it

3. Insert the replace filter to replace all tags that contain 'Spring Range' with 'Summer Range'

To learn more about Liquid syntax and its many functions, check out Shopify's Liquid documentation.

Storage and Secrets

You can access storage items and secrets as tokens using the syntax {{storage:<key>}} or {{secret:<key>}} (note the colon here, instead of a dot). 

For example, if your workflow had a storage item called "domain", you can access it using the token {{storage:domain}}.