🎯 Dynamic Content with Twig Logic
Introduction
Yes—you already segment your audience in Bookboost using filters to decide who should receive a campaign. But did you know there's a powerful way to personalise the message inside that campaign for each recipient?
Enter Twig templating — your expert-level trick to dynamically customise the content based on a guest’s booking details, preferences, and profile data. Instead of creating multiple campaigns, you can run one smart campaign where the content adapts automatically per guest.
In this article, we’ll share just a few examples of what you can do with Twig to optimise your guest journeys and deliver more relevant messages at scale.
🧠 What is Twig?
Twig is a templating language that allows you to insert dynamic, data-driven content into your campaign messages. With Twig, you can:
- Show or hide text depending on booking data
- Personalise messages based on services like parking or breakfast
- Adapt language and tone to the guest’s profile
- Generate door codes dynamically
Think of it as an expert trick to push personalisation beyond standard segmentation—without creating multiple campaigns.
💡 Example Use Cases for Personalisation
These are just a few examples of how you can use Twig. Each example illustrates how content can adapt to what the guest has booked or who the guest is.
1. Parking Instructions Based on Product Booked 🚗
Only show parking information if parking is part of the reservation:
{% if 'parking' in orders.numbers_list|lower or 'parken' in orders.numbers_list|lower %}
<p>Parking is available on the street behind the hotel. Spaces are limited and offered on a first-come, first-served basis. Please contact reception for assistance or alternative parking options.</p>
{% endif %}
2. Generate a Unique Door Code Depending on Parking Packag 🔐
Change the door code logic based on the presence of a parking product:
{% set hasParking = false %}
{% for item in orders.numbers_list|split(',') %}
{% if item in ['PRODUCT_PARKING_PACK1', 'PRODUCT_PARKING_PACK2'] %}
{% set hasParking = true %}
{% endif %}
{% endfor %}
{% if hasParking %}
{% set door_code = doorcode('your_doorcode_key_here', 985, true) %}
{% else %}
{% set door_code = doorcode('your_doorcode_key_here', 763, true) %}
{% endif %}
<strong>{{ door_code }}</strong>
3. Localise Titles into German 🇩🇪
Bookboost gathers the titles from the PMS, most PMS only use English titles. With the Twig you can automatically translate English titles into the appropriate German salutation. Perfect for maintaining proper formality in emails sent to German-speaking guests.
{% if primary_guest.title == 'Mr.' %}
Sehr geehrter Herr {{ primary_guest.full_name }}
{% elseif primary_guest.title == 'Mrs.' %}
Sehr geehrte Frau {{ primary_guest.full_name }}
{% else %}
Sehr geehrte/r {{ primary_guest.full_name }}
{% endif %}
4. Add Breakfast Message When Included in the Rate Plan 🍳
Include a breakfast description only when breakfast is part of the rate:
{% if 'breakfast' in rate_plan.name|lower %}
<p>Start your day with our complimentary breakfast, served daily from 6:30 AM to 10:00 AM. Indulge in a delicious variety of hot and cold options, including freshly baked pastries, scrambled eggs, bacon, and waffles. Enjoy fresh coffee, juice, and more.</p>
{% endif %}
🛠️ How to Add Twig Code in a Campaign
- Go to Campaigns.
- Choose or create your campaign.
- In the email editor, add your Twig code directly into any text block.
- The code may appear as raw HTML or Twig in the editor.
- Use the Preview function to test with real or demo guest data to confirm the dynamic output.
- Save and send when ready.
Advanced Tips
🧱 Reuse Twig logic with Content Blocks:
If you plan to use the same Twig code across multiple campaigns, add it to a Content Block. This way:
- You only need to update the logic once.
- All campaigns using that block will reflect the change automatically.
- It reduces errors and saves time.
For more information on setting up Content Blocks, check out this article: 📚 Save time with Content Blocks
🧪 Always preview both scenarios:
Test both "true" and "false" cases (e.g. with and without parking) using the campaign preview tool and sample guest profiles.
🧹 Use helpful filters:
Combine Twig with filters like |lower
, |split(',')
, or |raw
to ensure accuracy in text processing.
🤖 Need help creating Twig logic?
If you have a personalisation idea but are unsure how to build the code, you can ask ChatGPT for assistance. Just describe your case, and it can help you generate the right Twig code!
✅ Conclusion
Twig makes your Bookboost email campaigns smarter by responding to your guests’ unique details—automatically. From personalised greetings to conditional offers and service-based instructions, you can build truly guest-centric communication.
This article showed just a few examples—many more are possible depending on the guest data available. Whether you want to adjust tone, content, or language, Twig gives you the flexibility to do it all.