Entities

Entity Commands

Entities are used to identify and extract data from the user’s input. This data can be remembered and used later in conversation or used to complete automated tasks such as creating appointments or filling out user information for an account.

It is possible to perform actions associated with entities in the cli by using sb-cli entity <command>. The possible commands are listed below.

sb-cli entity create <json>            Creates an entity from inline JSON or a
                                       file
                                       [aliases: c]

sb-cli entity delete <alias> <locale>  Deletes an entity with the given alias
                                       [aliases: d]

sb-cli entity describe <alias>         Describes an entity with the given
                                       alias
                                       [aliases: desc]
                                                            
sb-cli entity list                     Lists all available entities
                                       [aliases: l]

Examples

Say you work for a house painting company and your customers can set appointments in advance by stating their name and the color they want their house painted. It will be useful to create entities that can recognize those two variables; name and color. To create a color entity, let’s use the alias “color-entity”, in locales english (en) and french (fr), with the description “This entity recognizes what color the user wants their house painted”.

In this case, you should use the following command:

sb-cli entity create {
  "alias": "color-entity",
  "type": "list",
  "locale": "en",
  "options": [
      {
          "referenceValue": "red",
          "synonyms": ["maroon", "scarlet", "burgundy"]
      },
       {
          "referenceValue": "orange",
          "synonyms": []
      },
       {
          "referenceValue": "blue",
          "synonyms": ["sky blue", "royal blue"]
      }
  ]
}

Now, if the customer writes to their chatbot,

The bot can extract “scarlet” and recognize that the customer wants their house painted a shade of red. Similarly, the customer could say:

Despite the different phrasing, the bot will still extract “sky blue” and determine that the user wants their house painted a shade of blue.

If you need a reminder of what kind of data your entity aims to recognize, use the command sb-cli entity describe color-entity and the CLI will return your given description,

If you have many entities and you would like to see a list of all of them, use the command sb-cli entity list and the CLI will return a list of entities such as:

Alias Locale
color-entity en
exampleEntity2 locale2
exampleEntity3 locale3

Finally, if you want to delete the entity in the english locale only, simply input sb-cli entity delete color-entity en to the ServisBOT CLI