Teneo Developers

Introduction to 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 a 'Language Objects' 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. In the folder view, click on the Plus icon to create a new document.
  2. Several other icons will appear. Click on the folder icon.
  3. Give your folder a name, such as Language Objects, and click on 'Create'.

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 ensure a broader coverage, including the 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 will go about it:

  1. Open the newly created 'Language Objects' folder.

  2. Click on the Plus icon, followed by Entity icon (when you hover over it, you should see the text 'Create new Entity'.

  3. Call the entity COFFEES_SERVED (the type .ENTITY is automatically defined).

  4. Click on 'Create'. The newly created Entity should open automatically.

  5. Inside the Entity, click on 'Add string variable'.

  6. Name the string variable coffeeType.

  7. Next, select the option to Add entry.

  8. Add the following entries into the Entity window:

    Coffee namecoffeeType
    %AMERICANO.NN.LEXamericano
    %CAPPUCCINO.NN.LEXcappuccino
    %CORTADO.NN.LEXcortado
    %ESPRESSO.NN.LEXespresso
    %FRAPPUCCINO.NN.LEXfrappuccino
    %LATTE.NN.LEXlatte
    %LUNGO.NN.LEXlungo
    %MACCHIATO.NN.LEXmacchiato
    %RISTRETTO.NN.LEXristretto
    flat whiteflat white
    flat whitesflat white
    brewed coffeebrewed coffee
    brewed coffeesbrewed coffee
    filtered coffeebrewed coffee
    filtered coffeesbrewed coffee

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

  9. Hit 'Save'.

As you can see the entity structure is similar to a spreadsheet as it contains columns and rows. The left column contains 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.

Generate Entity entries

Teneo's copilot features allow you to quickly generate more entries for entities. Let's try that now to expand the entity.

In order to enable copilot features, make sure to first define settings to use Generative AI.

  1. Click on 'Generate Entry'.

As we already have existing entries, let's generate more based on those. If you prefer, you could also generate entries based on a description which you would need to enter at this step.

  1. Select the number of entries you wish to generate and click on 'Generate'. Review the generated examples and click 'Apply' to add them to the list of existing entries.

Make sure to evaluate that the generated entries are aligned with the scope of your entity. If generating Language Objects, you may need to create the referenced Language Object for the entity entry to be valid.

You also need to populate the string variable column 'coffeeType'. Your entity should now look something like this:

finished entity

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 broader coverage for plural forms, declinations, and synonyms of words so the bot can recognize a wide variety of user input.