# Message Conditions

### Message conditions

Message conditions can be defined by clicking on Conditions in the Layout and adding context, attribute and other details. More information about context and attributes is a available in the next page on Attributes in Messages.&#x20;

<figure><img src="https://3203401256-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdP6xFXXyeBbibro1Ywnq%2Fuploads%2FxVNFjd1IXPTzLItcTM5P%2F2023-05-01_15-15-11%20copy%20(1).png?alt=media&#x26;token=622f1565-615f-467a-9182-81978bf93939" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3203401256-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdP6xFXXyeBbibro1Ywnq%2Fuploads%2Fsk3SSceP2YBzT16RlZlc%2F2023-05-01_15-57-54.png?alt=media&#x26;token=46d43572-7d5d-4fcb-b299-873ca618ac56" alt=""><figcaption></figcaption></figure>

We define conditions so that the system can evaluate which message to use. In the image below, two messages are associated with the intent called intent.app.WelcomeUser. The message called intent.app.WelcomeNewUser gets used when the user is not an existing customer. If they are, the message intent.app.WelcomeExistingUser is used. Existing\_customer is an attribute of the user context. More information about using attributes in messages can be found in the next page, "Attributes in messages".

<figure><img src="https://3203401256-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdP6xFXXyeBbibro1Ywnq%2Fuploads%2FiIcWPsG6ZsWKvVZmfguO%2F2023-05-01_14-35-48.png?alt=media&#x26;token=f5fb056d-2f52-45f4-bd97-2f2a8d2ba7aa" alt=""><figcaption><p>Example of messages with conditions</p></figcaption></figure>

Continuing our example above, where we want to show different messages to users depending on whether they are a new user or a returning user. To do this we would us Conditions to tell the system which message it should show depending on the value of attributes saved against the user.

For our example, then we would set the 'Attribute' to `seconds_since_last_seen` , 'Context' to `user`, 'Operation' to `Equals` and the 'Value' to '`0`' - meaning only show this message if the user has not been seen yet.

![Conditions: New user welcome message](https://3203401256-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOzV9Wk3YsltjoDUyen%2F-Mee6xCjA-snrQ6HPvfU%2F-MeeOQ4wT1T9GhqGezIz%2Fimage.png?alt=media\&token=4400ba7b-1113-41e9-a243-af30ac448915)

Where as for the returning user, we would change the 'Operation' to be `Greater than`. Meaning only show this message if the user has been seen before.

![Conditions: Returning user welcome message](https://3203401256-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MOzV9Wk3YsltjoDUyen%2F-Mee6xCjA-snrQ6HPvfU%2F-MeePTVX09rM_szrMfa2%2Fimage.png?alt=media\&token=b9824ffd-87ba-447a-b5c7-208bd100d4b7)

Conditions are really powerful for enabling personalised experiences for users. The key functionality that drives Conditions are Attributes and you find out more about them [here](https://docs.opendialog.ai/core-concepts/contexts-and-attributes/conditions-and-operators).&#x20;
