Abandoned cart reminder with a live check

An automation that waits after a cart goes idle, re-checks that it is still abandoned, then sends a library email to the shopper. A validated definition using a wait step and a live current.cart value.

When a cart goes idle, wait two hours, check the shopper has not come back or bought, then send them a reminder email. Trigger: checkout.abandoned@1. Steps: wait, condition on a live value, send_customer_email@1.

Model background: Automations.

The definition

{
  "schemaVersion": 1,
  "trigger": {
    "type": "checkout.abandoned@1",
    "origins": [
      "USER",
      "API",
      "MCP",
      "ASSISTANT",
      "BULK",
      "IMPORT",
      "DUPLICATE",
      "SYSTEM",
      "AUTOMATION"
    ],
    "filter": {
      "op": "all",
      "rules": [
        {
          "path": "event.facts.cart.subtotal",
          "op": "gte",
          "value": 30
        }
      ]
    }
  },
  "steps": [
    {
      "id": "pause",
      "type": "wait",
      "duration": {
        "amount": 2,
        "unit": "hours"
      }
    },
    {
      "id": "still",
      "type": "condition",
      "when": {
        "op": "all",
        "rules": [
          {
            "path": "current.cart.status",
            "op": "eq",
            "value": "ABANDONED"
          }
        ]
      },
      "then": [
        {
          "id": "remind",
          "type": "action",
          "contract": "send_customer_email@1",
          "input": {
            "customerId": {
              "$ref": "event.facts.customer.id"
            },
            "templateId": "TEMPLATE_ID",
            "kind": "marketing",
            "frequencyDays": 7
          }
        }
      ]
    }
  ]
}

Replace before saving:

  • TEMPLATE_ID: the id of a template in the store's campaign library. The email always sends the template's latest version.
  • The number 30: the smallest cart subtotal worth a reminder, in the cart's own currency.
  • frequencyDays (1 to 90, the run history it reads is kept 90 days): the shopper gets at most one email from this automation in that many days.

How it works

  • checkout.abandoned@1 fires when a cart goes idle. Its facts: event.facts.cart.subtotal, .currency, .itemCount, .lineCount, .productIds, .hasCoupon, .checkoutStarted, .via, .salesChannelId. Only customer actions and emails run under it, and no order tags.
  • A wait is a top-level step, 5 minutes to 90 days, at most 3 per definition. After a wait the facts are the old ones, so the condition tests the live value current.cart.status, read when the wait ends: ABANDONED (still idle), ACTIVE (the shopper came back), CONVERTED (they bought), MERGED. A cart deleted meanwhile ends the run SKIPPED with CART_NOT_FOUND.
  • A condition with no else that is false ends the run SUCCEEDED with the outcome CONDITION_NOT_MET: nothing was wrong, there was nothing to do.
  • The customer id is { "$ref": "event.facts.customer.id" }. A guest cart has no customer and the run skips.

What it does not do

  • It does not send when the shopper has not consented to marketing (NO_MARKETING_CONSENT), is suppressed (SUPPRESSED), has no address (NO_CUSTOMER_EMAIL) or already got one inside frequencyDays (FREQUENCY_CAP). kind: "marketing" carries the unsubscribe link and needs a business postal address on the store (NO_POSTAL_ADDRESS otherwise).
  • It does not stack on the store's own abandoned-checkout recovery emails. When those are switched on, this run ends SKIPPED with RECOVERY_EMAIL_ACTIVE, because nothing dedupes the two and the shopper would get a second reminder. Turn one of them off.
  • It does not mint a personal discount code. The authoring guide documents create_customer_coupon@1 for order and customer triggers only, so do not build a cart reminder on it.
  • It does not send while the store's emails are switched off (EMAILS_DISABLED) or while the platform holds marketing mail back (MARKETING_ON_HOLD).

Create it

With the Admin MCP:

  1. get_automation_guide with topic: "live-values", then "messages".
  2. validate_automation_definition. Fix every finding.
  3. test_automation with entity: { "type": "Cart", "id": "<a recent cart id>" }. The cart is tested as if it were abandoned right now, the wait is shown and never waited, and the condition is judged on today's value. Testing on a cart needs permission to view every order.
  4. create_automation_draft with name: "Abandoned cart reminder".
  5. Tell the merchant to approve it in the dashboard.

With the SDK:

const check = await admin.validateAutomationDefinition(storeId, { definition });
if (!check.ok) throw new Error(JSON.stringify(check.errors));

const draft = await admin.createAutomation(storeId, {
  name: 'Abandoned cart reminder',
  definition,
});

What the merchant sees

A draft in Settings, then Automations. Once on, each idle cart over the threshold starts a run that shows WAITING for two hours, then ends SUCCEEDED (email sent, or the shopper came back), or SKIPPED with the reason code. The list's "Last 7 days" column counts them.