Solved

Flow | Correct syntax for using metafields in openAI text generation

floriangoerig
Tourist
19 0 1

Hi there,

 

I want to use openAI text generation in order to generate a biography of famous people. The idea is to customize the prompt with metafields variables that contain first- and lastname information of the person.

 

Background. We run an autograph store with unique items. 

 

so this is my current prompt

Write a 500 words and 6 paragraphs biography text about 

{{ product.metafields.customAttributes.vorname }} {{ product.metafields.customAttributes.nachname }}

without a title formatted in HTML only with <p> tags

 

The prompt works fine without the metafield variables. I tried some variants in syntax but shopify keeps saying  

"customAttributes" is invalid. Replace this variable.

 

So what would be the right syntax?

 

Thanks for your help folks

Florian

Accepted Solution (1)

paul_n
Shopify Staff
790 118 190

This is an accepted solution.

That syntax does not currently work for metafields in Flow. Also, "customAttributes" are not the same thing as metafields. 

 

There are many threads showing how to access metafields using a loop or "where" clause. Here's the where clause method for a different type of metafield:

https://community.shopify.com/c/shopify-flow-app/display-variant-metafield-value-in-a-for-loop/m-p/2...

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Reply 1 (1)

paul_n
Shopify Staff
790 118 190

This is an accepted solution.

That syntax does not currently work for metafields in Flow. Also, "customAttributes" are not the same thing as metafields. 

 

There are many threads showing how to access metafields using a loop or "where" clause. Here's the where clause method for a different type of metafield:

https://community.shopify.com/c/shopify-flow-app/display-variant-metafield-value-in-a-for-loop/m-p/2...

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.