Back to Notifications Guides

This guide applies to:

  • Basic Edition
  • Plus Edition
  • Pro Edition
  • Business Edition

Introduction

The Notification Subject and Message fields use Twig Code Templates. These help you automatically add in information from each appointment.

This guide will help you personalize your Notifications to make each customer feel like you wrote them especially for them. And, if you’d like to start with a base message use our Default Notification Templates.

Visit our other guide for Basic Twig Templates that you can copy and paste.


Advanced Twig Code Templates

The following Twig Code Templates need to be tweaked, don’t copy and paste into your notification subject and message until you’ve read the instructions to use them.

Change Payment Received Format

Customize how the currency is displayed in the Payment Received template, by default it looks like this:

{{ Appointment.payment_received }}

We’ll be adding the number_format( ) function to customize the decimal places.

By default, the number_format function on its own will return 0 decimal places.

{{ Appointment.payment_received | number_format }}

To make sure your payments are always formatted to 2 decimal places, use the function like this.

{{ Appointment.payment_received | number_format(2) }}

Specific Customer Information Fields

Display a specific customer information field using this Twig Code Template below:

{{ attribute( Appointment.customer_information, 'MYFIELD' ) }}

Replace MYFIELD with the name of your customer information field.

Returning Values in Checkboxes

If your field is a checkbox, you’ll need to use a slightly different format. Since the checkbox field can hold more than one value (array), you’ll need to list all the possible values out using the |join function.

Let’s say, for example, your checkbox has 4 possible values: one, two, three, four. If someone selects all four values in the booking form, this is what the different join functions could output.

{{ attribute( Appointment.customer_information, 'MYFIELD' ) | join }}

This join function without any parameters would output: onetwothreefour

There are no spaces between the values.

{{ attribute( Appointment.customer_information, 'MYFIELD' ) | join(', ') }} 

This join function with a single parameter would output: one, two, three, four

The single parameter lets the values be separated by the same [comma + space] every time. You can separate the values with any characters you want. For example, join(‘~ ‘) would output one ~ two ~ three ~ four.

{{ attribute( Appointment.customer_information, 'MYFIELD' ) | join(', ', ' and ') }} 

And, this code snippet would output: one, two, three, and four

The first parameter tells the values to be separated by the [comma + space] for the first values except for the last one. The second parameter denotes the last separation of values, in this case, its [space + and + space].

This can also be whatever you’d like, for example, join(‘~ ‘, ‘ $ ‘) would output one ~ two ~ three $ four.


Show Customer Information Only If Filled Out

If statements are used to display Twig Code Templates only if the conditions are met.

For example, you might have an optional customer information field that you only want to show if the customer fills it out.

Use this Twig Code Template to show the field information only if the customer fills it out:

{% if attribute(Appointment.customer_information, 'MYFIELD') %}
MYFIELD: {{ attribute(Appointment.customer_information, 'MYFIELD') }}
{% endif %}

Replace MYFIELD with the name of your customer information field.


Custom Appointment Date Format

We can customize how the date is formatted for our Appointment Date and Time. This is done using the date( ) function.

For example, this is used to show us the Start Date and Time of our Appointment in the Admin Timezone:

{{ Appointment.start_date | date("F d, Y g:ia (T)", Appointment.customer_timezone) }}

In the Message, this will could look like this: July 01, 2020 2:30 pm (CDT)

That’s because the date( ) function of the Twig Code Template is formatting it: “F d, Y g:ia (T)”

Here’s a key to what each of these letters means:

  • F: The full name of the month (ex. January, February, March)
  • M: The month, three letters (Jan-Dec)
  • m: The month, number representation (1-12)
  • d: Day of the month, leading zeroes (01 to 31)
  • j: The day, no leading zeroes (1 – 31)
  • D: The weekday, in three letters (Mon, Tue, Wed)
  • Y: Year, in 4 digits
  • y: Year, in 2 digits

  • g: 12 hour time format, no leading zeroes
  • G: 24 hour time format, no leading zeroes
  • i: Minutes (00 to 59)
  • a: (am or pm)
  • T: Abbreviated time zone

So, if instead, I wanted my date formatted like this: Mon Jul 1, 2020 14:30 CDT

I’d change it to “D M d, Y G:i T” from “F d, Y g:ia (T)”

And my new Twig Code Template would look like this:

{{ Appointment.start_date | date("D M d, Y G:i T", Appointment.customer_timezone) }}

Make sure to use the correct timezone for the person who is receiving the message. Even if most of your customers are in your timezone, use the correct Twig Code Template to avoid any confusion.

Admin Timezone

Start Date:

{{ Appointment.start_date | date("F d, Y g:ia (T)", Appointment.date_timezone) }}

End Date:

{{ Appointment.end_date | date("F d, Y g:ia (T)", Appointment.date_timezone) }}

Customer Timezone

Start Date:

{{ Appointment.start_date | date("F d, Y g:ia (T)", Appointment.customer_timezone) }}

End Date:

{{ Appointment.end_date | date("F d, Y g:ia (T)", Appointment.customer_timezone) }}

Convert to Uppercase

To convert any of the Twig Code Template outputs to uppercase, add the bit to the end of the statement: | upper

For example, if I wanted the customer name to be uppercase, I’d write:

{{ customer_name | upper }}

Grab the First Name Only

To only display the first name from the Name field, use this instead of the {{customer_name}} template:

{{ (customer_name|split(' '))[0] }}

Note: This cannot decipher between first names, prefixes, or double names. If someone writes their name as Mary Lou Jones, this will grab only Mary. And if someone writes in Dr. Jones, this will grab only Dr.


Conditional Statements

Twig offers if, elseif, and else statements. And supports logical conditions such as:

  • Equals ==
  • Not equals !=
  • Less than <
  • Less than or equal to <=
  • Greater than >
  • Greater than or equal to >=

And other cool conditions such as:

  • is even
  • is odd
  • now
  • not
  • and
  • or

And again, here’s a key to the different letters you can use with the date() function:

  • F: The full name of the month (ex. January, February, March)
  • M: The month, three letters (Jan-Dec)
  • d: Day of the month, leading zeroes (01 to 31)
  • j: The day, no leading zeroes (1 – 31)
  • D: The weekday, in three letters (Mon, Tue, Wed)
  • Y: Year, in 4 digits

  • g: 12 hour time format, no leading zeroes
  • G: 24 hour time format, no leading zeroes
  • i: Minutes (00 to 59)
  • a: (am or pm)
  • T: Abbreviated time zone


If statement

If A is true, then show B.

{% if A %}
B
{% endif %}

If examples

If the day this message goes out is a Monday, I want to include the message, “Hello, it’s Monday!”.

{% if "now" | date('l') == "Monday" %}
Hello, it's Monday!
{% endif %}

If the appointment start date is on a Monday, I want to include the message, “Your appointment is this coming Monday!”.

{% if Appointment.start_date | date("l", Appointment.customer_timezone) == "Monday" %}
Your appointment is this coming Monday!
{% endif %}

Elseif statement

If A is true, then show B. If C is true, then show D. If both A and C are false, show E.

You can add in as many stacked elseif statements as you want, just make sure not there’s no overlap between the statements!

{% if A %}
B
{% elseif C %}
D
{% else %}
E
{% endif %}

Elseif examples

Show messages depending on the hour an appointment starts on.

{% if Appointment.start_date | date("G", Appointment.customer_timezone) == 13 %}

This appointment is between 1 PM and 2 PM, but not 2 PM.

{% elseif Appointment.start_date | date("G", Appointment.customer_timezone) == 14 or Appointment.start_date | date("G", Appointment.customer_timezone) == 15 %}

This appointment is between 2 PM and 4 PM, but not 4 PM

{% else %}

This appointment is anytime not between 1 PM and 4 PM

{% endif %}

Else statement

If A is true, then show B. If A is false, then show C.

{% if A %}
B
{% else %}
C
{% endif %}

Else examples

Show message depending on whether the appointment starts at an even or odd hour.

​{% if Appointment.start_date | date("G", Appointment.customer_timezone) is even %} 
​This appointment starts at an even hour. 
{% else %} 
This appointment starts at an odd hour. 
{% endif %}

Still stuck?

File a support ticket with our five-star support team to get more help.

File a ticket

  • Please provide any information that will be helpful in helping you get your issue fixed. What have you tried already? What results did you expect? What did you get instead?
  • This field is for validation purposes and should be left unchanged.


Related Guides