We are looking to populate information based on the data sent to SendGrid using dynamic content in dynamic templates.
We are sending transactional data to SendGrid to populate information in the dynamic template and I am looking to configure a rule as follows:
- If RateType begins with A, then display ABC
- If RateType begins with B, then display DEF
- If RateType begins with C or D or E, then display GHI
- If else display JKL
I was not able to figure out the code for the above scenarios if that is possible at all?
In a related scenario I am trying to do the same but with equals:
- If TransactionNumber equals 123 or 456, then display ABC
- If TransactionNumber equals 789 or 000, then display DEF
- If else display GHI
I know there is the possibility to configure dynamic content generation in Sendgrid templates using Handlebars. For example: https://docs.sendgrid.com/for-developers/sending-email/using-handlebars#conditional-statements
<!-- Template -->
{{#if user.profile.male}}
<p>Dear Sir</p>
{{else if user.profile.female}}
<p>Dear Madame</p>
{{else}}
<p>Dear Customer</p>
{{/if}}
Unfortunately, I was not able to make the above code work, as it seems too inflexible.