Use an LLM to draft the JSONata expressions for your data mapping, then check each expression before you add it to AI Hub.
A data mapping can contain dozens of expressions, one for each field the provider expects. An LLM can draft most of them if you give it the right inputs. It can also invent bindings, attribute names, or fields that don't exist, so always check the result.
Collect the inputs
The AI produces better expressions when it knows your data and the target schema. Collect the following:
- A sample feed entry: one product variant in the feed entry structure, with
productData,variant,store, andshippingMethods. To build one, see Test your JSONata mapping locally. - Your Product Type definition: the names and types of the Attributes your variants use, so the AI doesn't guess attribute names.
- The target fields: the field names and requirements from the data mapping page of your provider, such as OpenAI product data, Google product data, or Stripe product data.
- The available bindings: the variable and function bindings from the Bindings section of your channel's Product sync tab. For the defaults, see JSONata data mapping.
Remove personal data and confidential values from the sample before you share it with an LLM.
Write the prompt
Paste your inputs into a prompt like the following. Replace each placeholder in angle brackets.
You write JSONata expressions for a commercetools AI Hub data mapping.
Each expression runs against one product variant entry with these top-level
fields: productData, variant, store, shippingMethods. Here is a sample entry:
<paste the feed entry JSON>
These are the only bindings available (variables $country, $locale, $storeKey;
functions $tail, $getAttribute, $storeBaseUrl, $priceToAmount, $formatPrice).
$priceToAmount takes a price value object, and $formatPrice takes the amount and
the same price value object. Paste the bindings from your channel if they differ:
<paste the variable and function names and bodies>
Do not use any other custom functions or bindings.
The variant Attributes are defined by this Product Type:
<paste the Product Type name, Attribute names, and types>
Write one JSONata expression for each of these target fields:
<paste the target field names, their meaning, and whether each is required>
Rules:
- Use only fields that exist in the sample entry or the Product Type.
- Read localized values with $lookup(productData.name, $locale).
- Return a string, number, or boolean as the target field expects.
- Guard price and sale-price expressions. For price, use
variant.price ? $priceToAmount(variant.price.value) ~> $formatPrice(variant.price.value) : ""
and for sale price, use
variant.price.discounted ? $priceToAmount(variant.price.discounted.value) ~> $formatPrice(variant.price.discounted.value) : ""
Do not substitute zero when the value is missing.
- If a field can't be mapped from the available data, write "NOT MAPPABLE"
and explain why instead of guessing.
- A variant without availability is "out_of_stock". A category ID alone
does not provide a provider taxonomy path; mark that field "NOT MAPPABLE"
unless the required taxonomy value or a maintained mapping is supplied.
- Return the result as a list: target field, expression, one-line explanation.
size Attribute is a number. Convert it to a string." works better than repeating the whole prompt.Check the result
Treat every generated expression as a draft:
- Run each expression against your sample entry with the local test and compare the output with the value you expect.
- Check that every attribute name matches a name in your Product Type, including its casing.
- Check that the expression only calls bindings that exist in your channel.
- Test the expressions with variants that have missing attributes, a
nullprice, or missing availability. For an example, see Check for missing values. - Compare the value types with the requirements on the provider's data mapping page, for example whether a price is a number or a formatted string.
- Export the product data in AI Hub. An expression that returns no value gives an empty cell. An expression that can't be evaluated fails the export and names the function and SKU.
Collect the inputs with the Commerce MCP
Enable the read tools
Enable only the tools the LLM needs, and no tools that create or update data. For a data mapping, these four read tools are enough:
read_product_projections: reads the Product Projections and Product Variants to map.read_product_types: reads the Attribute definitions of your Product Types.read_stores: reads the Store that your Agentic Channel uses.read_shipping_methods: reads the Shipping Methods for theshippingMethodsfield.
Scope the product data
read_product_projections returns the published Product Projection without a scoped price. To get the same price shape as in the feed entry, pass these parameters:storeProjection: the key of the Store that your Agentic Channel uses. It filters prices and inventory to the Store's channels and applies the Store's locales.priceCurrency: a currency code such asEUR. This parameter enables price selection.priceCountry,priceCustomerGroup, andpriceChannel: optional price selection inputs. They only apply together withpriceCurrency.
price field that your expressions read as variant.price.Assemble the feed entry
The MCP returns API resources, not a feed entry. Ask the LLM to combine them in the feed entry structure. For example:
Use the Commerce MCP tools to build one feed entry for the variant with
SKU <SKU>. Follow these steps:
1. Call read_product_projections with a where predicate for the SKU,
storeProjection "<store key>", priceCurrency "<currency>",
priceCountry "<country>", and priceChannel "<distribution Channel ID>".
2. Set productData to the Product Projection.
3. Set variant to the Product Variant whose sku matches, including its
scoped price.
4. Call read_stores for the Store with key "<store key>" and set store to
the result.
5. Call read_shipping_methods and set shippingMethods to the results.
Return only the JSON object with the four top-level fields.
feed-entry.json and use it in the local test. Compare it with the structure in JSONata data mapping before you generate expressions from it.Next steps
- Verify your expressions with Test your JSONata mapping locally.
- Look up the feed entry structure and example expressions in JSONata data mapping.