About Liquid
Liquid is an open-source template language that enables dynamic content to be added to trigger notifications and pop-up messages. You can use a series of objects, tags and operators to specify what information shows in your messages.
Check the Liquid documentation (Github) to learn how to use Liquid.
Using Liquid with OnLocation
When you enter the message for your notification, you can use Liquid templates to narrow what displays. The operators you add make the information conditional on how the guest answers the question. You can ask multiple questions using basic and custom question placeholders that are activated for sign in or out.
For example, if you ask your guest during sign in if they'd like a drink, you can set up the host email notification to include this information only if they've specified the drink type. It will not be included in the notification if they have not answered the question.
When you add OnLocation placeholders within the Liquid tags, remove the curly brackets that are automatically added around the placeholders. Check the examples below to see the format.
Preview the message before activating it. If there are any display issues, you can add whitespace controls so there are no blank spaces in the email.
Template examples
The following examples show how you can use Liquid templates with custom or basic questions:
- If a contractor is asked if they have all the required PPE and answers no, the notification will specify what equipment is missing:
{% if cqanswer.q_888.q_1737 == "No" %}
Please bring the following items to reception: {{ cqanswer.q_888.q_1738 }}
{% endif %} - If the guest answers that they need evacuation assistance, the notification will specify this:
{% if match.assistance == "Yes" %}
In the event of an evacuation, please assist this contractor in leaving the premises.
{% endif %} - If the contractor is asked if they are working alone, depending on the answer, the notification will outline what emergency equipment they have:
{% if cqanswer.q_894.q_1755 == "Yes" %}
The contractor is working alone and has the following emergency equipment:
{{ cqanswer.q_894.q_1756 }}
{% endif %}
{% if cqanswer.q_894.q_1755 == "No" %}
The contractor is working alone and does not have any emergency equipment.
{% endif %}
Trigger example: Contractor sign in
In the example outlined below, a custom questionnaire asks contractors signing in if they have the required personal protection equipment (PPE). If the contractor responds that they don't have the required PPE, an email notification is sent to the selected Safety Officer notifying them that the contractor is missing a specific piece of equipment.
Before you start, set up the custom questionnaire and activate it for the required sign-in methods.
To create a trigger with a dynamic notification:
- Go to Locations, then select the location from the drop-down list.
- Select Triggers.
- Click Create a New Trigger.
- In the Trigger Details tab, give the trigger a name, select Active as the status, and select Contractor Sign in as the event. Click Next.
- (Optional) In the Trigger Rules tab, add any trigger rules. Click Next.
- In the Trigger Actions tab, click Create a New Action.
- Choose an email notification as the action.
- Select Matched Person as the recipient type, then choose Selected Safety Operator.
- Enter the email subject. Use placeholders to customize the subject.
- Enter the message. You can use a combination of text, placeholders, and Liquid templates.
If you're adding a placeholder inside Liquid tags, remove the curly brackets automatically added when you selected a placeholder.
{{ match.name }} has just arrived on-site and does not have the required PPE.
{% if cqanswer.q_888.q_1737 == "No" %}
Please bring the following items to reception: {{ cqanswer.q_888.q_1738 }}
{% endif %} - Click Preview, then select a record to preview the notification.
- Click Close.
- Click Save & Close.