Route new Shopify buyers into the right Flodesk nurture

By General Input

Every new Shopify order sends the buyer into the right Flodesk segment, New, Repeat, or VIP, and starts their post-purchase emails.

Integrations

  • Shopify
  • Flodesk

Type

Deterministic Code

Categories

  • Marketing
  • Operations

Build a code workflow that runs whenever a new Shopify order is created, and routes the buyer into the right Flodesk segment plus the matching post-purchase email workflow using deterministic rules. Two integrations only: Shopify and Flodesk. No judgement step, the rules are fixed.

Trigger: a Shopify orders/create webhook. The webhook payload includes the order ID and the customer ID.

Configurable inputs the user sets up once when installing the workflow: NEW_SEGMENT_ID, REPEAT_SEGMENT_ID, VIP_SEGMENT_ID (Flodesk segment IDs), NEW_WORKFLOW_ID, REPEAT_WORKFLOW_ID, VIP_WORKFLOW_ID (Flodesk workflow IDs), and VIP_THRESHOLD (numeric, default 200, in the store's currency).

Step 1. Call Shopify Get Order with the order ID from the webhook payload to read the order total, the customer email, the customer first and last name, the customer ID, the line items, and whether the buyer opted out of marketing.

Step 2. Call Shopify Get Customer Orders for the customer ID and count how many total orders this customer has (including the one that just came in).

Step 3. Apply the rules. If the customer's total order count is 1, flag them as new. If the count is greater than 1, flag them as repeat. Independently, if the order total is greater than or equal to VIP_THRESHOLD, also flag them as VIP. Build the list of Flodesk segment IDs from whichever flags are set (a first-time big spender lands in both the New segment and the VIP segment). Pick a single post-purchase workflow ID by priority: VIP wins over Repeat, Repeat wins over New.

Step 4. If the customer email is missing or the buyer opted out of marketing, log the decision and stop, do not write to Flodesk.

Step 5. Call Flodesk Create or Update Subscriber with the customer's email, first name, and last name. Then call Flodesk Add Subscriber to Segments with the chosen segment IDs. Then call Flodesk Add Subscriber to Workflow with the chosen workflow ID to enroll them in the matching post-purchase nurture.

Return a small JSON summary with the customer email, order total, total order count, the segment IDs that were applied, and the workflow ID they were enrolled into, so the run history is easy to debug.

Related prompts

Explore more prompts
Receiving dock console for inspecting and restocking Loop returnsSee which influencer creators actually drove Shopify salesMorning dispatch board for your local delivery runsAnswer Instagram and Messenger DMs with the order on screenWhite glove queue for the VIP customers waiting on youReturns and warranty claim desk that follows your policyFraud lookup desk for any email, phone, IP address or linkReview high risk Shopify orders before anything gets pickedFraud review desk for the Shopify orders you should holdMorning repricing console for Shopify with margin-safe rules