Email/SMS Template Variables

ADVANCED TOPIC: This page is a full reference for the written template language Buzzshot uses in emails and SMS. You do not need any of it for everyday messages, the editor's { } button inserts the common variables for you. If anything here is confusing, just get in touch and tell us what you are trying to do, we will be happy to help!

Buzzshot lets you customise the emails and SMS it sends to your players. You will find a { } icon in the editor to help you insert common variables into your message templates. For example:

Inserting Variables

One common variable is your Game Master's name, which you can drop into the email you send after a game to encourage a more personal review. The video below shows how to add the Game Master name and gives a gentle introduction to conditions.

The rest of this page explains how to write these variables by hand, which is useful in the older editor and any time you want to go beyond what the { } button offers. It starts with the simple basics and builds up to the more advanced features.

1. Variables: putting data into your message

A variable is a piece of data about the booking, the game, or the player. You write it inside double curly braces, and when the message is sent Buzzshot swaps it for the real value:

{{ player.first_name }} becomes the player's first name, for example "Bob".

The dot lets you reach inside something for a more specific piece of data. For example player is the player, and player.first_name is that player's first name.

Here are some of the most common variables you can use:

{{ player.first_name }} The first name entered for the player (eg "Bob")

{{ player.last_name }} The last name entered for the player (eg "Smith")

{{ room.name }} The name of the room played

{{ game.team_name }} The team name the players entered

{{ game.score }} The score for the game (if collected, you can enable that in settings)

{{ game.hints }} The number of hints given in the game (if collected, you can enable that in settings)

{{ game.game_master }} The name of the game master who took the game (if collected, ask if you'd like a game master field added)

{{ organization.name }} The name of your organization

{{ organization.url }} The website of your organization

{{ reviews_widget }} Inserts your currently selected reviews widget (usually the review buttons for TripAdvisor, Google and so on, but look in Reviews & Feedback in the settings for what yours is set to). This is often inserted automatically by your template, so you may not need to add it yourself.

If a variable has no value (for example, a Game Master was never recorded), it simply prints nothing.

2. Filters: tidying up how a value looks

Sometimes the raw value is not quite how you want it to read. A filter changes how a value is displayed. You add one with a vertical bar | straight after the variable:

{{ game.team_name|upper }} shows the team name in capitals, eg "THE A TEAM".

Some filters take an extra setting after a colon :

{{ game.team_name|truncate:20 }} shortens a long team name to 20 characters.

You can chain filters one after another, and they apply left to right:

{{ game.team_name|truncate:20|upper }} shortens the name, then capitalises it.

Text filters

Filter What it does Example
upper Puts text in CAPITALS {{ player.first_name\|upper }} → "BOB"
truncate:20 Shortens text to the given length, adding "..." {{ game.team_name\|truncate:8 }} → "The Esc..."
default:"text" Uses your fallback text when the value is empty {{ game.game_master\|default:"our team" }} → "our team"
yesno Turns a yes/no value into the words "yes" or "no" {{ game.did_win\|yesno }} → "yes"
commas Adds thousands separators to a number {{ game.score\|commas }} → "1,250"
numsuffix Gives the ordinal ending for a number (st, nd, rd, th) You came {{ game.rank }}{{ game.rank\|numsuffix }} → "You came 3rd"
length Counts the items in a list (or letters in text) {{ players\|length }} → "5"

Date and time filters

Dates and game times need a filter to read nicely.

Dates:

{{ game.datetime|datetime }} The date and time of the game in the default format (eg "1 Jan 2022 10:10 AM").

{{ game.datetime|date }} Just the date, in the default format (eg "1 Jan 2022").

You can pass your own format in quotes to control exactly how it looks:

{{ game.datetime|datetime:"%A %-d %B %Y" }} → "Saturday 1 January 2022"

The format uses standard date codes. See this document for the full list of codes you can use (for example %Y is the four digit year, %b is the short month name, %-I:%M %p is the 12 hour time).

Game times (the escape time / duration):

Filter What it does Example for a 52 min 30 sec game
timeclock Digital clock form {{ game.time\|timeclock }} → "52:30"
timewords Words and numbers {{ game.time\|timewords }} → "52 minutes 30 seconds"
timeminutes Whole minutes only {{ game.time\|timeminutes }} → "52"
timeseconds Seconds part only {{ game.time\|timeseconds }} → "30"
timehours Whole hours only (useful for very long games) {{ game.time\|timehours }} → "0"
timeminutesnohours Minutes left after taking out whole hours {{ game.time\|timeminutesnohours }} → "52"

The time filters accept a zero padding width if you want a fixed number of digits, eg {{ game.time|timeminutes:2 }} → "52".

3. Conditions: showing content only when it applies

A condition lets you include a piece of content only when something is true. You wrap it between {% if ... %} and {% endif %}. For example, to congratulate winners only:

{% if game.did_win %}
Congratulations on winning our game!
{% endif %}

Add an {% else %} to show alternative content the rest of the time:

{% if game.did_win %}
Congratulations on winning our game!
{% else %}
At least you tried! Come back and beat it next time.
{% endif %}

Testing values in a condition

On its own, {% if game.game_master %} is true whenever there is a value (a Game Master was recorded) and false when it is empty. You can also compare values:

You can write Meaning
game.score > 1000 greater than
game.score >= 1000 greater than or equal to
game.score < 1000 less than
game.score <= 1000 less than or equal to
room.name == "The Heist" equals (text in quotes)
room.name != "The Heist" does not equal
"VIP" in game.tags the list/text contains this
"VIP" not in game.tags does not contain this

Join several tests together with and, or, and not, and group them with brackets:

{% if game.did_win and game.score > 500 %}
A winning score of {{ game.score }}, brilliant!
{% endif %}
{% if game.score > 1000 or game.hints == 0 %}
That was a seriously impressive run.
{% endif %}

You can put conditions inside conditions to handle several cases:

{% if game.did_win %}
  {% if game.hints == 0 %}
A flawless escape with no hints!
  {% else %}
A great escape!
  {% endif %}
{% else %}
Better luck next time!
{% endif %}

4. Loops: repeating content for a list

If a variable holds a list (for example a list of players), a loop repeats a piece of content once for each item. You wrap it between {% for ... %} and {% endfor %}:

{% for player in players %}
{{ player.first_name }} {{ player.last_name }}
{% endfor %}

Inside the loop you also get some handy counters:

Inside a loop Meaning
{{ forloop.counter }} The current position, starting at 1
{{ forloop.counter0 }} The current position, starting at 0
{{ forloop.first }} True on the first item
{{ forloop.last }} True on the last item

For example, a numbered list:

{% for player in players %}
{{ forloop.counter }}. {{ player.first_name }}
{% endfor %}

A few things to keep in mind

  • Spelling and dots matter. {{ player.first_name }} works, but a typo or a missing dot will simply print nothing.
  • Close every {% if %} with {% endif %} and every {% for %} with {% endfor %}, otherwise the message will not render.
  • The available variables depend on the message, since not every email knows about a game or a Game Master. If you are unsure what is available for a particular message, just ask us.

If you need any help with any of this, or you would like to use some data we do not list here, please get in touch!

Related Articles