$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-post-purchase-survey-triggerRead-only: identifies orders 7–14 days post-fulfillment that are eligible for a post-purchase survey campaign, excluding refunded or cancelled orders.
| 1 | ## Purpose |
| 2 | Builds the recipient list for a post-purchase survey campaign by selecting orders that were fulfilled between `survey_min_days` and `survey_max_days` ago, are not refunded, not cancelled, and (optionally) belong to customers who consented to marketing. Output is a clean recipient list ready to load into your email or SMS automation. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders,read_customers,read_fulfillments` |
| 6 | - API scopes: `read_orders`, `read_customers`, `read_fulfillments` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | survey_min_days | integer | no | 7 | Earliest days after fulfillment to survey (give time for delivery + initial use) | |
| 14 | | survey_max_days | integer | no | 14 | Latest days after fulfillment to survey (recall fades after ~2 weeks) | |
| 15 | | marketing_consent_only | bool | no | true | Restrict to customers with `marketingState: SUBSCRIBED` | |
| 16 | | exclude_repeat_recipients_days | integer | no | 90 | Skip customers who were already on a survey list within this window (caller-tracked) | |
| 17 | | format | string | no | human | Output format: `human` or `json` | |
| 18 | |
| 19 | ## Safety |
| 20 | |
| 21 | > ℹ️ Read-only skill — no mutations are executed. The skill produces a recipient list; the caller is responsible for actually sending the survey via their own email / SMS platform. Honor `marketing_consent_only: true` for promotional surveys to stay compliant with consent rules. |
| 22 | |
| 23 | ## Workflow Steps |
| 24 | |
| 25 | 1. Compute window: `latest_fulfilled_at = NOW - survey_min_days`, `earliest_fulfilled_at = NOW - survey_max_days` |
| 26 | |
| 27 | 2. **OPERATION:** `orders` — query |
| 28 | **Inputs:** `query: "fulfillment_status:fulfilled financial_status:paid -status:cancelled updated_at:>=<earliest_fulfilled_at>"`, `first: 250`, select `displayFulfillmentStatus`, `displayFinancialStatus`, `cancelledAt`, `fulfillments { createdAt, displayStatus, deliveredAt }`, `refunds { id, createdAt }`, `customer { id, defaultEmailAddress { emailAddress, marketingState }, displayName, locale }`, pagination cursor |
| 29 | **Expected output:** All candidate orders; paginate until `hasNextPage: false` |
| 30 | |
| 31 | 3. Filter orders to the survey window using the **earliest fulfillment** `createdAt`: |
| 32 | - Skip if `fulfilled_at` is outside `[earliest_fulfilled_at, latest_fulfilled_at]` |
| 33 | - Skip if `cancelledAt != null` |
| 34 | - Skip if any refund was issued (full or partial) |
| 35 | - Skip if customer is null (guest order without email) |
| 36 | - If `marketing_consent_only: true`, skip if `marketingState != SUBSCRIBED` |
| 37 | |
| 38 | 4. De-duplicate on customer email — multiple orders from the same customer collapse to a single survey invite |
| 39 | |
| 40 | 5. Output recipient list |
| 41 | |
| 42 | ## GraphQL Operations |
| 43 | |
| 44 | ```graphql |
| 45 | # orders:query — validated against api_version 2025-01 |
| 46 | query SurveyEligibleOrders($query: String!, $after: String) { |
| 47 | orders(first: 250, after: $after, query: $query) { |
| 48 | edges { |
| 49 | node { |
| 50 | id |
| 51 | name |
| 52 | createdAt |
| 53 | cancelledAt |
| 54 | displayFinancialStatus |
| 55 | displayFulfillmentStatus |
| 56 | totalPriceSet { |
| 57 | shopMoney { |
| 58 | amount |
| 59 | currencyCode |
| 60 | } |
| 61 | } |
| 62 | fulfillments(first: 5) { |
| 63 | id |
| 64 | createdAt |
| 65 | displayStatus |
| 66 | deliveredAt |
| 67 | } |
| 68 | refunds { |
| 69 | id |
| 70 | createdAt |
| 71 | } |
| 72 | customer { |
| 73 | id |
| 74 | displayName |
| 75 | locale |
| 76 | defaultEmailAddress { |
| 77 | emailAddress |
| 78 | marketingState |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | pageInfo { |
| 84 | hasNextPage |
| 85 | endCursor |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | ``` |
| 90 | |
| 91 | ## Session Tracking |
| 92 | |
| 93 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 94 | |
| 95 | **On start**, emit: |
| 96 | ``` |
| 97 | ╔══════════════════════════════════════════════╗ |
| 98 | ║ SKILL: Post-Purchase Survey Trigger ║ |
| 99 | ║ Store: <store domain> ║ |
| 100 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 101 | ╚══════════════════════════════════════════════╝ |
| 102 | ``` |
| 103 | |
| 104 | **After each step**, emit: |
| 105 | ``` |
| 106 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 107 | → Params: <brief summary of key inputs> |
| 108 | → Result: <count or outcome> |
| 109 | ``` |
| 110 | |
| 111 | **On completion**, emit: |
| 112 | |
| 113 | For `format: human` (default): |
| 114 | ``` |
| 115 | ══════════════════════════════════════════════ |
| 116 | POST-PURCHASE SURVEY LIST |
| 117 | Window: <survey_min_days>–<survey_max_days> days post-fulfillment |
| 118 | Orders considered: <n> |
| 119 | Refunded (excluded): <n> |
| 120 | Can |