Understanding actions in Shopify Flow
In a workflow, actions are the tasks that Flow performs when a workflow's conditions are met. Common actions include adding tags to orders or customers, sending emails or Slack notifications, updating inventory, holding fulfillment, canceling orders, and creating draft orders. You can also automate actions in third-party connector apps that you've installed, such as sending data to Google Sheets, Klaviyo, or ShipStation.
Actions can connect to any other type of step in a workflow, such as a trigger, condition, or another action. A workflow can contain any number of actions, and each step can connect to any number of actions for a single outcome. For example, if a condition is met, then you could connect 5 separate action steps when you want the workflow to do 5 things at the same time when the condition is true.
Choosing actions for your workflow
There are many different actions to choose from to accomplish a task during a workflow. Understanding which specific tasks can be automated in Shopify Flow can help ensure that your workflow operates correctly.
Actions fall into the following categories:
- Store actions: These actions change something in your Shopify store, such as adding tags, updating inventory, or canceling orders.
- Communication actions: These actions send customizable notifications through a platform of your choice, such as emailing yourself or your team, posting a message in Slack, or sending a marketing email to your customers.
- App actions: These actions do a task in a connected app. The available options depend on which app connectors are installed in your store. Not all apps have an associated connector to Shopify Flow.
- Advanced actions: These actions modify the workflow's behavior or data, including the following types:
- Get data actions: These actions fetch a list of additional data from your store that isn't provided by default in the workflow trigger to use in your workflow. These actions call a query with a set of filters, such as getting a list of product data updated in the last day.
- Aggregation actions: These actions perform calculations on list data in a workflow, such as Count or Sum.
- For each loop (iterate) action: This action allows you to perform a task on every item returned in a list, in a loop.
- Send request action: These actions are for sending and receiving data from the Shopify GraphQL Admin API or external APIs.
- Wait action: A unique type of action that stops the workflow from taking the next step until a set duration of time has passed.
When deciding how to implement your action when building a workflow, review the following considerations based on the task that you want the workflow to automate:
Confirm what data your workflow provides
Actions require data to function, and the data has to be provided to the action by either the trigger, or by including a Get data action during the workflow. If you select an action that doesn't receive the necessary data, then the workflow doesn't run and displays an error message. For example, a workflow that starts with the Customer created trigger imports customer data into the workflow. If this trigger is followed by an Add order tags action, which requires order data and not customer data, then the workflow results in a missing data error.
Why this matters: This is a common reason why custom workflows break or never work in the first place. Before finalizing your workflow, think about what information your action requires in order to complete the task, and make sure that the dataset being imported in the preceding steps can offer that data.
Confirm the timing of the actions in a workflow
Workflows operate as a series of steps. Because of the drag-and-drop canvas, you can design a workflow that completes multiple actions simultaneously, or organize it such that actions occur one after another. For example, if condition A is met, then you can have the workflow perform actions X and Y at the same time, or you can have the workflow perform action X, and then have the workflow perform action Y. This can be relevant when certain conditions or actions require other actions to have occurred previously in the workflow.
Actions typically happen immediately when a condition is met and the action step is next in the workflow, but you can also control when an action takes place using the Wait action. This can be helpful for workflows that automate customer communications, such as waiting a day before sending a marketing email to a new customer. How you choose to organize when actions take place during the workflow is up to you.
Why this matters: The timing of actions determines when tasks are performed in your workflow. Organizing actions to take place simultaneously or sequentially ensures that your automated tasks happen in the right order and meet your requirements. For example, by using the Wait action, you can control the timing of customer notifications or other follow-up tasks to suit your needs.
Adding variables in actions to return dynamic data
Variables can be used in action steps to insert dynamic data in custom text, such as in customer emails. These variables are formatted in the same GraphQL Admin API dot notation as used in conditions and wrapped in double brackets {{ }}. When used in actions, variables act as a placeholder that returns the specific value of the variable based on the data provided during the workflow.
For example, in the Send order invoice action, the Subject field for the email contains the order.name variable by default, and is formatted as "Invoice {{order.name}}". This means that when the email sends, the subject line of the final email reads "Invoice #1000" or whatever the order number is based on that value for the order.
When applicable, you can click Add variable to search for available variables in a field in an action. This lets you customize the content of any field based on the variables available for that action using Liquid. You can also add conditional statements in Liquid code using the variable to customize when content displays.
For example, in the same Send order invoice action, you might add the following content in the Custom message field, which contains several variables that include dynamic values based on the data provided by the workflow:
Hello {{order.customer.firstName}}! This is the invoice for order {{order.name}}, which you placed on {{order.createdAt}}.
{% if order.fullyPaid = 'false' %}
Please complete any outstanding payments in the next 5 business days.
{% endif %}Learn more about using variables to display or transform data in Shopify Flow.