Teneo Developers

Counting coffees with Metadata

One use case for Metadata is to annotate data that helps measure the solution value in business terms. For example, in a coffee shop, the owner can track the solution value by looking at the number of coffees sold, as that is a clear number which indicates the revenue for the owner. On this page, we will add a Metadata tag inside our solution and later use Teneo Query Language to extract the corresponding information.

To do this, we will go ahead and edit our Order a coffee flow, adding Metadata inside the Output nodes.

metadata-3

Create a Metadata tag

The first step is to create a new Metadata tag that can be placed inside the flow to track the number of sold coffees.

  1. While inside the solution, select the 'SOLUTION' button located in the top left corner. This will take you to the solution backstage.
  2. Navigate to the 'Globals' section and click on 'Metadata'.
  3. To create a new 'Metadata', click on the 'Add' button.
  4. Select 'Flow' and name it something suitable, like CoffeeOrdered.
  5. Select the value type 'Boolean', leave Auto-Logging selected, and leave the value set to 'False'.
  6. Save and to return to the main solution window.

Edit the flow

It is now time to place a Metadata tag inside the User wants to order coffee flow.

  1. Open up the 'User wants to order coffee' flow in edit mode.
  2. Navigate to the last output node 'Summarize order'.
  3. In the output configuration panel, go to 'Metadata' and click on the 'Add' button.
  4. Open up the drop-down menu and select 'CoffeeOrdered'. Change the value to 'True' to mark that a cup of coffee was sold.
  5. Save the flow.

Publish the solution

Before the new version of the solution can start collecting Metadata information, and in order to make the recent changes active, it is important to publish the solution again.

  1. Open the 'SOLUTION' tab in the solution's window.
  2. Select 'Publish'.
  3. Click the 'Manage' button and in the drop-down. You will see a lot of different alternatives; locate the 'Latest' section and choose 'Publish'.

Metadata is logged once your bot has been published and end users start having conversations with it. To see the full potential of what metadata can do for your project, make sure that the bot is published and in use for long enough to gather interesting conversation logs.

Retrieve the number of sold coffees

For this step, it is important that the solution has been published for a while and people have talked to it, as we are going to use Teneo Query Language to extract the number of coffees sold by our bot.

  1. Open the 'SOLUTION' tab in the solution's window.
  2. Select 'Optimization'.
  3. Navigate to 'Log Data' and open up your source by clicking on the 'Manage' button followed by 'Open'.

A new window should now open. This is the Log Data window, described here. The next step is to use Teneo Query Language to create a query where we can display the number of sold coffees.

  1. In the query tab, paste in the following query ca t.e.md:CoffeeType as 'Coffees sold' : t.e.md:CoffeeOrdered == true. This should display the number of sold coffees.

The result should look like this,
Metadata - Larger

Please see TQL Cookbook for more template queries.

Test yourself

Go ahead and test yourself by adding a similiar Metadata tag, this time to store the number of reserved coffee mugs in User wants to buy a coffee mug. If you are up for an extra challenge, you can also go ahead and store the ordered coffee type in a Metadata tag. This time, you will need to have a string Metadata tag.