Payload Templating
This page describes the template syntax used by akenza in more detail
Usage
To trigger the suggestions in the UI, simply enter double open curly brackets ({{) in the input field which will show available options. Make sure to end the expression by adding double closing curly brackets (}}).
Enclosed in the curly brackets, the access to any data sample or other properties is done using the dot-notation.
Consider the following structure:
{
    "data": {
        "time": "2021-03-02T11:37:00+000",
        "temp": 23.5,
        ...
    },
    ...
}If e.g. the temperature value of the sample is to be added in the email body, the access to this value is as follows: {{data.temp}}.   
JSON Payload Templating
If the target e.g. a Webhook requires a different JSON object structure, the custom payload can be used in combination with the templating syntax to achieve a completely new JSON structure.
Consider the following structure of the sample:
{
    "data": {
        "time": "2021-03-02T11:37:00+000",
        "temp": 23.5,
        "state": "all ok",
        ...
    },
    ...
}If the output to the webhook connector should look something like
{
    "temp": 23.5,
    "time": "2021-03-21T11:37:00+000",
    "state": "all ok",
    ...
}The following template will achieve this:
{
    "temp": {{data.temp}},
    "time": {{data.time}},
    "state": {{data.state}},
    ...
}NOTE: Previously all the templating expressions in JSON were enclosed in quotes in order to be a valid JSON object. This is no longer necessary since the templating engine will replace and encode/escape the value according to type.
Supported Properties
The following properties are supported:
- data.*access any values of the sample
- meta.*access any values of the meta object
- result.*access any values of the custom rule logic result
- uplinkMetathe complete uplink meta-object. See Uplink Meta Properties for sub-properties
- topicthe data topic
- timestampthe timestamp of the sample
- deviceIdthe unique device id of the device triggering the flow
- akenzaDeviceIdthe akenza device id of the device triggering the flow
- correlationIdthe correlation id of the flow
- devicethe complete device object. See Device Properties for sub-properties
- rulethe complete rule object. See Rule Properties for sub-properties
- uplinkMetricsthe complete uplink metrics object. See uplink metrics Properties for sub-properties
- rawDatathe complete raw data object. See raw data Properties for sub-properties. Only available for LoRa uplinks
- dataSourcesall data source objects involved in the triggered flow. See Data Source Properties for sub-properties
Device Properties
The following properties of a device can be accessed when using template syntax.
Note: The prefix device. is always required in order to access sub-properties.
- namethe device name
- descriptionthe device description
- integrationIdthe integration Id of the device (only for LoRaWAN devices)
- workspaceIdthe workspace Id of the device
- dataFlowIdthe data flow Id of the device
- connectivitythe connectivity of the device
- idthe akenza device Id
- deviceIdthe unique device id
- customFields.*access Custom Fields values by their name
Rule Properties
The following properties of a rule can be accessed when using template syntax.
Note: The prefix rule. is always required in order to access sub-properties.
- ruleIdthe id fo the rule
- namethe name of the rule (only for rules)
- descriptionthe description of the rule
- workspaceIdthe workspace Id of the rule
Data Source Properties
The following properties of a data source can be accessed when using template syntax.
To access a specific data source, use dataSources.X where X is the number of the data source as specified in the rule (starting at 1).
Some properties can be null in certain circumstances (e.g. the correlationId or the device) if e.g. the rule was triggered by a timer event or the data source is set to access the last sample.
Note: The prefix dataSources.X. is always required in order to access sub-properties.
- correlationIdthe correlation id of the data source (only available if the data source was triggering the flow)
- devicethe complete device object. See Device Properties for sub-properties
- deviceIdthe unique device id
- akenzaDeviceIdthe akenza device id
- topicthe topic of the sample
- timestampthe timestamp of the sample
- data.*access any values of the sample
- meta.*access any values of the meta object
- uplinkMetathe complete uplink meta object
- triggerboolean indicates whether the data source has triggered the uplink
- deviceInputboolean indicates if the data source is a device
- tagInputboolean indicates if the data source is a tag
Uplink Meta Properties
The following properties of uplink metadata can be accessed when using template syntax
Note: The prefix uplinkMeta. is always required in order to access sub-properties.
- dataReceivedthe ISO-8601 timestamp when the data was received
- bytesReceivedthe number of bytes received in the uplink request
- processingStartthe ISO-8601 timestamp when the processing was started
- scriptRunUplinkStartthe ISO-8601 timestamp when script run was started
- scriptRunUplinkEndthe ISO-8601 timestamp when script run ended
- processingEndthe ISO-8601 timestamp when the processing ended
- outputProducedthe ISO-8601 timestamp when all output was produced
- uplinkDurationthe ISO-8601 duration of the whole uplink flow
- processingDurationthe IOS-8601 duration of the processing
- scriptRunningDurationthe ISO-8601 duration of the script run
Uplink Metrics Properties
The following properties of uplink metrics can be accessed when using template syntax
Note: The prefix uplinkMetrics. is always required in order to access sub-properties.
- uplinkSizethe size of the uplink
- timestampthe ISO-8601 timestamp when the data was received
- latitudethe latitude of the device
- longitudethe latitude of the device
- locationRadiusthe error radius for the location
- portthe port used when sending the uplink
- frameCountUpthe frame count up of the uplink
- frameCountDownthe frame count down of the uplink
- rssithe rssi of the uplink
- snrthe snr of the uplink
- sfthe spreading factor used to send the uplink
- txPowerthe tx power used to send the uplink
- numberOfGatewaysthe number of gateways that received the uplink
- espthe esp of the uplink
- sqithe signal quality of the uplink
- batteryLevelthe battery level of the device
Raw Data Properties
The following properties of raw data can be accessed when using template syntax
Note: The prefix rawData. is always required in order to access sub-properties.
- portthe port of the unprocessed uplink
- payloadHexthe hex payload of the unprocessed uplink
Last updated
Was this helpful?