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@1fires 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
waitis 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 valuecurrent.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 runSKIPPEDwithCART_NOT_FOUND. - A condition with no
elsethat is false ends the runSUCCEEDEDwith the outcomeCONDITION_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 insidefrequencyDays(FREQUENCY_CAP).kind: "marketing"carries the unsubscribe link and needs a business postal address on the store (NO_POSTAL_ADDRESSotherwise). - It does not stack on the store's own abandoned-checkout recovery emails. When those are switched on, this run ends
SKIPPEDwithRECOVERY_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@1for 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:
get_automation_guidewithtopic: "live-values", then"messages".validate_automation_definition. Fix every finding.test_automationwithentity: { "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.create_automation_draftwithname: "Abandoned cart reminder".- 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.
Sweep unpaid orders every morning
A scheduled automation that finds orders still unpaid after 3 days, tags them and sends the order numbers as a notice. A validated definition using the clock trigger, a fetch step and a bulk tag action.
Flag a return nobody answered
An automation that waits 3 days after a return request and notifies the store's managers if it is still unanswered. A validated definition using a wait step and a live current.return value.