A session is a complete log of a conversation a user had with your bot. At the simplest level, it's a record that reads like a script of the user questions that drive the conversation and the corresponding responses made by the bot. But there's more to a session than just that; a session collects every detail of what happened from the beginning to the end of the conversation, recording not only how the bot responded, but also how that response was arrived at. Each session is logged with a unique session ID to make it easy to find in the Log Data Source viewer.
A session is made up of the following:
- Session properties (id, beginTime, transactionCount and other information about the session)
- Global variables
- A collection of all the transactions
TQL by itself does not know where to find the session properties, so when writing a query you have to add a session prefix to put the reference into perspective. For example, to access the session's ID, you would write session.id or s.id for short. The transaction count would be written as s.transactionCount and so on. A query to show all the session IDs along with the transaction count would look like this:
listall s.id, s.transactionCount. You can find out more about the different TQL commands on the Command page in the Query Syntax section on the left.
Some properties often used in queries are:
|s.id||A unique identifier for a particular session|
|s.beginTime||A timestamp of when the session began|
|s.transactionCount||The number of transactions during the session, including the greeting|
Global variables are generally logged as part of the transaction in which they were changed. Exceptions to this are global variables that change during the End dialog script, which is not associated with an actual transaction. This is an easy way to set up queries for end values of important global variables. For example, let's say you counted the number of times a user input ran into the Safetynet. In an End dialog script, you save that variable to itself or to a new variable:
In the LDS viewer, the variable is listed as a global variable at the session level.
Now in TQL you can pull out sessions in which the Safetynet became active only once, or run a distribution to find sessions with higher usage of the Safetynet. Please refer to the TQL Syntax Overview for the exact syntax to use when querying variables.