This article describes the structure and purpose of templates used in advanced services (Indexes, Timeseries and Notifications) on the Trusted Twin platform. 

The purpose of this article is to provide system architects and developers with conceptual knowledge required to design solutions on the Trusted Twin platform. In order to consult developer resources, please navigate to the Trusted Twin docs website.

5 min read

Figure 1. Templates on the Trusted Twin platform.



On the Trusted Twin platform, templates are expressions (e.g., "{entry_value.serial}") used where the name or value needs to be dynamically built based on the current request execution context. They follow the Python str.format() convention (see Format String Syntax).

Figure 2.  Example of a template and a dynamically built name.

Use examples

Some examples of the use of templates:

  • determining the name of a measurement column in which the value of a given Entry in the Ledger has to be stored in a Timeseries table.
  • determining the values of properties which have to be stored in the Indexes table.

Template variables

Templates use contextual variables including:

  • resource or object names, UUID identifiers or descriptions (e.g., user, Twin),
  • entry names, values, or timestamps (i.e., Ledger),
  • user dictionary provided in the request (i.e., X-TrustedTwin custom header),
  • current time.

Developer resources
Variables available in templates

Services using templates

Templates are used in the following services:

  • Indexes service – for building values for properties.
  • Timeseries service – for building values for timestamp or dimensions and names for measurements (available in general configuration and in Ledger Entry configuration).
  • Notifications (subscribe/notify) service – for building topic names in order to publish information about changes.

Tips & tricks

  • Entry value or object description can store any JSON serializable object. Templates allow for advanced addressing (e.g., "entry_value.user_list[2]" or "entry_value.user_dict.name").
  • Templates used for building names and values differ on how they handle strings. 

Developer resources
Template types

  • Templates can be used in the Timeseries service to handle automatic measurement unpacking from a dictionary (i.e., "**"). 

Figure 3. “**” template example.

Developer resources
Create a Timeseries table

For more information about how to use the Trusted Twin platform in your application’s architecture or technology stack, please contact hello@trustedtwin.com or schedule a video consultation with us through Calendly.