Message Variables
All bot and agent messages can include context variables. Tags are indicated by the double mustaches {{ and }} around them.
A typical template:
Hello {{contact.givenName}}, your {{result.Maintenance.brand}} is ready!
When said to a contact named Chris, with a Maintenance form result for his Mercedes, this will produce the following:
Hello Chris, your Mercedes is ready!
Variables can be used in chat bubbles, canned responses, articles and WhatsApp templates. It works by expanding tags in a message text using values provided by the current running context.
Most variables have a namespace prefix. The following variable types are available:
Agent Name
The name of the user sending the message.
Example:
Cheers, {{agentName}}
Contact Profile Attributes
Contact profile attributes have the contact
prefix. In the context of a contact conversation, the following contact profile attributes are commonly used as variables:
- name
- givenName
- familyName
- telephone
In addition, the following contact profile variables can also be used (when configured for use by the organization):
- additionalName
- initials
- honorificPrefix
- honorificSuffix
- gender
- worksFor
- avatar
- locale
- address.streetAddress
- address.streetNumber
- address.postalCode
- address.addressLocality
- address.addressRegion
- address.addressCountry
Example:
Hello {{contact.name}}, we have a branch in {{contact.address.addressLocality}}
Custom Data Attributes
In addition to the fixed contact profile fields, custom contact data attributes (underneath the contact profile in the UI) can be used as variables using the data
prefix.
Example:
Your assigned dealer is {{data.dealer}}
Form Values
Forms that are currently active have their values exposed as message variables.
Example:
We can book your testdrive in a {{form.Test Drive.brand}} {{form.Test Drive.model}} now.
Result Values
Values in the most recent 10 results are available as variables through the result
prefix followed by the form name.
Example:
Your test drive in a {{result.Test Drive.brand}} {{result.Test Drive.model}} is booked.
Message Meta Variables
Any message.meta
properties that were passed with the message are available as non-prefixed variables. This can be useful when sending WhatsApp templated messages and for bots.
Example:
Request: POST /v2/conversations/590bd49f458b716046347f47/messages
{
"type": "chat",
"text": "You live in {{city}}",
"meta": {
"city": "Amsterdam"
}
}
Links
The following variables generate links to consumer media:
- {{video}}
- {{messenger}} or {{facebook}}
- {{whatsapp}}
Using variables in WhatsApp templates
All the variables referenced above may be used when submitting new WhatsApp templates for approval. When using a WhatsApp Templated Message in a conversation, the correct values will be passed along to Facebook to be merged in.