At NeoDeliver, we use Handlebars as the templating language for setting up content across any campaign type. Handlebars makes it easy to create dynamic, personalized content by inserting variables and adding simple logic.
This guide explains how to use Handlebars, provides a list of available variables, and shows how you can include custom variables.
What is Handlebars?
Handlebars is a powerful yet simple templating language that lets you dynamically insert data into your content. Using placeholders like {{variableName}}
, you can personalize messages for your audience.
Example:
Hello {{contact.name}},
Your order #{{orderNumber}} has been shipped and will arrive on {{deliveryDate}}.
Available Variables
You can add some predefined variables to your templates. Below you can find a list of the existing variables.
Contact variables:
contact.id
contact.external_id
contact.name
contact.given_name
contact.last_name
contact.email
contact.phone_number
contact.subscribed_at
contact.lang
contact.birthday
contact.gender
contact.tags
contact.metadata
Campaign variables:
campaign.id
campaign.created_at
campaign.type
campaign.name
Message variables:
message.id
message.email
message.phone_number
message.lang
message.created_at
message.type
Other variables:
unsubscribe_link
Adding Custom Variables
In addition to the predefined variables, you can include custom variables to further personalize your templates. Custom variables must be provided through our API when sending messages.
How to Provide Custom Variables via API
When making an API call to send a campaign, include the custom variables in the
variables
field of the request body.Example API Request:
POST /campaigns/:id/send
{
"contact_id": "ctc_abc",
"variables": {
"customField1": "Value1",
"customField2": "Value2"
}
}Use the custom variables in your template:
Hello {{customField1}},
Here’s some information tailored just for you: {{customField2}}.