Extract values with Augmenters

Teneo Inquire stores and retrieves highly detailed transactional records from running conversational AI applications. Augmenters are used to extend the default log data by enriching or summarizing it in a format that can be accessed by standard queries. These have the benefit of both simplifying the subsequent querying and increasing performance. One use-case is to mark key flows of the solution, making it easier to get statistics on how many of these are completed or aborted.

In this page we will learn how to create the two types of augmenters, and how key flows can be annotated and counted:

  • Adorners
  • Aggregators

Prerequisites

Before you can use the dashboard you need to have the following:

A published solution with data

Conversations that you have with your bot in Try Out are not stored in your bot's data repository. Before you can use augmenters, it is recommended that your solution is published and data is generated by interacting with your bot online. Also make sure that your environment is running by either logging into Teneo Studio or the console.

Teneo Inquire URL

The Teneo Inquire URL looks like this:

https://[your team name].data.teneo.ai/teneo-inquire/frontend/#/importer

You should replace [your team name] with the name of your team. You can find it in the top right corner when you log in to your environment in the browser.

Access Log Data Manager

The first step is to access the Log Data Manager where we can create our augmenters.

  1. Visit your Teneo Inquire by using the link shown above.
  2. Once inside the website, log in using the same credentials used in Teneo Studio.

At this point you should have this screen in front of you:

log-data-source

Create an Adorner

Augmenters can be created with several different purposes. For this example, we will create an adorner for the Longberry Barista solution to extract when the key flows in the solution has been raised and dropped, and when a completion point was reached.

  1. Start by locating the 'Augmenters' section.
  2. You will now see a 'Log Data Source' navigating to 'None'. Click on it and select the relevant solution; in our case, this is the longberry_baristas_XXX solution.

Once a 'Log Data Source' has been selected, two new panels will show up: Adorners and Aggregators. The difference between these is explained here.

  1. Go ahead and select 'Add' followed up with 'Groovy script Adorner' under the 'Adorner' section. There is also an option to create Teneo Query Language based Adorners. This is not relevant for our case.
  2. Give the adorner a name, like Issue adorner.

Now it is time to add a Groovy script to access the valuable information located inside our solution.

  1. Copy the following code and paste it under 'Groovy script'

    def issuesStarted = [:]
    def issuesCompleted = [] as HashSet
    def issuesAborted = [] as HashSet
    
    // List of flow ids that represent relevant flows
    def flowIdsToTrack = ["INSERT_FIRST_FLOW_ID", "INSERT_SECOND_FLOW_ID"] as HashSet
    // List of vertex ids that represent when above flow should be considered completed
    def endFlowVertexIds = ["INSERT_FIRST_FLOW_VERTEX_ID", "INSERT_SECOND_FLOW_VERTEX_ID"] as HashSet
    
    session.transactions.each { t ->
        t.events.each { e ->
            def flowInstanceId = e.getValue('flow-instance-id')
            def flowId = e.getValue('fid')
            def pathType = e.getValue('pathType')
            def flowName = e.getValue('fname')
    
            if (pathType == "raise-flow" && flowId in flowIdsToTrack) {
                issuesStarted[flowInstanceId] = flowName
                callback.adornTransaction(t.id, 't.a.s:issueStarted', flowName)
            } else if (pathType == "drop-flow" && flowId in flowIdsToTrack) {
                if (e.getValue('vid') in endFlowVertexIds) {
                    issuesCompleted.add(flowInstanceId)
                    callback.adornTransaction(t.id, 't.a.s:issueCompleted', flowName)
                } else {
                    callback.adornTransaction(t.id, 't.a.s:issueAborted', flowName)
                    issuesAborted.add(flowInstanceId)
                }
            }
        }
    }
    
    issuesStarted.entrySet().each { entry ->
        def flowInstanceId = entry.key
        def flowName = entry.value
    
        if (issuesCompleted.contains(flowInstanceId)) {
            // Issue was completed
            callback.adornSession(session.id, 's.a.s:issueCompleted', flowName)
        } else {
            // Issue was aborted
            callback.adornSession(session.id, 's.a.s:issueAborted', flowName)
    
            // If the session ended before the flow was drop, we mark the last transactions as the aborting point
            if(!issuesAborted.contains(flowInstanceId)) {
                callback.adornTransaction(session.transactions.last(), 't.a.s:issueAborted', flowName)
            }
        }
    }

Replace the flow ID

Now we need to replace the ID from the Groovy script above that is located in line 6. This is the placeholder for a flow ID. In this example, we will use the Longberry Baristas solution and locate the business-critical flows to track. Let us go through the steps to achieve this:

  1. Open up your 'Longberry Baristas' solution that's included in your Teneo free trial, and open up the 'User wants to order a coffee' flow.
  2. While inside the flow, click on the 'Flow' button located in the top left corner to open up the flow backstage window.
  3. Located at the bottom of the 'Properties' section is the ID. Copy it and replace INSERT_FIRST_FLOW_ID in line 6 with the ID you just copied.
  4. Close the solution and open up the 'User wants to buy a coffee mug' and do the same thing, but this time replace INSERT_SECOND_FLOW_ID in line 6 with the ID you find there.

The 'Properties' tab and flow ID can be found here:
1-flow_id

Replace the vertex ID

Now that we have replaced the flow IDs from line 6, it is time to replace the following IDs in line 8. This time we will need to access the node at the end of the flow to ensure a full happy path was taken without any interruptions. In order to achieve that, we need to do the following:

  1. Open up the 'User wants to order a coffee' flow.
  2. Locate down to the last output node named 'Summarize order' and right click followed up with 'Copy ID to clipboard'.
  3. Now it is time to replace the INSERT_FIRST_FLOW_VERTEX_ID with the ID you just copied.
  4. Do the same thing with 'User wants to buy a coffee mug' flow and replace the INSERT_SECOND_FLOW_VERTEX_ID with the vertex ID from 'I have reserved a coffee mug for you'.

Adornment Keys

We are in the last step of creating a working adorner. The last step is to create your own Adornment Keys to use as a shortcut when working inside your solution to retrieve information.

  1. Paste in the following line s.a.s:issueCompleted, s.a.s:issueAborted, t.a.s:issueStarted, t.a.s:issueCompleted, t.a.s:issueAborted
  2. Click on the 'Preview' button to try out your adorner. This will test your adorner and warn you if there are any issues.

    If issues are found, please repeat the steps taken above.

  3. Finally, go ahead and save your adorner.

Congratulations, you have now created your first adorner! Now, it is time to use this adorner and retrieve information in Inquire using Teneo Query Language.

Retrieve information from the logs

It is finally time to go back to our 'Longberry Baristas' solution and use the newly created adorner to retrieve som valuable information. In this specific section, we are intrested to know when the business critical flows are triggered and finished with a happy path, without any interruptions.

  1. Open up your solution 'Longberry Barista' that comes together with a free trial.
  2. While inside the solution, select the 'SOLUTION' button located in the top left corner. This will take you to the solution backstage.
  3. Select 'Optimization', followed by 'Log Data'.
  4. Expand the 'Manage' button and open up the relevant 'Log Data Source'.

A brand new window will open up where the user is able to use Teneo Query Language in order to run queries and analyze the solution. We will now go ahead and see how often our business-critical flows were used thanks to the adorner we built.

  1. Paste in the following query: la s.beginTime, s.a.s:issueCompleted. This lists all of the times one of the two flows we chose were triggered.

2-query

If we are interested in more specific data we can access when a business-critical flow was interrupted by a different flow together with the input that caused the business-critical flow to be interrupted.

  1. Paste in the following query: la s.id as 'Session ID', t.time as 'Time', t.a.s:issueAborted as 'Aborted issue', t.e2.fname as 'Flow', t.e1.userInput as 'User input' : t.e2.pathType == "raise-flow", t.e1.type == "request"

To be able to retrieve information as per the steps above, don't forget to ensure the solution is published, data has been generated as a result of the bot being interacted with, and the Teneo server has been started (you can make sure it has been started by lodding into Teneo Studio).

Was this page helpful?