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.

When a customer requests a return, wait 3 days. If nobody has approved, declined or cancelled it by then, notify the managers. Trigger: return.requested@1. Steps: wait, condition on current.return.status, notify_me@1.

Model background: Automations.

The definition

{
  "schemaVersion": 1,
  "trigger": {
    "type": "return.requested@1",
    "origins": [
      "USER",
      "API",
      "MCP",
      "ASSISTANT",
      "BULK",
      "IMPORT",
      "DUPLICATE",
      "SYSTEM",
      "AUTOMATION"
    ]
  },
  "steps": [
    {
      "id": "pause",
      "type": "wait",
      "duration": {
        "amount": 3,
        "unit": "days"
      }
    },
    {
      "id": "still",
      "type": "condition",
      "when": {
        "op": "all",
        "rules": [
          {
            "path": "current.return.status",
            "op": "eq",
            "value": "REQUESTED"
          }
        ]
      },
      "then": [
        {
          "id": "tell",
          "type": "action",
          "contract": "notify_me@1",
          "input": {
            "title": "Return {{return.number}} has waited 3 days",
            "message": "Nobody has approved or declined return {{return.number}} for order {{order.number}}."
          }
        }
      ]
    }
  ]
}

Replace before saving: the wait duration (minutes, hours or days, 5 minutes to 90 days) and the wording of the notice.

How it works

  • return.requested@1 is one of six return triggers (requested, approved, declined, received, completed, cancelled). Their facts are the order facts plus event.facts.return.status, .resolution, .source, .autoApproved, .reasonCode, .unitCount and .lineCount. No decline text and no merchant note is ever in the facts.
  • The facts are frozen at the request, so after the wait the condition reads the live value current.return.status (REQUESTED, APPROVED, RECEIVED, COMPLETED, DECLINED, CANCELLED). Still REQUESTED means nobody answered.
  • If it was answered, the condition is false, there is no else, and the run ends SUCCEEDED with the outcome CONDITION_NOT_MET. That is the normal, quiet result for most returns.
  • The text may use the order variables plus {{return.id}}, {{return.number}}, {{return.status}}, {{return.resolution}} and {{return.unitCount}}. A customer can cancel a request only while it waits for approval, so a cancelled return reads CANCELLED here.

What it does not do

  • It does not approve or decline anything. There is no return action in the engine: it only tells a person.
  • It does not email the customer. A customer email "about the order" is possible with send_customer_email@1 and kind: "order", but not as a reminder to the merchant.
  • Other live return columns you can test instead of the status: current.return.ageDays, .daysSinceApproved, .daysSinceReceived, .resolution, .source, .hasRefund. For example, "approved but never received after 10 days" is a wait on return.approved@1 and a check on current.return.status eq APPROVED.

Create it

With the Admin MCP:

  1. get_automation_guide with topic: "triggers", then "live-values".
  2. validate_automation_definition. Fix every finding.
  3. test_automation with entity: { "type": "Order", "id": "<an order that has a return>" }. An order with no return yet has nothing to test on.
  4. create_automation_draft with name: "Return waiting too long".
  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: 'Return waiting too long',
  definition,
});

What the merchant sees

A draft in Settings, then Automations. Once on, every new return request starts a run that sits WAITING for 3 days. If the return is still unanswered, the store's managers get a notice such as "Return R-1042 has waited 3 days". Otherwise the run ends SUCCEEDED and nobody is bothered.