Mailgun Send email integration - passing an array of items

Hi. I am testing out sending an email via Mailgun, and using the Templates API. I have a saved template in Mailgun, using the Handlebars notation.

The module takes a section - Template Variables. With map unticked, this allows you to enter name-value pairs, like Name = “John Doe”.

I would like to also pass an array of items in the template variables, like Products = [ {title: “Product 1”, price: 10.00}, {title: “Product 2”, price: 20.00} ] in JSON notation.

The Value field shown above does not seem to take any array form notation.

I could find no documentation on what it expects when you set Map = TICKED. Ive tried passing JSON as per below, but it doesnt work, giving an error:

Validation failed for 1 parameter(s).

  • Array of objects expected in parameter ‘templateVars’.

Any idea how this would be possible? Are there specific documentation articles related to such integrations?

Regards,
Karl

Hi,

I ran into this the other day.

The MailGun integration expects an array of collections with the following key-value pairs name and value (case-sensitive).

[
{
“name”: “variable_name”,
“value”: “variable_value”
]
]

An array aggregator can be used to auto generate the required format to the custom output format, if the MailGun module is after the aggregator.

You can also create a JSON data structure with a Create JSON module that matches the array of collections format and then pass that into the mapped field.

3 Likes