Creating an email with line-items

I’m trying to create a simple workflow that sends an order confirmation HTML email that can potentially have multiple line items. I’m struggling with the part to setup the line-items decorated in HTML.

The response that I get from the webhook is something like this:

  "body": {
    "content": {
      "items": [{
        "name": "item one"
      }, {
        "name": "item two"

Apparently, I can’t loop over those line items in the expression builder to transform those items into an HTML block. Any pointers on how that’s done?

Ok. I think I have this figured out… Do I use a transform function to come up with the HTML block? And then have that block property feed into the next node?

const block = items[0].json.body.content.items.reduce((prev, curr, index) => {
  return `${prev}<div>${}</div>`
}, '')

return [{
  json: { block }
1 Like

Hi @mdings, welcome to the community :tada:

You’re quite right, at the moment such transformations would require the use of a the Function node running custom JS.

As a starting point you could for example take a look at the example I have written in this thread building an email from multiple RSS Feed items (only the last node would be relevant):

The n8n data structure which you would need to follow when using the Function node is explained here in a bit more detail: Key Concepts | Docs

Once you have single item with a JSON field of email_html (or anything else really, this is just an arbitrary name I’ve used in my example) you can then reference this field containing your email HTML via an expression in any of the email nodes (Send Email, Mailgun, SendGrid etc.) to send out your mail.