> For the complete documentation index, see [llms.txt](https://native-app-co.gitbook.io/stork-credit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://native-app-co.gitbook.io/stork-credit/integrations/shopify-flow.md).

# Shopify Flow

Issue store credit from any Shopify event using the Stork Credit action in Shopify Flow, and start workflows whenever Stork Credit issues credit.

Stork Credit ships a Shopify Flow action, **Add Store Credit**. Any Flow trigger can lead to it, which makes Flow the escape hatch for reward logic the automation forms don't cover — refunds, product reviews, subscription milestones, support outcomes, tag changes.

It also ships a Flow trigger, [**Store Credit Issued**](#the-store-credit-issued-trigger), which starts a workflow each time Stork Credit issues credit to a customer.

Flow is a free Shopify app. Install it from the Shopify App Store if you don't have it.

## The Add Store Credit action

Add the action to any workflow and fill in its fields.

| Field               | Required | Description                                                                 |
| ------------------- | -------- | --------------------------------------------------------------------------- |
| **Email**           | Yes      | The recipient. A customer is created if none exists with this address       |
| **Amount**          | Yes      | The credit amount, e.g. `10.00`                                             |
| **Currency**        | No       | ISO code such as `USD`. Defaults to your shop's primary currency            |
| **Expires on**      | No       | `YYYY-MM-DD`. Leave blank for credit that never expires                     |
| **Notify customer** | No       | Tick to send the customer Shopify's store credit email. Unticked by default |

The text fields accept Flow variables, so the amount can be calculated from the triggering event.

## Building a workflow

{% stepper %}
{% step %}

#### Pick a trigger

Anything Flow offers — *Order created*, *Customer created*, *Refund created*, *Product review published*, and so on.
{% endstep %}

{% step %}

#### Add conditions

Optional, but this is where Flow earns its place. Filter on order value, customer tags, product type, or any field the trigger exposes.
{% endstep %}

{% step %}

#### Add the Stork Credit action

Search for **Add Store Credit** in the action list.
{% endstep %}

{% step %}

#### Map the fields

Set **Email** to the customer's email from the trigger. Set **Amount** to a fixed value or a Flow expression.
{% endstep %}

{% step %}

#### Turn the workflow on

Test it with a real event before relying on it.
{% endstep %}
{% endstepper %}

## Ready-made templates

Stork Credit publishes Flow templates you can install and edit rather than starting from scratch:

* **Store credit based on order total** — tiered credit scaled to what the customer spent.
* **Store credit for new customers** — a welcome balance on first order.
* **Store credit 90 days after an order** — a delayed win-back reward.

Find them in the Flow editor's template gallery, or click **Open Flow** from the Stork Credit home page to jump straight there.

There are also seven more workflows you can download and import, covering welcome credit, spend rewards, VIP tags, cancelled orders and win-backs. See [Shopify Flow templates](/stork-credit/integrations/flow-templates.md).

## What the action returns

The action returns the issued amount, its currency, and the customer's **balance after the transaction** — so later steps in the same workflow can use them, for example in a customer notification or an internal Slack message.

If the credit fails, the action returns an error status with the reason, and later steps can branch on it.

## Notifications

By default the Flow action doesn't email the customer. To send Shopify's store credit email when the credit is issued, tick **Notify customer** on the action. Workflows you built before this option existed keep working as they did, with no email, until you tick it.

If you'd rather write your own message, leave **Notify customer** unticked and add an email step after the action instead. It can use the issued amount and the customer's new balance that the action returns.

{% hint style="info" %}
Don't tick **Notify customer** and add your own email step in the same workflow, or the customer gets two emails about the same credit.
{% endhint %}

## The Store Credit Issued trigger

Use **Store Credit Issued** as the first step of a workflow to react whenever Stork Credit issues store credit — tag the customer, send your own email, post to Slack, or add a row to a spreadsheet.

The trigger passes these fields to the rest of the workflow:

| Field             | Description                                                                                  |
| ----------------- | -------------------------------------------------------------------------------------------- |
| **Customer**      | The customer who received the credit, with all their Shopify data — email, tags, total spent |
| **Amount**        | The amount of credit issued                                                                  |
| **Currency**      | ISO code such as `USD`                                                                       |
| **Source**        | How the credit was issued: `Automation`, `CSV import`, `Flow` or `External trigger`          |
| **Campaign name** | The **Title** of the automation that issued the credit. Blank for the other sources          |
| **Expires at**    | When the credit expires, as a date and time. Blank for credit that never expires             |

Add a condition on **Source** or **Campaign name** to run the workflow for some credit only. For example, a condition of *Campaign name is equal to Spring VIP reward* limits it to that one automation.

{% hint style="info" %}
The trigger only starts for store credit issued by Stork Credit. Credit you add by hand in the Shopify admin, or that another app issues, doesn't start it — Shopify doesn't report that activity to apps.
{% endhint %}

{% hint style="warning" %}
Be careful combining this trigger with the **Add Store Credit** action in the same workflow. The action issues credit, which starts the trigger again, so the workflow repeats without stopping. If you need both, add a condition that **Source** is not equal to `Flow`.
{% endhint %}

Renaming an automation changes the **Campaign name** it sends from then on, so update any workflow conditions that match on the old title.

For an order-value automation that [waits for fulfillment or a set time](/stork-credit/automations/order-value-automations.md#when-credit-is-issued), the trigger starts when the credit is actually issued at the end of the wait, with the amount issued. Credit that is cancelled during the wait never starts it.

## Flow or an automation?

| Use an automation when…                                                                         | Use Flow when…                                                 |
| ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| The reward is based on a paid order, issued straight away or after it's fulfilled or a set wait | The trigger is anything other than a paid order                |
| The rules fit the form's options                                                                | You need branching, or several actions in sequence             |
| You want run history inside Stork Credit                                                        | You want the logic visible alongside your other Flow workflows |

Both write to the same customer store credit balance, and both are counted in the app's reporting.

## Plan limits

The **Store Credit Issued** trigger works on **every plan** and has no allowance.

The Stork Credit Flow action works on **every plan**, including Free. Each plan includes an allowance for the **value** of store credit it issues:

| Plan     | Flow credit per month |
| -------- | --------------------- |
| **Free** | $1,000                |
| **Grow** | $1,000                |
| **Pro**  | $1,000                |

The allowance is the total value of credit the action issues in a billing period, in your store's currency. It resets with your billing period (see [Plans & billing](/stork-credit/reference/plans-and-billing.md#monthly-limits)). Your usage against it is shown on the app home page in the **Plan & usage** card, as **Flow credit issued**.

If your workflows issue credit in more than one currency — for example a different amount for each market — **Flow credit issued** lists a separate total for each currency. Amounts in different currencies are never added together.

{% hint style="info" %}
This allowance is not applied automatically. Going over it doesn't stop your workflows, fail the Stork Credit step, or change your bill — we review usage and get in touch if a store is consistently over it. If you expect to issue significantly more than this through Flow, [contact support](/stork-credit/reference/support.md) so we can plan for it.
{% endhint %}

{% hint style="warning" %}
The Flow action and the home page links to Flow are available on every plan, including **Free**. Each plan has a monthly number of Flow actions — see [Plans & billing](/stork-credit/reference/plans-and-billing.md#shopify-flow-credit).
{% endhint %}

See [Plans & billing](/stork-credit/reference/plans-and-billing.md).
