Expand my Community achievements bar.

Never miss an update of the Adobe Journey Optimizer Community Lens! Subscribe now to get the latest updates, insights, and highlights delivered straight to your inbox every time a new edition drops.
SOLVED

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

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

 

View solution in original post

2 Replies

Avatar

Community Advisor

@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

Avatar

Correct answer by
Employee Advisor

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