Articles on: React Flow

Run Code

Run Code


In this article:

 

✔️ About the Run Code action


The Run Code action enables you to insert JavaScript blocks into your workflow, giving you complete control over logic, data transformation, and integration with Shopify's API. It’s ideal for advanced users who need more flexibility than what standard Flow blocks offer.


✔️ Key Benefits


1. Flexible Logic

Build custom logic that goes beyond the capabilities of standard workflow blocks. Whether it's conditional branching, calculations, or more complex data processing, the Run Code action handles it all.


2. JavaScript in Your Workflow

Use familiar JavaScript syntax to manipulate data, access variables, and define how your automation should behave. Compared to Liquid, JavaScript offers far more capabilities, making it easier to implement dynamic logic.


3. Access Additional Data

The Run Code trigger allows you to fetch and return extra data from the Shopify API, even data that standard React Flow blocks can't access. You can then use this information as variables or conditions in the following steps of your workflow.


4. Advanced Automation Scenarios

Handle complex or non-standard automation tasks without relying on external systems or complicated workarounds. This unlocks new levels of control and efficiency in your store's operations.


✔️ Workflow Example


Example: We want to assign the appropriate tag to a customer whose last 20 orders sum is greater than 5000.


  1. Open the app and click Create new -> Create from scratch.
  2. Click View templates in the Run Code block and select the “Tag customer by spend across the last 20 orders” template.



  1. Configure the ready-made template according to your needs. For example, you can set the value or add more conditions. Then go to the Add customer tag action and set the required tags.



  1. Save the workflow.


You can click “Run test” to check how this workflow is executed. And click “Turn on” if you are ready to activate it.


✔️ Next Step


This article offers a general overview of the Run Code functionality. If you'd like to explore the technical details, we recommend checking out our dedicated technical guide - Run Code Technical Guide.


Updated on: 04/07/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!