Payload Templating
This page describes the template syntax used by akenza in more detail
Payload templating allows the customization of the payload of output connectors, rule actions, and access data of the uplink as well as other metadata by making use of a templating language.
The templating language can be used to add properties of the sample to the e-mail action body and subject.
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:
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:
If the output to the webhook connector should look something like
The following template will achieve this:
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 samplemeta.*
access any values of the meta objectresult.*
access any values of the custom rule logic resultuplinkMeta
the complete uplink meta-object. See Uplink Meta Properties for sub-propertiestopic
the data topictimestamp
the timestamp of the sampledeviceId
the unique device id of the device triggering the flowakenzaDeviceId
the akenza device id of the device triggering the flowcorrelationId
the correlation id of the flowdevice
the complete device object. See Device Properties for sub-propertiesrule
the complete rule object. See Rule Properties for sub-propertiesuplinkMetrics
the complete uplink metrics object. See uplink metrics Properties for sub-propertiesrawData
the complete raw data object. See raw data Properties for sub-properties. Only available for LoRa uplinksdataSources
all 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.
name
the device namedescription
the device descriptionintegrationId
the integration Id of the device (only for LoRaWAN devices)workspaceId
the workspace Id of the devicedataFlowId
the data flow Id of the deviceconnectivity
the connectivity of the deviceid
the akenza device IddeviceId
the unique device idcustomFields.*
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.
ruleId
the id fo the rulename
the name of the rule (only for rules)description
the description of the ruleworkspaceId
the 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.
correlationId
the correlation id of the data source (only available if the data source was triggering the flow)device
the complete device object. See Device Properties for sub-propertiesdeviceId
the unique device idakenzaDeviceId
the akenza device idtopic
the topic of the sampletimestamp
the timestamp of the sampledata.*
access any values of the samplemeta.*
access any values of the meta objectuplinkMeta
the complete uplink meta objecttrigger
boolean indicates whether the data source has triggered the uplinkdeviceInput
boolean indicates if the data source is a devicetagInput
boolean 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.
dataReceived
the ISO-8601 timestamp when the data was receivedbytesReceived
the number of bytes received in the uplink requestprocessingStart
the ISO-8601 timestamp when the processing was startedscriptRunUplinkStart
the ISO-8601 timestamp when script run was startedscriptRunUplinkEnd
the ISO-8601 timestamp when script run endedprocessingEnd
the ISO-8601 timestamp when the processing endedoutputProduced
the ISO-8601 timestamp when all output was produceduplinkDuration
the ISO-8601 duration of the whole uplink flowprocessingDuration
the IOS-8601 duration of the processingscriptRunningDuration
the 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.
uplinkSize
the size of the uplinktimestamp
the ISO-8601 timestamp when the data was receivedlatitude
the latitude of the devicelongitude
the latitude of the devicelocationRadius
the error radius for the locationport
the port used when sending the uplinkframeCountUp
the frame count up of the uplinkframeCountDown
the frame count down of the uplinkrssi
the rssi of the uplinksnr
the snr of the uplinksf
the spreading factor used to send the uplinktxPower
the tx power used to send the uplinknumberOfGateways
the number of gateways that received the uplinkesp
the esp of the uplinksqi
the signal quality of the uplinkbatteryLevel
the 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.
port
the port of the unprocessed uplinkpayloadHex
the hex payload of the unprocessed uplink
Last updated