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:
- In the folder view, click on the Plus icon to create a new document.
- Several other icons will appear. Click on the folder icon.
- 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:
-
Open the newly created 'Language Objects' folder.
-
Click on the Plus icon, followed by Entity icon (when you hover over it, you should see the text 'Create new Entity'.
-
Call the entity
COFFEES_SERVED
(the type .ENTITY is automatically defined). -
Click on 'Create'. The newly created Entity should open automatically.
-
Inside the Entity, click on 'Add string variable'.
-
Name the string variable
coffeeType
. -
Next, select the option to Add entry.
-
Add the following entries into the Entity window:
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
-
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.
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.
- 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.
- 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:
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.