akenza.io
Search…
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 and 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:
1
{
2
"data": {
3
"time": "2021-03-02T11:37:00+000",
4
"temp": 23.5,
5
...
6
},
7
...
8
Copied!
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 of 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 strucutre.
Consider the following structure of the sample:
1
{
2
"data": {
3
"time": "2021-03-02T11:37:00+000",
4
"temp": 23.5,
5
"state": "all ok",
6
...
7
},
8
...
Copied!
If the output to the webhook connector should look something like
1
{
2
"temp": 23.5,
3
"time": "2021-03-21T11:37:00+000",
4
"state": "all ok",
5
...
6
}
Copied!
The following template will achieve this:
1
{
2
"temp": {{data.temp}},
3
"time": {{data.time}},
4
"state": {{data.state}},
5
...
6
}
Copied!
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
  • uplinkMeta the complete uplink meta object. See Uplink Meta Properties for sub properties
  • topic the data topic
  • timestamp the timestamp of the sample
  • deviceId the unique device id of the device triggering the flow
  • akenzaDeviceId the akenza device id of the device triggering the flow
  • correlationId the correlation id of the flow
  • device the complete device object. See Device Properties for sub properties
  • rule the complete rule object. See Rule Properties for sub properties
  • dataSources 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 name
  • description the device description
  • integrationId the integrationId of the device (only for LoRaWAN devices)
  • workspaceId the workspaceId of the device
  • dataFlowId the data flow id of the device
  • connectivity the connectivity of the device
  • id the akenza device id
  • deviceId the unique device id

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 rule
  • name the name of the rule (only for rules)
  • description the description of the rule
  • workspaceId the workspaceId 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 properties
  • deviceId the unique device id
  • akenzaDeviceId the akenza device id
  • topic the topic of the sample
  • timestamp the timestamp of the sample
  • data.* access any values of the sample
  • meta.* access any values of the meta object
  • uplinkMeta the complete uplink meta object
The following properties of uplink meta data 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 recieved
  • bytesReceived the number of bytes received in the uplink request
  • processingStart the ISO-8601 timestamp when the processing was started
  • scriptRunUplinkStart the ISO-8601 timestamp when script run was started
  • scriptRunUplinkEnd the ISO-8601 timestamp when script run ended
  • processingEnd the ISO-8601 timestamp when the processing ended
  • outputProduced the ISO-8601 timestamp when all output were produced
  • uplinkDuration the ISO-8601 duration of the whole uplink flow
  • processingDuration the IOS-8601 duration of the processing
  • scriptRunningDuration the ISO-8601 duration of the script run
Last modified 10d ago