Templating Language
The templating language is used in pipelines and external objects to access channel data. It allows you to insert values of template fields, mailing, sender, subscription, and other entities into pipe parameters — for example, when forming a JSON request to an external API.
Prefixes
Each template starts with one of three prefixes that determine how the value is processed:
| Prefix | Behavior | Can be combined with text |
|---|---|---|
$ | Inserts the value as a string | Yes |
$# | Inserts the value preserving the original type (int, bool, array, etc.) | No |
$$ | Unpacks an array into a repeating structure. Used for fields of type "file" | No |
Notation format
For the $ and $# prefixes, two notation variants are available:
$template.field
${template.field}
The curly brace variant is convenient when you need to clearly separate the template from surrounding text:
qwerty${in.a_id}qwerty
For the $$ prefix, only the notation without curly braces is allowed.
Concatenation with text
A template with the $ prefix can be freely combined with constant text:
https://example.com/handler/v${sender.version}/test
Templates with the $# and $$ prefixes cannot be concatenated with strings — they return the value strictly of their own type. For example, the notation qwerty$#in.a_id will cause an error if a_id has type int, because a string and a number cannot be concatenated.
Keywords
Keywords are the names of objects available in the pipeline context. Access to object fields is done through a dot (.), with no limit on nesting depth.
Pipeline data
| Keyword | Type | Description |
|---|---|---|
$in | Object | Data passed to the current pipe from the previous pipe (if any) |
$in.send_message_id | string | Full message identifier (SMID), generated by the mailing for each profile |
$in.unique_message_id | string | Unique message identifier (SMID with version) |
$in.launch_id | string | Unique sending identifier. One per mailing launch |
$in.a_id | int | Account identifier |
$in.c_id | int | Mailing identifier |
$origin | Object | Original data that came into the pipeline |
Channel entities
| Keyword | Type | Description |
|---|---|---|
$template | Object | Data filled in the message for the channel. Fields are accessed by shortname: $template.<field_shortname>. If presets are used, only fields of the selected preset are available. Current preset: $template._presets_ids |
$sender | Object | Data filled in the sender for the channel |
$resource | Object | Data filled in the resource for the channel |
$campaign | Object | Data filled in the mailing for the channel |
$subscription | Object | Data filled in the subscription for the channel |
$account | Object | Data filled in the account for the channel |
Mailing schedule
| Keyword | Type | Description |
|---|---|---|
$camp_schedule | Object | Mailing start and stop settings |
$camp_schedule.start_time | time | Mailing start time in the schedule |
$camp_schedule.stop_time | time | Mailing stop time in the schedule |
Errors
| Keyword | Type | Description |
|---|---|---|
$error | Object | Error data from the previous pipe |
$error.code | int | Error code (for example, HTTP code) |
$error.message | string | Text description of the error |
Accessing fields and arrays
Object fields
Access to an object field is done through a dot (.):
$template.field_name.inner_field_name
Array elements
Access to an array element is done through .%<index> (zero-based indexing):
$template.field_attach.%0.name
Functions
The following built-in functions are available in templates:
General functions
| Function | Description | Example | Result |
|---|---|---|---|
$base64 | Encodes a value in base64 | $base64('Hello') or $base64($sender.login:$sender.password) | SGVsbG8= |
$gen_uniq_int_id | Generates a unique 10-digit number | $gen_uniq_int_id() | 1726573911 |
$escapeCharacters | Removes special characters from a string | $escapeCharacters('Hello \'world\'') | Hello world |
$getWebhookURL | Forms a webhook URL for a callback | $getWebhookURL($origin.send_message_id) | https://altcraft.com/fbp/v1/1/1?fffffffffff |
$removeCodeFromPhone | Removes the region code from a phone number | $removeCodeFromPhone('89505062312') | 9505062312 |
$#toObject | Converts a JSON string to an object | $#toObject('{"a": "b"}') | {"a": "b"} |
Getting entity names by message_id
These functions allow you to get human-readable entity names by message identifier. Useful for logging, report generation, and conditional branching in pipelines. If the entity is not found, the function returns an error.
| Function | Description | Example | message_id | unique_message_id |
|---|---|---|---|---|
$getCampaignName | Campaign name | $getCampaignName($in.unique_message_id) | Yes | Yes |
$getTemplateName | Template name | $getTemplateName($in.send_message_id) | Yes | — |
$getDatabaseName | Database name | $getDatabaseName($in.unique_message_id) | Yes | Yes |
$getSegmentName | Segment name. If segment is not set — No segment | $getSegmentName($in.send_message_id) | Yes | — |
$getWorkflowName | Scenario name. If scenario is not set — No workflow | $getWorkflowName($in.send_message_id) | Yes | — |
$getResourceName | Resource name. If resource is not set — No resource | $getResourceName($in.unique_message_id) | Yes | Yes |
Getting entity IDs by message_id
| Function | Description | Example | message_id | unique_message_id |
|---|---|---|---|---|
$getCampaignID | Campaign identifier (string) | $getCampaignID($in.unique_message_id) | Yes | Yes |
$getTemplateID | Template identifier (string) | $getTemplateID($in.send_message_id) | Yes | — |
$getDatabaseID | Database identifier (string) | $getDatabaseID($in.unique_message_id) | Yes | Yes |
$getSegmentID | Segment identifier (string) | $getSegmentID($in.send_message_id) | Yes | — |
$getWorkflowID | Scenario identifier (string) | $getWorkflowID($in.send_message_id) | Yes | — |
$getResourceID | Resource identifier (string) | $getResourceID($in.unique_message_id) | Yes | Yes |
Getting attribute value
The function $getAttributeValue returns the value of a custom attribute (custom field) by its identifier. Attributes are set at the mailing, workflow, or campaign level and are inherited hierarchically: the mailing value has the highest priority, then the workflow, then the campaign.
| Function | Description | Example |
|---|---|---|
$getAttributeValue | Returns the attribute value (string). First argument — message_id, second — attribute identifier (string) | $getAttributeValue($in.send_message_id, "attribute_1") |
If the attribute is not found at any level of the hierarchy, the function returns an empty string.
Examples
All prefixes
Input data of the pipe:
{
"attribute as string": "$sender.id",
"attribute as original type": "$#sender.id",
"attribute as part of string": "test $sender.name",
"$$template.field_files_template[array]": {
"content": "[$]content",
"filename": "[$]name",
"type": "[$]mime",
"size": "[$]size",
"constant": 1,
"sender_id": "$sender.id"
}
}
Result after template processing:
{
"attribute as string": "145",
"attribute as original type": 145,
"attribute as part of string": "test interstellar sender",
"array": [
{
"content": "base64string",
"filename": "file1.txt",
"type": "text/plain; charset=utf-8",
"size": "10",
"constant": 1,
"sender_id": "145"
},
{
"content": "base64string",
"filename": "file2.txt",
"type": "text/plain; charset=utf-8",
"size": "100",
"constant": 1,
"sender_id": "145"
}
]
}
Template in URL
The params.url parameter of the HTTP Request pipe:
https://example.com/handler/v${sender.version}/test
After processing (when sender.version = 2):
https://example.com/handler/v2/test
Concatenation and types
The params.template.test_field parameter of the Pack pipe:
qwerty$in.a_id
Result (when in.a_id = 5):
qwerty5
The same notation with the $# prefix will cause an error, because a string and a number cannot be "concatenated":
qwerty$#in.a_id // error