Teneo Developers
Table of Contents
Was this page helpful?

Share to

Transformer

We are often interested in viewing data over time in order to identify trends; we want to be able to see how our bot's conversations develop over time. Transformers are a group of TQL functions that make it easier to query dates and trends. They perform background computations that deliver new data values that you can display or query. Transformers appear as part of a query's constraint, and the transformed values can be used as part of the selection. There are two types of transformers used by TQL:

  • Date transformers
  • Trend transformers

Our focus here is on date transformers. For information about trends, check the TQL Reference Guide and the TQL Cookbook.

Date transformers

Date transformers allow you to organize events by different periods of time. They use the TQL function catd which allows you to specify one or both of the following:

  • a model, specifying the level of granularity for the query. Possible values are:
    • date
    • day-of-week
    • month
    • quarter
  • a pattern, specifying which date or time format to use (based on Java specifications for date format strings): Some examples:
    • yyyy-MM-dd
    • kk
    • yyyy-'w'ww
    • ...

Optional parameters allow you to specify a time zone or Java Locale. Please refer to the manual for more detail.

Let's look at a sample query that shows the number of conversations per day that occurred during business hours. Notice that you can format and also comment your queries to make them easier to read.

tql

1d date: 
2  catd(model="date") s.beginTime as date,	// tells TQL to organize the results by unique dates
3  catd(pattern="HH") s.beginTime as hour,	// tells TQL to make hour available in the query
4  hour == in {"09".."18"}					// constraint to only show sessions during these hours
5  order by date
6

Here you can see the results sorted by date. The first column shows the date. The second shows the number of sessions during business hours. This information could also be fed into a dashboard, where it could be converted into a graph.

TQL - Date Transformer