Entities

Teneo comes with a collection of pre-built Entities that you may use in your flows. However, sometimes we need to create custom entities for our bot. This is the case for the different kinds of coffee types that are served at Longberry Baristas. In the following section we will walk you through the creation of this custom entity.

Create an 'Entity' folder

Before we create our entities, it might be a good idea to create a folder that we can use to store them. This is not required, but as a solution grows, folders help to structure your Teneo assets. To create the folder, proceed as follows:

  1. Make sure none of the folders on the left are selected, by clicking in the white area below the folders in the 'Explore' section.
  2. Click the 'Folder' icon in the 'New' group in the ribbon.
  3. Give your folder a name, for example Language Objects and hit Enter.

Create a 'Coffees served' entity

Let's create the entity for recognizing the different kinds of coffees that are served at Longberry baristas. In Teneo, an entity can either contain words, phrases or language objects. Generally speaking, language objects are usually lists of synonyms or thematically related words, which are used to recognize the wide variety of user inputs. This means that language objects ensures a broader coverage with respect to plural forms, declinations, and synonyms of the words compared to just using words or phrases. In other words, we do not have to specify every form or synonym of a word to get great coverage. For example, the language object '%AMERICANO.NN.LEX' will not only recognize "Americano", but also the plural form "Americanos".

The entity that we are creating in this section will contain both language objects and words like brewed coffee (singular) and brewed coffees (plural). Since no language object covers the different forms of ‘brewed coffee’ we have to specify them ourselves in the entity. It would be a good idea to create a language object that covers both singular and plural forms of ‘brewed coffee’, and then use that language object as an entry in the entity instead. However, we will skip this step for now...

This is how we go about it:

  1. In your main solution window, select the 'Language Objects' folder and click 'Entity' in the 'New' section of the Ribbon. This will create a new entity in the selected folder.
  2. Call the entity COFFEES_SERVED (the type .ENTITY is automatically defined).
  3. Use the left arrow on the top to get to the HOME tab of the entity.
  4. Copy the following table onto the clipboard:

    Coffee name coffeeType
    %AMERICANO.NN.LEX americano
    %CAPPUCCINO.NN.LEX cappuccino
    %CORTADO.NN.LEX cortado
    %ESPRESSO.NN.LEX espresso
    %FRAPPUCCINO.NN.LEX frappuccino
    %LATTE.NN.LEX latte
    %LUNGO.NN.LEX lungo
    %MACCHIATO.NN.LEX macchiato
    %RISTRETTO.NN.LEX ristretto
    flat white flat white
    flat whites flat white
    brewed coffee brewed coffee
    brewed coffees brewed coffee
    filtered coffee brewed coffee
    filtered coffees brewed coffee

    Note that filter coffee and brewed coffee are considered synonyms and both should return the type 'brewed coffee'.

  5. In the Home window of the Entity mark the field Click here to add a new entry.
  6. While the Entity field is marked, use Ctrl+V to paste the table into the Entity.
  7. You will now be asked whether the first row of the table you are about to paste contains variable names or belongs to the data. Select 'First row is variable names'
  8. Hit 'Save' and close the entity window.

As you can see the entity structure is similar to a spreadsheet as it contain columns and rows. The left column contain entry values like language objects and words. In the right column, we have the variable 'coffeeType' which contains the string value of the entry on the corresponding row. For example, if we recognize 'americano' the variable 'coffeeType' would get the value "americano". You will learn more about how to extract data from user input on the next page.

The language objects used in the entity above are of the type lexical entries, which are the smallest building blocks from which more complex language objects can be built. All language objects have a suffix that denotes which type it is. On this page, we have worked with lexical entries which have the suffix ‘.LEX’. Language objects of the type lexical entries usually contain different inflections, regional variations, and spelling of a word.

Summary

Great job! You have just created your first custom entity and worked with these components:

  • Folder: Helps you keep your solution organized,
  • Entity: A way of structuring data and mapping entry values to variables that can be used for data extraction,
  • Language objects: Used to get a broader coverage for plural forms, declinations, and synonyms of words so the bot can recognize a wide variety of user input.

Test yourself

Now that we have added a entity that stores coffee types. Lets proceed with adding one more entity but this time for the following coffee sizes:

Coffee size coffeeSize
small small
medium medium
regular medium
large large
big large
supersize large
venti large

What's next?

We have finally created an entity that stores different coffee types. Now its time to use this entity inside the flow and extract the values

Was this page helpful?