Calling User Properties

Basic Usage

To include a property of a user within a message, open a dropdown using {. A menu of your user properties by display name will pop up. If a user property has no display name, it will show its user property name. Select it by either pressing enter or typing out the full name.

Once selected, it will be highlighted so that you can distinguish user properties in your text blocks from regular text. User properties can only be called in text blocks - learn more about message elements here.

1093

📘

Clearing User Properties

Sometimes during testing you may want to clear all of your user properties when chatting with a bot. This can be done by sending the bot the following message:
_clear_

User Property Fallback

Sometimes you'll want to personalize a message with a user property that could be undefined for some users. In this case, it's easy to define a fallback value in case the user does not have the property defined. The syntax is almost identical the the basic usage, but you include || 'some fallback value' in between the user property and the closing }}.

263

Hi {{=user.name || 'there'}} :wave:!

Conditional User Properties

In addition, you might want to personalize the message based on another user property. For example, if we've previously collected the gender of a user's pet, we can then properly refer to him or her. See the below example, and then scroll down to see the example broken down.

263

How old is {{? user.petGender === 'male' }} he {{??}} she {{?}}?

The above example is a little confusing so let's break it down.

  • {{? user.petGender === 'male' }} begins the conditional and defines what the user property condition is. In this case it's if the user's petGender property equals male.
  • he is the message that we want to include if the condition is met, i.e. the users petGender is male.
  • {{??}} is roughly equivalent to else and must come between your branches
  • she is the message that we want to include if the condition is not met, i.e. the users petGender is not male
  • {{?}} is how we end the conditional statement

If you're familiar with JavaScript, the above is roughly equivalent to the below.

if (user.petGender === 'male') {
 return 'he';  
}
else {
 return 'she';
}