Unable to personalize an if and else condition for api triggered campaign in AJO Email templates | Community
Skip to main content
Level 2
September 17, 2025
Solved

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

  • September 17, 2025
  • 2 replies
  • 356 views

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>
  <%}%>
Best answer by Mayank_Gandhi

@nutsa9858  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%}

 

2 replies

SatheeskannaK
Community Advisor
Community Advisor
September 17, 2025

@nutsa9858 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
Mayank_Gandhi
Adobe Employee
Mayank_GandhiAdobe EmployeeAccepted solution
Adobe Employee
September 19, 2025

@nutsa9858  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%}