Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Unable to personalize an if and else condition for api triggered campaign in AJO Email templates

Avatar

Level 1

How to define/personalize an if else condition for AJO API Trigger Campaigns email templates for {{context.make}} for below pattern


<% if((make!='a') && (make!='b') && (make!='c') && (make!='d')){%>
"a"
 </a>
<%} else if((make=='a') && (model=='b')){%>
"b"
  </a>
<%} else {%>
  "c"
</a>
  <%}%>
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Community Advisor

@NuthanSa1 Follow similar syntax to adapt to your needs.

{%#if profile.homeAddress.countryCode != "FR" and profile.homeAddress.countryCode != "US"%}
test00
{%else if rofile.homeAddress.countryCode != "CA"%}
test11
{%else%}
test22
{%/if%}
Additionally, you can use the personalization editor below to try out and see how it works.
Thanks, Sathees

Avatar

Employee Advisor

@NuthanSa1  To personalize if-else conditions for an AJO API Trigger Campaign email template with contextual payload variables (such as {{context.make}}), you should use Journey Optimizer's supported syntax. For API-triggered campaigns, you access contextual payload data with {{context.<fieldName>}}.

 

Try this:

sample payload

{
  "context": {
    "make": "a",
    "model": "b"
  }
}

 

{%#if contains(context.make, "a") %}
  <!-- Your output here for make 'a' -->
{%else if (context.make == "b" && context.model == "c") %}
  <!-- Your output here for make 'b' and model 'c' -->
{%else%}
  <!-- Fallback output -->
{%/if%}