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 samplemeta.*access any values of the meta objectresult.*access any values of the custom rule logic resultuplinkMetathe complete uplink meta-object. See Uplink Meta Properties for sub-propertiestopicthe data topictimestampthe timestamp of the sampledeviceIdthe unique device id of the device triggering the flowakenzaDeviceIdthe akenza device id of the device triggering the flowcorrelationIdthe correlation id of the flowdevicethe complete device object. See Device Properties for sub-propertiesrulethe complete rule object. See Rule Properties for sub-propertiesuplinkMetricsthe complete uplink metrics object. See uplink metrics Properties for sub-propertiesrawDatathe complete raw data object. See raw data Properties for sub-properties. Only available for LoRa uplinksdataSourcesall 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 namedescriptionthe device descriptionintegrationIdthe integration Id of the device (only for LoRaWAN devices)workspaceIdthe workspace Id of the devicedataFlowIdthe data flow Id of the deviceconnectivitythe connectivity of the deviceidthe akenza device IddeviceIdthe 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.
ruleIdthe id fo the rulenamethe name of the rule (only for rules)descriptionthe description of the ruleworkspaceIdthe 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-propertiesdeviceIdthe unique device idakenzaDeviceIdthe akenza device idtopicthe topic of the sampletimestampthe timestamp of the sampledata.*access any values of the samplemeta.*access any values of the meta objectuplinkMetathe complete uplink meta objecttriggerboolean indicates whether the data source has triggered the uplinkdeviceInputboolean indicates if the data source is a devicetagInputboolean 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 receivedbytesReceivedthe number of bytes received in the uplink requestprocessingStartthe ISO-8601 timestamp when the processing was startedscriptRunUplinkStartthe ISO-8601 timestamp when script run was startedscriptRunUplinkEndthe ISO-8601 timestamp when script run endedprocessingEndthe ISO-8601 timestamp when the processing endedoutputProducedthe ISO-8601 timestamp when all output was produceduplinkDurationthe ISO-8601 duration of the whole uplink flowprocessingDurationthe IOS-8601 duration of the processingscriptRunningDurationthe 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 uplinktimestampthe ISO-8601 timestamp when the data was receivedlatitudethe latitude of the devicelongitudethe latitude of the devicelocationRadiusthe error radius for the locationportthe port used when sending the uplinkframeCountUpthe frame count up of the uplinkframeCountDownthe frame count down of the uplinkrssithe rssi of the uplinksnrthe snr of the uplinksfthe spreading factor used to send the uplinktxPowerthe tx power used to send the uplinknumberOfGatewaysthe number of gateways that received the uplinkespthe esp of the uplinksqithe signal quality of the uplinkbatteryLevelthe 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 uplinkpayloadHexthe hex payload of the unprocessed uplink
Last updated
Was this helpful?