Using exec for Temporary Data Storage in Arigato
Overview
exec
is a temporary storage system that allows you to save and retrieve data within a single workflow execution in Arigato. This is useful for passing values between Actions, Conditions, and API requests without redundant calls or recalculating data.
Important: Data stored in exec
is erased after the workflow completes. It does not persist between workflow executions. Data does persist from a parent workflow to a subworkflow. Storing and retrieving data from exec can be done anywhere that accepts Twig Tokens within the app. exec
is only available in Canvas Workflows. Legacy workflows do not support this feature.
Basic Usage: Storing and Retrieving a Simple Value
Store a Simple Value
{% do SET_EXEC('discount_code', 'SUMMER25') %}
Retrieve the Value Later in the Same Workflow
Your special discount code is {{ exec['discount_code'] }}!
Use Case: Set a discount code at one point in the workflow and use it later in an email or metafield update.
Intermediate Usage: Storing AI-Generated Data
You can use SET_EXEC
to store AI-generated responses and use them later in the workflow.
Store an AI-Generated Product Summary
{% do SET_EXEC('ai_summary', "Summarize this product in one sentence." | ai({ context: product })) %}
Use the AI Summary in an Email or Metafield Update
"Product Summary: {{ exec['ai_summary'] }}"
Use Case: Generate an AI-powered product description once and reuse it in multiple Actions without making redundant API calls.
Advanced Usage: Storing API Responses and Using Them Later
You can capture responses from an API request and store them in exec
for later use.
Retrieve Data in a Custom Action from an External API and Store It
{% set result = RUN_ACTION("http_request", { method: "GET", url: "https://api.my-custom-api.org/v1/resource", headers: { "Content-Type": "application/json", "Authorization": "Bearer {{ shop.database.my_api_key }}" } }) %} {% if result.response.status_code == 200 %} {% set return_objects = result.response.body | from_json %} {% do SET_EXEC('api_result', return_objects) %} {% endif %}
Use the API Data Later in the Workflow
"Here’s the data we retrieved: {{ exec['api_result'] | json_encode }}"
Use Case: Fetch data from an external API and use it in later workflow steps without making multiple requests.
Using Exec Within a Custom Condition
A powerful way to use exec
in Arigato is by setting values directly inside a Custom Condition. Since Custom Conditions are just Twig code that must return "TRUE"
or "FALSE"
, you can use SET_EXEC
to store data and reuse it in later actions.
Example: Using AI to Determine Order Fraud Risk in a Custom Condition
Step 1: Store and Evaluate the Fraud Score in One Step
Instead of setting exec
in a separate action, you can generate and store the AI fraud score inside the Custom Condition itself:
{% do SET_EXEC('fraud_score', "Evaluate this order's fraud risk on a scale of 1 to 100. Return only the number." | ai({ context: order })) %} {% if exec['fraud_score'] < 30 %} TRUE {% else %} FALSE {% endif %}
What This Does:
- Calls AI inside the Custom Condition and stores the fraud score in
exec['fraud_score']
. - Immediately evaluates whether the score is less than 30 and returns
"TRUE"
or"FALSE"
. - Makes the fraud score available in
exec
for later use in the Workflow.
Step 2: Use the Stored Fraud Score to Add a Note to the Order
Since the fraud score is stored in exec
, we can reference it later to log why the order was canceled.
Add an Order Note Using exec
Data
Fraud score was {{ exec['fraud_score'] }}, so the order was cancelled.
Why This Matters:
- Without
exec
, the AI response would only be available inside the Custom Condition and lost afterward. - Storing the fraud score ensures it can be used anywhere.
- This provides better visibility into why actions (like cancellations) happened.
Why Use SET_EXEC Inside a Custom Condition?
- By setting and using
exec
within a Custom Condition, you can store decision outcomes and keep data accessible for the rest of the Workflow—whether it's for notes, emails, or further actions.
Related Documentation: