Learn how to personalize message content in OneSignal using Liquid syntax across email, push notifications, SMS, in-app messages, and Live Activities.
<img src="{{image_url}}"/>
{{ ... }}
- Display data from a variable or object.{% ... %}
- Execute conditional statements or loops.Source | Example | Set via |
---|---|---|
Tag | {{ first_name }} | OneSignal SDK or API (tags ) |
Property | {{ subscription.email }} | System-managed (email, external_id, language) |
Custom Data | {{ message.custom_data.key }} | Passed in API call to create message |
==
, !=
, >
, <
, >=
, <=
and
, or
contains
(string or array)if
, elsif
, else
unless
{{ variable | filter }}
to adjust how the data is displayed.
default
date
bill_due : 1687968776
now
(or today
) along with the date filter.
capitalize
round
pluralize
for
loopsfor
loop, refer to the for
loop object.
for
loops in liquid syntax can lead to poor notification delivery performance in certain rare cases. Be mindful of your usage of for
loops. Also note that we prevent the usage of for
loops in a few Push Channel fields: contents
, headings
, subtitle
, apns_alert
, and url
limit
& offset
where
where
, you can create an array containing only the products that have a type
of kitchen
.
Command | Description | Example | Example Output |
---|---|---|---|
replace | Replaces a substring with another string. | {{ 'hello world' | replace: 'world', 'there' }} | hello there |
capitalize | Capitalizes the first letter of a string. | {{ 'hello' | capitalize }} | Hello |
upcase | Converts a string to uppercase. | {{ 'hello' | upcase }} | HELLO |
downcase | Converts a string to lowercase. | {{ 'HELLO' | downcase }} | hello |
strip | Removes leading and trailing whitespace from a string. | {{ ' hello ' | strip }} | hello |
strip_html | Removes all HTML tags from a string. | {{ '<p>hello</p>' | strip_html }} | hello |
truncate | Shortens a string to a specified length, adding an ellipsis (…) if needed. | {{ 'This is a long sentence' | truncate: 10 }} | This is a… |
truncatewords | Truncates a string after a certain number of words. | {{ 'This is a long sentence' | truncatewords: 2 }} | This is… |
replace_first | Replaces the first occurrence of a substring. | {{ 'hello world' | replace_first: 'world', 'there' }} | hello there |
prepend | Adds a string to the beginning of another string. | {{ 'world' | prepend: 'hello ' }} | hello world |
append | Adds a string to the end of another string. | {{ 'hello' | append: ' world' }} | hello world |
lstrip | Removes leading whitespace from a string. | {{ ' hello' | lstrip }} | hello |
rstrip | Removes trailing whitespace from a string. | {{ 'hello ' | rstrip }} | hello |
{{- ... -}}
, {%- ... -%}
to trim surrounding whitespace.
See Whitespace control for more details.
{% raw %}
and {% endraw %}
to prevent Liquid parsing. See “raw” syntax.