Tag VIP customers on a first big order

An automation that tags the order and its customer when a new customer's first paid order passes an amount, with a validated definition and the MCP and SDK calls to draft it.

Mark a new customer as VIP the moment their first order is paid and is large. Trigger: order.paid@1 with a filter. Actions: add_order_tags@1 and add_customer_tags@1.

Model background: Automations.

The definition

{
  "schemaVersion": 1,
  "trigger": {
    "type": "order.paid@1",
    "origins": [
      "USER",
      "API",
      "MCP",
      "ASSISTANT",
      "BULK",
      "IMPORT",
      "DUPLICATE",
      "SYSTEM",
      "AUTOMATION"
    ],
    "filter": {
      "op": "all",
      "rules": [
        {
          "path": "event.facts.customer.isFirstOrder",
          "op": "eq",
          "value": true
        },
        {
          "path": "event.facts.order.total",
          "op": "gte",
          "value": 500
        }
      ]
    }
  },
  "steps": [
    {
      "id": "mark",
      "type": "action",
      "contract": "add_order_tags@1",
      "input": {
        "orderId": {
          "$ref": "event.entityId"
        },
        "tags": ["vip-first-order"]
      }
    },
    {
      "id": "tag",
      "type": "action",
      "contract": "add_customer_tags@1",
      "input": {
        "customerId": {
          "$ref": "event.facts.customer.id"
        },
        "tagIds": ["TAG_ID_OF_VIP"]
      }
    }
  ]
}

Replace before saving:

  • TAG_ID_OF_VIP: the id of an existing customer tag. An automation never creates a tag. A tag that is not in the store is refused when the version is approved (TAG_NOT_FOUND). List or create tags with the Admin MCP tag tools first.
  • The number 500: your threshold, in the order's own currency. Totals are not converted between currencies.

How it works

  • order.paid@1 fires when the order's financial status becomes paid. That is not the same as the order status dropdown being set to PAID.
  • The filter reads two facts frozen at the moment of payment: event.facts.customer.isFirstOrder and event.facts.order.total. Both rules must hold (op: "all").
  • The order tag comes first so the order is marked even if the customer step is skipped. add_order_tags@1 takes free-text tags (1 to 20, trimmed, no comma).
  • add_customer_tags@1 targets { "$ref": "event.facts.customer.id" }. A guest order has no customer: that step is skipped with CUSTOMER_NOT_FOUND, and isFirstOrder is empty for a guest, so the filter does not match a guest anyway.

What it does not do

  • It does not look at lifetime spend. For "a customer who has spent more than N over time" test current.customer.totalSpent in the filter instead (a live value, see Facts versus live values).
  • It does not email the customer. Add send_customer_email@1 only with a template and the customer's consent in mind.
  • Adding a tag to a customer fires customer.tag_added@1, which another automation can start from.

Create it

With the Admin MCP:

  1. get_automation_guide with topic: "triggers".
  2. validate_automation_definition. Fix every finding.
  3. test_automation with entity: { "type": "Order", "id": "<a paid first order>" }. A condition on live values is judged on today's data and marked as such.
  4. create_automation_draft with name: "Tag VIP on first big order".
  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: 'Tag VIP on first big order',
  definition,
});

What the merchant sees

A draft in Settings, then Automations. At approval the approver's permissions are bound, so they must be allowed to do everything the actions do. Once it is on, each qualifying order gets the vip-first-order tag and the customer gets the VIP tag. The run history shows SUCCEEDED, or SKIPPED with CUSTOMER_NOT_FOUND for a guest.