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.
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.
- While inside the solution, select the 'SOLUTION' button located in the top left corner. This will take you to the solution backstage.
- Navigate to the 'Globals' section and click on 'Metadata'.
- To create a new 'Metadata', click on the 'Add' button.
- Select 'Flow' and name it something suitable, like
CoffeeOrdered
. - Select the value type 'Boolean', leave Auto-Logging selected, and leave the value set to 'False'.
- 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.
- Open up the 'User wants to order coffee' flow in edit mode.
- Navigate to the last output node 'Summarize order'.
- In the output configuration panel, go to 'Metadata' and click on the 'Add' button.
- Open up the drop-down menu and select 'CoffeeOrdered'. Change the value to 'True' to mark that a cup of coffee was sold.
- 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.
- Open the 'SOLUTION' tab in the solution's window.
- Select 'Publish'.
- Click the 'Manage' button and in the drop-down. You will see a lot of different alternatives; locate the 'Latest' section and choose 'Publish'.
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.
- Open the 'SOLUTION' tab in the solution's window.
- Select 'Optimization'.
- 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.
- 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,
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.