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@1fires 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.isFirstOrderandevent.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@1takes free-text tags (1 to 20, trimmed, no comma). add_customer_tags@1targets{ "$ref": "event.facts.customer.id" }. A guest order has no customer: that step is skipped withCUSTOMER_NOT_FOUND, andisFirstOrderis 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.totalSpentin the filter instead (a live value, see Facts versus live values). - It does not email the customer. Add
send_customer_email@1only 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:
get_automation_guidewithtopic: "triggers".validate_automation_definition. Fix every finding.test_automationwithentity: { "type": "Order", "id": "<a paid first order>" }. A condition on live values is judged on today's data and marked as such.create_automation_draftwithname: "Tag VIP on first big order".- 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.
Low-stock alert for the team
An automation that emails your team once when a variant's sellable stock drops below your own number, with a complete validated definition and the exact MCP and SDK calls to draft it.
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.