Shopify Flow "Send marketing email" Not Rendering Dynamic Variables from Run Code Step

Hi everyone,

I’m setting up a Shopify Flow automation to email customers their eSIM details after purchase. My workflow is as follows:

  1. Trigger: Order paid

  2. Condition: Line item title contains “eSIM”

  3. Action: Send HTTP request to an external API to assign an eSIM

  4. Condition: HTTP response status is 200

  5. Action: Run code (JavaScript) to parse the HTTP response and output two fields: iccid and qr_code_url

  6. Action: Send marketing email to the customer, including their ICCID and QR code link using Liquid variables (e.g., {{ runCode.iccid }} and {{ runCode.qr_code_url }})

Issue:
Despite returning the iccid and qr_code_url fields from my Run code step and referencing them as {{ runCode.iccid }} and {{ runCode.qr_code_url }} in the email template, the values do not render in the emails sent to customers. I’ve also added debug: {{ runCode | json }} to the template, and it outputs null in the received email. However, my Run code output in the Flow logs clearly shows that these fields are being returned correctly.

I’ve confirmed:

  • The “Send marketing email” action is directly after the Run code step (no branching).

  • I am using the correct variable names and Output schema.

  • The workflow is linear—no parallel paths or branches that would affect variable scope.

  • If I use Shopify Flow’s “Send internal email,” I can only send to static addresses and not the customer.

Question:
Has anyone successfully passed Run code output variables into a “Send marketing email” step in Shopify Flow?
Is there something I’m missing regarding variable scope, timing, or Flow configuration to make these dynamic values available in the marketing email to the customer?

Any help or examples would be greatly appreciated!

Hi!

You can try using FlowMail for transactional emails sent to your customer. With FlowMail we had no issues passing any data from previous workflow steps into the email.

You can’t use json to render an object in Flow, because the underlying data is based by a basically infinite query in GraphQL (there is no standard object to render) . It still works for JSON escaping though. Regarding send marketing email, it does not allow passing in data directly. I believe it now supports metafields, so you could pass in data by setting a metafield first in Flow and then reading it there, but that wouldn’t work in all scenarios.