Set up the Run Function action in Shopify Flow
Once you have a saved function, you connect it to a workflow with the Run Function action in Shopify Flow. This page covers the action's configuration screen, what it sends to your code, and what it gives back to the rest of your workflow.
Add the action to a workflow
- Open Flow in your Shopify admin and create or edit a workflow.
- Set up your trigger as usual, for example Order created.
- Click the + to add a step and choose Action.
- Search for Run Function and select it.
The action now appears in your workflow and needs to be configured.
The configuration screen
The Run Function action has two parts.
1. Function
Click the action, then open its configuration. You get a Function dropdown listing every function in your store.
- Pick the function this step should run.
- Disabled functions still appear in the list, marked
(disabled). If you select one, the workflow will report an error at run time. Enable it on the function's Settings tab first. - Click Save in the top bar of the configuration screen. You will see a "Configuration saved" confirmation.
The selection is stored per workflow step. If you use the Run Function action twice in the same workflow, each one has its own function selection.
2. Input (JSON)
Back on the action itself, there is an Input (JSON) field. This is the data your function receives as input.
- It must be a JSON object.
- You can insert Flow variables with Liquid, which is how you get the triggering order, product, or customer into your code.
- Leave it blank to pass an empty object
{}.
A minimal example:
{ "orderId": "{{order.id}}", "threshold": 100 }
See Passing variables into your function for the full picture, including how to insert Flow variables, what happens with invalid JSON, and how to handle lists.
What your function gets back to Flow
When the run succeeds, the action returns three fields you can use in later Flow steps:
| Field | Type | What it holds |
|---|---|---|
status |
Text | SUCCESS |
output |
Text | Your return value, as a JSON string |
durationMs |
Number | How long the run took, in milliseconds |
output is a JSON string, not an object. Flow cannot index into it, so you cannot write output.tagged. If you need a single value in a later step, the practical options are:
- Return a plain string or number from your function instead of an object, so
outputis directly usable. - Do the branching inside your function and act on the result there.
- Split the work across two Run Function steps, where the second one reruns the logic it needs.
When a run fails
If the function returns an error, times out, or is disabled, the action fails and the workflow stops on that branch. The error message from your function is what Flow shows.
Common causes:
| What Flow shows | What to do |
|---|---|
| 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 |
| 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, successful or not, is recorded in History in the Workflow Functions app with its input, output, logs, and error. That is the first place to look when a workflow behaves unexpectedly.
Retries and duplicate runs
If Flow retries the same action execution, the app returns the result of the earlier successful run instead of executing your code a second time. That means a retry does not double-charge your quota and does not repeat side effects such as creating a discount code twice.
This only applies to Flow's own retry of the same action execution. If your workflow itself triggers again, that is a new run.
Testing the wiring
The fastest way to verify everything is connected:
- Turn the workflow on in Flow.
- Trigger it, for example by creating a test order.
- Open History in Workflow Functions. You should see a run with trigger Flow.
- Open the run to check the input Flow actually sent, your logs, and the output.
If the input is empty or missing fields you expected, the problem is almost always the Input (JSON) field on the action, not your code.
Turning a function off safely
To stop a function without editing your workflows, open the function and turn Enabled off on the Settings tab. Flow keeps running the workflow, but the Run Function step reports an error until you enable it again. To stop the workflow entirely, turn the workflow off in Flow.
Next steps
- Passing variables into your function for the Input (JSON) field in detail.
- Creating and using secrets for API keys used by your code.