Skip to main content
LeadConduit supports combining, formatting, hashing, and performing math on values using template markup. Templating in LeadConduit is based on the popular Handlebars semantic templating library. A template is a string which contains any number of variable placeholders

Template Variable

Variable placeholders in templates start and end with two curly-brace characters: {{ lead.first_name }}. Multiple placeholders can be combined in a single template: {{ lead.first_name }} {{ lead.last_name }}. The universe of possible variables available to a template depends on the fields defined in your flow and the steps you’ve added to your flow.

Variable Formatting

LeadConduit has a built-in helper for formatting numbers and dates. Formatting a value is done with the format helper. If the value is a date field, then you may use date formatting options with the helper. If it’s a number field, then you may use the number formatting options with the helper.

Date Variable Formatting

To format a date, use the format helper: {{ format lead.dob format="YYYY-MM-DD" }} results in ‘2015-06-24’. The format option is a string which defines the format of the date. This format can be any combination of the below tokens. To escape characters in format strings, you can wrap the characters in square brackets: {{ format lead.dob format="[It's] MMMM Do" }} results in “It’s October 12th”.

Date Format Tokens

Localized Date Formats

Because preferred formatting differs based on locale, there are a few tokens that can be used to format a moment based on its locale. There are upper and lower case variations on the same formats. The lowercase version is intended to be the shortened version of its uppercase counterpart. To change the locale, use the locale options: {{ format date format="LLL" locale="fr" }} results in “24 june 2015 17:24”.

Number Variable Formatting

To format a number, use the format helper: {{ format lead.mortgage.first_mortgage_balance format="$0,0.00"}} results in ‘$45,302.00’. The format option is a string which defines the format of the number. See the table of examples below: Use the locale option to format the number to a particular locale: {{ format lead.mortgage.first_mortgage_balance locale="fr" format="$0,0.00" }} results in ‘€45 302.00’.

Converting Number and Boolean to String

Fields of type number and boolean can be converted to string using the format helper with the dataType="String" option: {{format field_name dataType="String"}} Example:
  • Input: {{format lead.age dataType="String"}} with lead.age = 30
  • Output: “30”

Converting String to Number

Fields whose final result from the format helper is a string can be converted to a number if the dataType="Number" option is passed and the value is a string representing a valid number. Examples:
  • Input: {{format lead.postal_code dataType="Number"}} with lead.postal_code = ‘78751’
  • Output: 78751 (as a number value)
If the string does not represent a valid number, the result will not be converted:
  • Input: {{format lead.postal_code dataType="Number"}} with lead.postal_code = ‘H3Z 2Y7’
  • Output: ‘H3Z 2Y7’
This can also be used with dates if the formatting returns only numbers, such as epoch time:
  • Input: {{format lead.source_timestamp format="X" dataType="Number"}} with lead.source_timestamp = ‘2015-06-24T17:24:49.060Z’
  • Output: 1435166689 (as a number value)

Variable String Manipulation

Strings can be manipulated with the following helpers:

Lowercase

Transforms the value to lowercase: {{lowercase field_name}} Example:
  • Input: {{lowercase lead.first_name}} with lead.first_name = “Mike”
  • Output: “mike”

Uppercase

Transforms the value to uppercase: {{uppercase field_name}} Example:
  • Input: {{uppercase lead.first_name}} with lead.first_name = “Mike”
  • Output: “MIKE”

Substring

Returns a substring from the start position to the end position, or from the start position to the end of the string if no end position is provided: {{substring field_name start="3"}} Example:
  • Input: {{substring lead.first_name start="3"}} with lead.first_name = “Michael”
  • Output: “chael”
{{substring field_name start="2" end="4"}} Example:
  • Input: {{substring lead.first_name start="2" end="4"}} with lead.first_name = “Michael”
  • Output: “ich”

Replace

Replaces the pattern with the content of the replace option. The pattern can be a literal string or a regular expression using the regexp() option: {{replace field_name pattern="Mi" replace="At"}} Example:
  • Input: {{replace lead.first_name pattern="Mi" replace="At"}} with lead.first_name = “Michael”
  • Output: “Atchael”
{{replace field_name pattern="regexp(h.{3})" replace="ke"}} Example:
  • Input: {{replace lead.first_name pattern="regexp(h.{3})" replace="ke"}} with lead.first_name = “Michael”
  • Output: “Micke”

Extract

Extracts all occurrences found with the regular expression in the pattern: {{extract field_name pattern="\$begin:math:display$(.*?)\\$end:math:display$"}} Example:
  • Input: {{ extract foo pattern="(?\<=#)(\\w+)(?=#)" }} with lead.first_name = “#John#Doe#Smith”
  • Output: “John Doe”

Variable Math

To perform math operations, use the math helper: {{ math "1 + 1" }} results in 2. Of course, variables can also be used: {{ math "1 + lead.random_number" }} might result in 32 depending on the value of lead.random_number. The math expression accepts a pretty basic grammar. Operators have the normal precedence: There are also several pre-defined functions:

Example

To calculate the loan-to-value ratio, given a mortgage loan amount and the value of the home: {{ math "(lead.mortgage.loan.amount / lead.mortgage.new_property_value) * 100" }}%. Note that this example expresses the LTV as a percentage, first by calculating the percentage and then by appending the % character outside the variable placeholder. This could instead be handled using formatting.

Variable Math Formatting

The math helper supports the same options as the format helper for numbers: format and locale. For example, to calculate the loan-to-value ratio and format it as a percentage: {{ math "lead.mortgage.loan.amount / lead.mortgage.new_property_value" format="0.[00]%" }}. This would return the LTV percentage with up to 2 decimal points (i.e. 72.93%) as a string value.

Variable Hashing

LeadConduit supports a wide variety of hashing functions that can be applied to variables in a template. The helper name determines the hashing algorithm. For example, to use MD5 to hash the email address use: {{ md5 lead.email }}. All the following hashing algorithms are supported:
  • md4
  • md5
  • ripemd
  • ripemd160
  • sha1
  • sha224
  • sha256
  • sha384
  • sha512
  • whirlpool
Multiple values can be hashed together: {{ md5 lead.email lead.phone_1 }}. This can be used to salt the hash also: {{ md5 lead.email "this is my salt" }}. The salt option can also be used. This is the equivalent of the last example: {{ md5 lead.email salt="this is my salt" }}. Hashing supports multiple encodings using the encoding option: {{ md5 lead.email encoding="base64" }} results in something like “tkK0IXs0sejTvZFfxlxEUg==”. The following encodings are supported:
  • hex (default)
  • base64
  • latin1