Getting startedSet up the Run Function action in Shopify Flow

Set up the Run Function action in Shopify Flow

Copy page

Connect a function to a Shopify Flow workflow end to end: trigger, Run Function action, input, configuration page, a real run and its history.

This walkthrough connects a function to a workflow in Shopify Flow, end to end: from the trigger to a real run you can inspect. The example sends every new order to an ERP with the verified template Push new orders to your ERP, with dryRun on so nothing is sent while you set it up.

Step 1: Choose a trigger

In your Shopify admin, open Flow, select Create workflow, then Select a trigger. This example uses Order created; any trigger works.

Shopify Flow's Select trigger panel searching for Order created
Pick the trigger that should run your function, here Order created.

Step 2: Add the Run Function action

Select the + under the trigger, choose Action, then Workflow Functions, and select Run Function.

Shopify Flow's Select action panel listing Workflow Functions with its description
In the action picker, open Workflow Functions.
Workflow Functions in Flow's action picker with its one action, Run Function
Run Function is the app's action: it runs one of your functions and returns its output to Flow.

Step 3: Set the input

The action has an Input (JSON) field. It becomes input in your code. Insert Flow variables with Liquid - here the id of the new order - and leave dryRun on while you test:

{"orderId": "{{ order.id }}", "dryRun": true}

Until you pick a function, the action shows To continue, select a function in the configuration. See Passing variables into your function for lists, quoting and invalid JSON.

The Run Function step before configuration, with an empty Input (JSON) field and Configuration not found
The new step: an Input (JSON) field, and the function still to choose.

Step 4: Choose the function

Select Edit next to Run Function. The Workflow Functions configuration page opens: pick the function from the list, select Save, then Exit to return to the workflow.

The Workflow Functions configuration page with Push an order to the ERP selected
The configuration page lists every function in your store. The choice is saved per workflow step.
The configured Run Function step with the Input JSON and the chosen function Push an order to the ERP
Configured: the step shows the input and the function it runs.

Step 5: Turn it on and run it for real

Name the workflow and select Turn on workflow.

Flow's Test your workflow can replay an existing order, but it only simulates app actions - Run Function shows Can't access the returned data there and does not run. To see a real run, trigger the workflow: here, by creating a test order.

The workflow Send new orders to the ERP turned on in Shopify Flow
The workflow is on. Every new order now runs the function.
Flow's run details for Send new orders to the ERP with the Run Function step completed
In Flow, Recent runs shows the workflow completed, including the Run Function step.

Step 6: Check the run in the app

Open History in Workflow Functions. The run appears with the trigger Flow. Open it to see the input Flow sent, the output, logs and timing.

The run detail in Workflow Functions: Flow trigger, the order id as input, and the ERP document as output
The same run in the app: the order id Flow sent, and the sales-order document the function built. With dryRun on, it was not sent.

When the output looks right, remove "dryRun": true from the Input (JSON) and add the secrets the template reads (ERP_ORDERS_URL, ERP_API_KEY).

What the action returns to Flow

Field What it holds
status SUCCESS
output Your return value as JSON text
fields One entry per top-level key of the returned object, each with key and value, so later steps can use single values without parsing JSON
durationMs How long the run took, in milliseconds

Return a flat object with the values you want to use later, for example { "tier": "gold", "total": 129.5 }. Flow limits an action's result to about 49 KB; when the output is too large for both, fields is left out and output still carries everything. The editor's test bench warns you before that happens.

When a run fails

If the function throws, times out or is disabled, the action fails and the workflow stops on that branch with the function's error message. Common causes:

No function configured for this action

Open the action configuration and select a function.

The configured function no longer exists

The function was deleted. Select another one.

A function is disabled

Enable it on the function's Settings tab, or grant the permission it needs.

Plan limit reached

You have used your rolling 30-day run quota. Upgrade your plan.

This account has been suspended

Contact support.

Every attempt is recorded in History with its input, output, logs and error. See Run history and troubleshooting.

Retries do not run twice

If Flow retries the same action execution, the app returns the result of the earlier successful run instead of running your code again - no second charge to your plan and no repeated side effects. A new trigger is a new run.

Turning a function off

Turn Enabled off on the function's Settings tab: the workflow keeps running, and the Run Function step reports an error until you enable it again. To stop everything, turn the workflow off in Flow.

Next steps