Adding Entities

Updated 2 hours ago by Karol Jastrzebowski

Entities

Entities represent a logical group of things (pizza toppings, days of a week, type of dogs, etc) that you want the bot to detect during a conversation. This can be an important task especially if you are trying to build some custom logic that relies on getting access to this type of data.

For example, when you order a pizza, you can pick your topping from a number of different types: mushrooms, pepperoni, cheese etc. all of them are part of a common set or common entity you can call Toppings. Entities are used in Hu:toma so you can instruct the bot to detect specific attributes from a conversation and pass those value to you at one point (this is done through an intent which will be explained later). In the case of pizza example, it means that at one point you will be able to know the type of pizza the user wants and can write some code that issues the actual order to a backend.

Custom Entities

Custom entities are entities you can build. Let's try, for example, to build a pizza Topping entity:

  1. Create a new bot as described in the Creating a bot section.
  2. Once you reached bot summary, you should see an entities menu on the left side of your console

  3. Click that link and you will see a form where to create your new entity. 
  4. Give your entity a topping name choose Values list as the type and add a few possible values like: Pepperoni, tomatoes, mushrooms, and onion

  5. Your entity is now completed. In the Intent section, we will explain how you can use it in your intents

Regular Expression Entities

As well as standard entities, which offer a list of values, you can also create entities based on a regular expression. This is useful in cases where the entity values fit a standard pattern, but where there might be an infeasibly large number of them. For example, catalog numbers or phone numbers.

To create a regex entity, create a new entity as described above, but choose "Regular Expression" as the entity type. You will be able to enter a regular expression rather than a list of values. For example, if your catalog numbers are in the format 'A12345', you could enter '^A\d{5}$' which will match A followed by any 5 digits.

When you save a regex entity, the regex string is checked to ensure its a valid regular expression. However, regex's can get complex and it is recommended you check the regex matches only the values you need.

System Entities

System entities are like a custom entity you build but supported out of the box so you don’t have to waste time building it yourself. The system entities supported right now are

  • @sys.places — this includes places, town, cities etc.
  • @sys.person — famous people
  • @sys.group — organization or a known group
  • @sys.date — matches a date.
  • @sys.time — matched time
  • @sys.percent — percentage
  • @sys.number — cardinal numbers such as ten, two.
  • @sys.ordinal — ordinal numbers such as 1, 2 etc.
  • @sys.any — Matches any non-empty input

Both system and custom entities on its own are not very useful. But when added to an intent they make your life way easier when you need to custom build business logic. Go ahead now and read about Intents in this section


How did we do?