OpenDialog Docs
OpenDialog 2023.1
Ask or search…
Comment on page

Attributes in messages

If you are not familiar with the concept of attributes, read more or consider the video-based OD Academy lessons. To sign up, email [email protected].
Attributes can be used in any message to customize the content. For example, the user's name can be added in the welcome message to personalize the experience.
Edit Message screen


Attributes are added to messages using curly braces {}.and Inside the curly braces we first add the context name (very often and by default the context is "user"), next we add a period (.) and then the attribute name. For example, the attribute first_name stored in the user context looks like this:
If the value of first_name is John, the message will display as "Hello John and welcome back to Prime Brands."
Note - If the attribute has no value or does not exist in the context given, the attribute reference is removed from the final message.

Attribute Filters

It may be necessary to filter or modify the value of an attribute before it is used in a message. To help with this, OpenDialog provides a number of built-in filters to use when referencing attributes in the message editor.
Filters are applied to attributes using a pipe (|) and they can be chained together with the result of a filter being passed through the next. For instance:
{ user.age | number_to_words | uppercase_first }
The above takes the value of the age attribute in the user context, converts the number to words and adds an uppercase the first letter. If age was 30, the value placed in the message would be 'Thirty'.

Available Filters

String filters
  • uppercase - uppercases all letters in the string
  • uppercase_words - uppercases the first letter of each word in the string
  • uppercase_first - uppercases only the first letter in the string
  • lowercase - lowercases the entire string
Number Filters
  • number_to_words - turns a number into its word. eg 1 => 'one'
  • ordinal - returns the ordinal of the number. eg 1 => 1st
  • ordinal_words - returns the ordinal spelled out. eg 1 => 'first'
Collection Filters
  • count - returns the number of items in a collection type attribute

Using attributes

Attributes can be used in any message in place of text, button text, image source, form field text etc. I'm assuming space between curly brace and context + attribute is optional?
Example message content using attributes in various message types

Defining attributes

Attributes can be defined in a number of ways:
  • In the dynamic attributes page: each workspace has a "hidden page" (aka a page that is accessible through the interface if one knows the URL. There is no link in the interface to that page, and the page may not be properly themed). This hidden page is typically accessed by adding "dynamic-attributes" after the "admin/" portion of the URL. E.g.
  • Attributes can be defined "on the fly" by simply using them, e.g. in a form message. These attributes are by default strings. To assign a specific type to the attribute, it must be defined in the dynamic attributes page
  • Attributes can also be defined in a config file in the codebase
For video lessons and hands-on practice with these concepts, consider signing up for the OpenDialog Academy lessons by emailing [email protected].