Lacuna/Labs
cross-post-shopify-to-google
pink
#198 / 601

NAME

cross-post-shopify-to-google — Shopify publish → adapt + push to Google Shopping. Cleanest mapping of the three. Idempotent upsert by SKU.

SYNOPSIS

id cross-post-shopify-to-google tier pink section §7. Pink — Sakura local (65 baseline, 131 post-matrix) trigger event:listing-published-to-shopify tools merchant_center/sync source new

DESCRIPTION

Sakura's local 8B model handles this on-device. Free, private, Cortex-grounded. The 'I just know what you have' tier.

Shopify publish → adapt + push to Google Shopping. Cleanest mapping of the three. Idempotent upsert by SKU.

MECHANISM

PREfetchGUARDtier: pinkACTperformRESULTrenderON-ERRretry / esc
;;~ title    "Cross-post · Shopify → Google Shopping"
;;~ author   "lacuna"
;;~ version  1
;;~ mode     automation
;;~ flavor   purple
;;~ id       cross-post-shopify-to-google
;;~ touches  (shopify-listings google-merchant)
;;~ summary  "Event-triggered on listing-published-to-shopify. Shopify is the cleanest of the three sources — already structured similar to Google. The mapper still scrubs anything Shopify-specific, but the warning rate is much lower than Etsy or eBay. Tier-gated to Magic+; drafts never sync."

;; Shopify → Google. The mapping is the cleanest of the three cross-post
;; carts because Shopify's product shape (title, body_html, variants,
;; images, product_type) maps almost 1:1 to Google's product feed.
;;
;; The dedup story is the most fraught here: many operators already have
;; Shopify ↔ Merchant Center integrations running, so Curator might find
;; the same product already on Google. Phase 3 of the GMC plan adds the
;; reconcile path (products.list on first connect + adopt existing
;; offerId). Until then, sync_listing's POST is idempotent — Google's
;; products.insert is upsert by offerId, so re-pushing the same SKU
;; updates rather than duplicates.

(cart 'cross-post-shopify-to-google
  '((author    . "lacuna")
    (version   . 1)
    (touches   . (shopify-listings google-merchant))
    (read-only . #f)))

(define (start ctx)
  (let ((id (ctx-get 'listing-id ctx)))
    (if (null? id)
        (escalate 'missing-listing-id null)
        (act 'shopify/listing (list id) 'check-listing))))

(define (check-listing ctx)
  (let ((listing (ctx-result ctx)))
    (cond
      ((null? listing)             (escalate 'listing-not-found null))
      ((listing-is-draft? listing) (escalate 'drafts-do-not-sync null))
      (else (next 'check-merchant (ctx-set 'listing listing ctx))))))

(define (check-merchant ctx)
  (act 'merchant_center.status '() 'check-merchant-result))

(define (check-merchant-result ctx)
  (let ((status (ctx-result ctx)))
    (cond
      ((not (status-connected? status))
       (escalate 'merchant-not-connected null))
      ((status-pending-verification? status)
       (after 3600 'check-merchant ctx))
      (else (next 'push ctx)))))

(define (push ctx)
  (let ((listing (ctx-get 'listing ctx)))
    (act 'merchant_center/sync (list listing) 'check-push-result)))

(define (check-push-result ctx)
  (let ((r (ctx-result ctx)))
    (cond
      ((push-ok? r)
       (next 'announce (ctx-set 'google-product-id (push-product-id r) ctx)))
      ((eq? r 'rate-limited)   (after 30 'push ctx))
      ((eq? r 'mapping-failed) (escalate 'mapping-failed (push-errors r)))
      (else                    (escalate 'push-failed r)))))

(define (announce ctx)
  (sakura/say (string-append
                "Cross-posted Shopify → Google Shopping · "
                (ctx-get 'google-product-id ctx)))
  (done))

source: curator-web/src/scheme/carts/google/cross-post-shopify-to-google.sks · 70 lines

EXAMPLES

Example forthcoming — docs/automations/examples.json entry editable in place.

TIER

pink
Sakura local 8B · free · on-device

FITNESS

Ready

Fits any shop today — this one has no sample-size floor.

SEE ALSO

HISTORY

canonical source: curator/docs/AUTOMATIONS-CANONICAL.md · §7-pink-sakura-local-65-baseline-131-post-matrix
last regenerated: 2026-06-05 20:31 UTC (mechanical — edits land in the MD or sidecars, not here)

KNOWN BUGS

(none recorded — flag in AUTOMATIONS-CANONICAL.md or open an issue against the cart file)