Periodic usage counting queries

Periodic usage counting queries are very basic and commonly used queries in almost all kinds of projects built by Teneo Studio. Many of our clients are using these queries to evaluate the performance of the Chatbot. The most outstanding characteristic of these queries is, instead of having a specific time constraint like s.beginTime == "2021-11" in the query, they can retrieve the number of the previous month/week/day from the moment when they are executed. The advantage of these queries is that the chatbot developer does not need to change the content of the query, but just run it periodically to get the most recent data from the Log Data Source. The following example shows a query that counts the number of dialogs in the last month:

ca s.beginTime == in {"now-1M/M"}

This query counts the number of dialogs in the previous month from the moment this query is executed. Please be aware that the month in this query refers to a calendar month. For example, if you run this query within the November 2021, you will get the number of dialogues from 1st October 2021 until 31st October 2021:

If you want to change the period from month to week, you can use this constraint:

s.beginTime == in {"now-1w/w"}

Here the week means a calendar week starting from Monday to Sunday. In some rare cases, you might need previous year (use {"now-1y/y"} ) or previous day (use {"now-1d/d"} ). Please be aware that the time expression in the query is case sensitive. You should only use upper case when you are referring to month because the lower case m represents minute. Click here for more relative time references.

You can use similar query for counting the number of transactions in the last month, such as:

ca s.beginTime == in {"now-1M/M"}

You can also query the number in the month before last month, for example:

ca s.beginTime == in {"now-2M/M"}

Sometimes you may need more constraints to these queries. The most common additional constraint for this query is s.transactionCount > 1, which means the dialog that is counted should have at least two transactions. This constraint is very useful because when the Chatbot is open, it usually generates automatically the first transaction with no user input and the greeting message as output. Therefore, in most of the cases if the dialog only contains one transaction, it means that the user has closed the chatbot just after opening it, without giving any user inputs. Here is an example of counting the number of dialogs which have at least one user input:

ca s.transactionCount > 1, s.beginTime == in {"now-1M/M"}

You can see that it returns less results that the query without s.transactionCount > 1 constraint because sessions with only one transaction have been filtered out.

Furthermore, if you need the daily dialog count in the previous month, you can use distribute instead of count all in the query. Here is an example:

d date: catd(model="date") s.beginTime as date, s.beginTime == in{"now-1M/M"} order by date asc

The results look like this:

Click here for more queries using relative dates. You can also find more commonly used queries in our TQL Cookbook. If you need a training for Teneo Inquire, please contact us.

We hope you found this article useful, and feel free to ask here any questions you might have on the Teneo Inquire!

1 Like