If else condition with personalization token

Hi All,
I am trying to fina a solution for the below querry. But the if else condition is not working(I tried for creating a seprate contact with firstname as unknown but its not working)
Requirement:
If the first name contains UNKNOWN or is equal to UNKNOWN (any case sensitive) then show a specific value.
and the condition
{% if contact.firstname.value == “Unknown” %}<p>Hello</p>{% else %} Hey {% endif %}
Can you look into this and advise
Thanks,
Prathap

Hi, @prathap :waving_hand: Welcome to our community! Thank you for the great question.

It looks like you are on the right path. Have you tried using the lower filter to convert the contact.firstname.value to lowercase (or upper for uppercase) and then compare it to the lowercase (or uppercase) string you want to match?

Something like:

{% if contact.firstname|lower == "unknown" %}<p>Hello</p>{% else %}<p>Hey</p>{% endif %}

Have fun building! — Jaycee

@Jaycee_Lewis Thanks for your quick response.
However i have tested this condition and matching condition is not working, only else condition is executing even if it matches the condition.
Contact first name is prathap. I have tried with this contact but its not working.
{% if contact.firstname == “prathap” %}<p>Hello</p>{% else %}<p>Hey</p>{% endif %}
Can you lookinto this and let me know

@prathap Maybe try debugging it.

Are you sure {{contact.firstname}} is returning what you want? Try adding it above the IF statement just to print it and see what is the actual value.

Then you could try something like this:

{% if contact.firstname is string_containing('unknown') %}<p>Hello</p>{% else %}<p>Hey</p>{% endif %}

@albertsg I tried debuging it but not getting the expected result.
{{ contact.firstname }} is fetching the expected value but if i use if else condition and this value is not matching.
However i tried with first name default value(there), if else is working for this default value but not working for contacts value
Example:
Default value(there); and the condition is executing
{% if contact.firstname == “there” %}<p>Hello</p>{% else %}<p>Hey</p>{% endif %}
Actual Contact or sample contact value(prathap); and the condition is not executing
{% if contact.firstname == “prathap” %}<p>Hello</p>{% else %}<p>Hey</p>{% endif %}

Hi @prathap !
What if you save the name to a variable before running the if statement? I’ve had issues in a programmable email that required a saved variable in Hubl logic. Not sure if this will help you, but I figured I would share.

Example:

{% set this_contact = contact.firstname %}
{% if this_contact == "prathap" %}
 <p>Hello</p>
{% else %}
 <p>Hey</p>
{% endif %}

To add to @tyler-west answer, try adding print the value with the filter |pprint to see more details about it.
There is a page on HubSpot’s documentatio dedicated to debuggin that could be helpful in this situation: Debugging methods and error types - HubSpot docs

For using any Personalization Token in if/else condition, it is necessary to enable programmable email. And for that, you need to add isEnabledForEmailV3Rendering: true at the top of the template. For reference, please check the screenshot. For more, please go to this page.