---
title: "Tutorial: react to a price drop with a before-and-after rule"
description: "Build a workflow from a blank canvas that starts only when a variant's price went down, and posts the old and the new price to Slack."
canonical: "https://docs.workflow-suite.app/tutorial-react-to-a-price-drop"
---

# Tutorial: react to a price drop with a before-and-after rule

Shopify tells you that a product changed. A change trigger tells you what changed, with the value before and after. In this tutorial you build, from a blank canvas, a workflow that starts only when a variant's price went down, and posts the old price, the new price and the difference to Slack.

**You need:** the secret `SLACK_WEBHOOK_URL` (see [Secrets](https://docs.workflow-suite.app/secrets.md)) and read access to products on the **Permissions** page.

## 1. Start blank

1. Open **Workflows** and select **Create blank workflow**.
2. The editor opens with the trigger **Run manually** and one problem: the workflow has no steps yet.
3. Replace **Workflow name** with `React to a price drop`.

![A blank workflow named React to a price drop: the Run manually trigger alone on the canvas, the button 1 problem in the toolbar and the trigger panel with Change trigger](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/8ea113b62a5b66d9.png)
*A blank workflow. The 1 problem button tells you what is still missing.*

## 2. Pick the change trigger

1. Select **Change trigger** in the side panel. The window **Choose what starts this workflow** opens.
2. Type `price` into the search box.
3. Pick **Product variant price changed**. Its description says what it carries: both prices before and after and the difference in percent.

![The trigger picker filtered by price: Product variant price changed under Products, Order line items changed under Orders and Draft order line items changed under Draft orders](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/e603c8facb2c3deb.png)
*Search the trigger picker. The Verified badge means we fired this trigger for real and checked the result.*

## 3. Start only when the price went down

The trigger fires for every price change, up or down. A trigger filter keeps the workflow from starting at all when the price went up, and a filtered event does not count against your plan.

1. In the trigger panel tick **Only start for some events**.
2. Under **Rule 1** open **Comparison** and pick **decreased**. The field turns into **Field that changed**.
3. Type `price` into **Field that changed**.

![The trigger panel of Product variant price changed with Only start for some events ticked and Rule 1: Field that changed price, comparison decreased, and a note that before-and-after rules need a trigger that reports which fields changed](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/7f61414048e92a48.png)
*A before-and-after rule on the trigger. Only price decreases start the workflow.*

> [!NOTE]
> Before-and-after rules (changed, changed to, changed from, increased, decreased) only work with a trigger that reports what changed, such as this one. On any other trigger such a rule never matches. See [Change triggers with before and after values](https://docs.workflow-suite.app/change-triggers.md).

## 4. Post the old and the new price

1. Press the **+** under the trigger and pick **Send Slack message**.
2. Set **Name** to `Post the price drop to Slack` and **Webhook URL** to `{{ secrets.SLACK_WEBHOOK_URL }}`.
3. Press the variable button next to **Message** and type `price` into the search box. The picker lists what this trigger carries: `old_price`, `new_price`, `price_delta`, `price_percent_change` and `price_direction`, each with a sample value.

![The Insert a variable window filtered by price for the trigger Product variant price changed: event.payload.old_price 24.99, event.payload.new_price 19.99, price_delta -5, price_percent_change -20.01 and price_direction decrease](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/0be3e3a13ca67abe.png)
*The before and after values of the change, ready to insert.*

4. Write the message, for example:

```
Price drop: {{ event.payload.title }} ({{ event.payload.variant.title }}) went from {{ event.payload.old_price }} to {{ event.payload.new_price }} ({{ event.payload.price_percent_change }}%)
```

5. Select **Save** in the bar at the top of the admin.

## 5. Test it

1. Select **Test** in the toolbar. The sample event of this trigger already contains a price decrease from 24.99 to 19.99.
2. Keep **Preview (nothing is changed)** and select **Run preview**.
3. Select the Slack step on the canvas: the panel shows the message as it would have been sent.

![After the preview the trigger and the Slack step are green; the side panel shows Test result Previewed with the rendered message Price drop: Example T-Shirt (Small) went from 24.99 to 19.99 (-20.01%)](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/3597e2c9bb9c8d29.png)
*The filter matched the sample event and the message rendered with the old and the new price.*

## 6. Turn it on

Select **Turn on**. The trigger panel says **Preparing: reading your existing products so the first change is not missed** until the app has read them, then **Ready**. A change trigger compares each event with what the app saw before, so the app reads your products once. The first change of a product the app has never seen only records the baseline; the second one starts the workflow.

![The workflow turned on: the On badge next to the name and the trigger panel of Product variant price changed reading Ready](https://cdn-dev.eu.codecreationlabs.cloud/crm-tool/uploads/SjJ78gKLnLlocopCui3Cs62dJbGZ7F1n/148b60ea430475d1.png)
*After Turn on the app reads your existing products once, so their first price change is not missed. The panel says Preparing while it does and Ready when it is done.*

## Make it yours

- Only big drops: add a second rule `price_percent_change` **is at most** `-20` on the trigger filter.
- Add a **Condition** instead of a filter when you want a different message for increases: [Conditions](https://docs.workflow-suite.app/conditions.md).
- Other change triggers work the same way: tags added, status changed, back in stock, metafield changed. See [Change triggers with before and after values](https://docs.workflow-suite.app/change-triggers.md).
