Use this article as a reference guide for customizing notifications. It works from simple to complex, and includes instructions on how to insert a tag (or placeholder) in a notification, how to format text and dates, and how to set up more complex logic in your notifications, like conditional or iterative statements.

Keep in mind that many of our notification templates already use advanced code. However you're looking to customize notifications, chances are we have an example of it in our templates. Following is a list of notification styles and logic, along with examples from our notification templates. You can use these to help you customize other notifications in a similar way.

Tags and styles

We use Markdown for styling our notifications, as shown in the following examples.

Insert a tag

When writing a notification, {{ }} indicates a placeholder. You place a tag within these double curly brackets to expose that information in the notification.

For example, in the Event created notification, {{ event_name }} would the pull the name of the created event into the notification.

When you're working in a notification, you can click Need help with tags? to see a list of tags you can use.

Format text

The following table shows some simple ways to format your notifications.

Format

How to write it

What it looks like in the notification

Bold

This event is *mandatory*.

This event is mandatory.

Italics

This is a _managers-only_ event.

This is a managers-only event.

Unordered list

Don't forget to bring:
*a notebook and pen
*snacks
*your brain

Don't forget to bring:

  • a notebook and pen

  • snacks

  • your brain

Ordered list

To get there:
1.Take the elevator to the 2nd floor.
1.Turn right and go to the end of the hall.
1.Knock twice on the door.

To get there:

  1. Take the elevator to the 2nd floor.

  2. Turn right and go to the end of the hall.

  3. Knock twice on the door.

Add links

To add a link with a display text to your notification, surround the display text with brackets [ ], followed by the link tag within parentheses ( ).

This example is from the Event updated notification template:

Heads up that the event [{{ event_name }}]({{ event_link }}) was updated.
  • [{{ event_name }}] means that the display text will be the event name

  • ({{ event_link }}) means that the URL link will be the link to the event page in the PlusPlus application

The end result would look something like this:

Heads up that the event Coaching for Results was updated.

Format dates and

Tags that show date and time display in a default format on a notification, but you can change the date format by adding a filter to a date/time tag using the vertical bar |.

In this example from the Session reminder notification template, {{ enrolled_at }} has a default date format, but we've added a filter to change the way it appears, both with date/time stamp and with a relative date.

You were booked on {{ enrolled_at|date:"D, M d, Y" }} ({{ enrolled_at|timesince }} ago).
  • {{ enrolled_at|date:"D, M d, Y" }} shows the enroll date with the three-letter abbreviation for day of the week D, the three-letter abbreviation for the month M, the two-digit date of the month d, and the year with all four digits Y.

  • {{ enrolled_at|timesince }} shows how long ago the enroll date was timesince.

The end result would look something like this:

You were booked on Mon, Nov 18, 2022 (ten days ago).

In this example, we want to include a time zone for a session date/time.

{{ session_start_time | timezone:host_timezone | date:"D, M j \a\t P" }}
  • session_start_time pulls the start time for the session into the notification.

  • | timezone:host_timezone means that the session start time is in the host's time zone.

  • | date:"D, M j \a\t P" determines how the date and time are displayed.

Common date filters include:

filter

use

example

S

adds suffix for date of the month

1st, 2nd, 3rd, and so on

F

month fully written

January, February, and so on

y

two-digit year

22 (for 2022), 23 (for 2023), and so on

Check out this list of date filters so you can format dates however you need to.

Logical expressions

We use django template language for logical expressions, allowing you to use conditional and iterative statements in your notifications.

Conditional statements using if

Add a conditional statement to include info in a notification if it's applicable and exclude it if it's not.

For example, the Event invite notification template includes a message from the person who sent the invite, but only if that person wrote an invite message.

Here's how that messaging is written in the notification:

{% if invite_message %}
{{ user_name }} says:
"{{ invite_message }}"
{% endif %}
  • {% if invite_message %} begins the conditional statement {% if, and means that if there is an invite message, it should be included in the notification in the following way...

  • {{ user_name }} says: gives the name of the person who sent the invite, followed by "says:"

  • "{{ invite_message }}" gives the content of the invite message.

  • {% endif %} ends the conditional statement; everything between {% if and {% endif %} is impacted by the condition.

Note that an unguarded tag (a tag without an if or for statement around it) does not pull data into the notification if the data does not exist. In the above example, you could just put {{ invite_message }} in the notification, and if the person who sent the invite had included a message, it would appear in the notification; if they hadn't, it would not appear. Because the above example includes the {{ user_name }} says: statement, we want to use the if statement to ensure the notification doesn't read "Alicia Mercado says:" without any message following it.

Conditional statements using else

Within a conditional if statement, you can add an else statement to include one of multiple options in a notification, whichever is correct in the situation.

In the Event type requested notification template, a message indicates how many other team members are expected for a requested event. If there is only one other person expected, we want the notification to say, "1 additional person is expected." If more are expected, we want it to say, for example, "3 additional people are expected."

This is how the notification is written:

{{ quantity }} additional {% if quantity == 1 %} person is {% else %} people are {% endif %}expected in the event.
  • {{ quantity }} is the number of people expected.

  • {% if quantity == 1 %} person is begins the conditional statement % if, and means that if the quantity equals 1, the notification will say "person is".

  • {% else %} people are means that if the quantity does not equal 1 (that is, more than 1), the notification will say "people are".

  • {% endif %} ends the conditional statement.

Conditional statements using else and elif (else if)

Use an elif (else if) statement to include another conditional statement and make the notification use whichever condition is correct in the situation. In the previous example {% else %} tells the notification what to say if the initial condition is not true. On the other hand, elif tells the notification what to say if a separate condition is true.

This is an example from an assignment reminder notification where the messaging is different based on the number of reminders that have been sent.

This is your {% if reminder_count == 1 %}first{% elif reminder_count == 2 %}second{% else %}*last*{% endif %} reminder that you were assigned to {{ content_name }}.
  • {% if reminder_count == 1 %}first begins the conditional statement with the first condition that, if this is the first reminder sent reminder_count == 1 , the message says “first reminder”.

  • {% elif reminder_count == 2 %}second is the second condition, saying that, if the reminder count is not 1, but 2, the message says, “second reminder”.

  • {% else %}*last* means that, if this is not the first or second reminder, the message says, “last reminder”.

  • {% endif %} ends the conditional statement.

Looping or iterative statements using for

Use a for statement to insert looping or iterative logic, allowing you to capture a full list of items in your notification.

For example, the Event updated notification uses a for statement to insert all the timeslots for an event in the notification. It looks like this.

{% for timeslot in timeslots %}
{{timeslot.date_range}} ({{timeslot.timezone}})
{% endfor %}
  • {% for timeslot in timeslots %} looks for all the timeslots in an event and lists them.

  • {{timeslot.date_range}} ({{timeslot.timezone}}) lists all the event timeslots, first with the date and time, and then with the time zone in parentheses.

  • {% endfor %} ends the for statement.

See also

Did this answer your question?