APIs & Integrations

Not applicable

How to use statements based on custom values in the email body using the transactional email single send API

We are using the single send API for our transactional emails and within the body we have the need to frequently check if a value is present or equal to x render this block else return null and so forth. Imagine a complicated email filled with tons of conditional data. It seems that we can not create conditions in the email body based on these custom properties. Do we really have to rely on our back-end to pass blocks of html based on our needs or is there some solution within the body?

0 Upvotes
2 Replies 2
davidpurkiss1
Member

How to use statements based on custom values in the email body using the transactional email single send API

To help anyone else who comes across this. We ran into a similar issue and managed to workaround this by "binding" a custom property to a css display property. E.g.

 

 

.my_content_toggle {
  display: {{ custom.contentToggle }}
}

 

The you can pass in either "none" or "inherit" to the contentToggle custom property.

Derek_Gervais
HubSpot Alumni
HubSpot Alumni

How to use statements based on custom values in the email body using the transactional email single send API

Hi @AdrienneD,

You're correct that information passed via the Transactional Email API will not function within HubLif statements, as the templates compile before the information populates. For now, your best bet would be to pass the correct HTML from your system. I can understand the use case you're describing, though; if you have the inclination, I would encourage you to check out the Ideas Forum on the HubSpot Community. There, you can create a post including your use case that product and other customers can see.

0 Upvotes