Using Tokens
Tokens are the foundation of dynamic content in Arigato workflows. They represent real data from your trigger — like an order number, customer email, or product list — and let you insert that information into messages, webhooks, and other actions.
This guide walks you through using tokens, transforming them with basic Twig, and handling common patterns like loops.
What Are Tokens?
A token is a placeholder that gets replaced with live data when your workflow runs. Tokens work on their own, but when you want to transform, format, conditionally structure, or build lists, you’ll use Twig syntax.
Examples of simple tokens:
{{ order.name }}
{{ customer.email }}
These might output something like:
#1024 user@example.com
How to Insert a Basic Token
1. Open the Action or Condition where you want dynamic content (e.g., email subject or Slack message).
2. Click the token picker icon in the tray below the text area.
3. Browse or search for the value you want (e.g., “order name”).
4. Click on the token name.
5. Click Insert Token.
When you insert, you’ll see something like:
{{ order.name }}
When the workflow runs, that placeholder is replaced with the actual data from the event.
How Token Insertion Works
When you click Insert token, Arigato inserts the token into the text area that was most recently focused. It does not always insert into the field that appears visually active unless that field was the last one you clicked into before opening the token picker.
This means:
- If you click into a field, then click elsewhere on the page before inserting a token, the token may still go into the first field you clicked.
- This can be unexpected if you assume tokens always insert where your cursor *looks like* it is right now.
Tip for reliable insertion: Click into the exact spot in your text area where you want the token to appear, then open the token picker and select the token.
When You Need Twig
Tokens deliver data, but Twig lets you transform that data into exactly the format you need:
- Format dates and numbers
- Build lists (loops)
- Include content conditionally
- Join values into strings
- Clean or modify text
Twig is the expression layer that shapes token output so that it is ready for real use in emails, messages, and other Actions.
Loops — What You Need to Know
Some tokens represent collections (like order line items). When you choose one of these, Arigato may generate a loop block for you automatically:
{% for item in order.line_items %}
• {{ item.title }}
{% endfor %}
Important Loop Rule
Once you’re inside a loop block:
- Any tokens that refer to list items must be inside that loop block.
- If you put dependent tokens outside the loop, they won’t resolve correctly because the loop context (e.g.,
item) isn’t available there.
✔ Correct
{% for item in order.line_items %}
• {{ item.title }} × {{ item.quantity }}
{% endfor %}
✘ Incorrect
{% for item in order.line_items %}
• {{ item.title }}
{% endfor %}
Order quantity was {{ item.quantity }}.
In the incorrect example, item.quantity won’t resolve outside the loop because item is only defined inside the loop block.
Transforming Token Output with Twig
Once you understand tokens and loops, the next big unlock is transforming data to fit your needs.
Format a Date
{{ order.created_at | date("F j, Y") }}
Lowercase an Email
{{ customer.email | downcase }}
Comma-Separated List of Product Titles
{{ order.line_items | map("title") | join(", ") }}
Conditional Text
{% if customer.orders_count > 1 %}
Thank you for being a returning customer!
{% endif %}
Minimal Twig You’ll Use Right Away
Here are the core constructs that cover most use cases:
- Display a token
{{ order.name }}<br> - Loop
{% for item in order.line_items %} • {{ item.title }} × {{ item.quantity }} {% endfor %} - Condition
{% if customer.tags contains "VIP" %} 🎉 Thank you for being a VIP! {% endif %} - Filter
{{ order.total_price | number_format(2, ".", ",") }}
Inspecting Variables for Debugging
When you’re unsure what data is available or what it looks like, you can dump it:
{{ order | debug }}
This prints the entire object’s contents, which is useful for exploring available fields and data structure. Other ways of viewing data in the app include using the Preview system and the Data Inspector.
Where to Go Next
Once you’ve mastered basic tokens and simple Twig:
- Explore the full Twig reference for filters and helpers.
- Check out our recipes for common use cases.
- Use real examples to build up your templates piece by piece.