Entities Training

Train the bot to extract structured data from user text input.

Entities are used for extracting values from natural language inputs. Any important data you want to get from a user’s request will have a corresponding entity.

In the expression “I need to see Dr. Grey on Monday” Dr. Grey and Monday are entities (of type doctor and date).

There are 2 types of entities:

  • built-in (defined by NativeChat)
  • developer (defined by a developer)

Built-in entity types

The built-in entity types can be used with a Question step without explicitly training your chatbot how to recognize them.

Date

Use the Date entity type to retrieve date values from a conversation. Note that if you are defining validation for the dates such as a Range validation for minimum and maximum date, the validation will be performed for the parsed entity by NativeChat. For example, if the user inputs “I would like to meet with doctor Burke tomorrow”, NativeChat will identify tomorrow as the correct date and will parse the value validation only e.g. 2017.02.02.

Time

Use the Time entity type to retrieve time values from a conversation. Note that if you are defining validation for times such as a Range validation for minimum and maximum time, the validation will be performed for the parsed entity by NativeChat. For example, if the user inputs “I would like to meet with doctor Burke tomorrow at 2 in the afternoon”, NativeChat will identify the correct time and will parse the value validation only e.g. 14:00.

Datetime

Use the Datetime entity type to retrieve date and time at the same time. In most cases, it would be better to use Date and Time separately so that the chatbot will be able to understand just the date or the time and then ask for the other. The Datetime value is a javascript date. Once a Datetime entity is understood you can use it in messages using the $date formatter.

Number

Use the Number entity type to retrieve numeric values from a conversation. NativeChat will understand “500” as well as “five hundred” and return an entity with value 500 as an integer.

Text

Use the Text entity type to retrieve free-text input from the user such as a subject of a message or a title.

File

Use the File entity type to receive files from a conversation. Entities of this type are not understood from the message text. They are filled when the user sends a file to the bot. The value of a File entity is an object with the following properties:

  • url - URL of the received file
  • labels - array of labels that are automatically attached to every image file using image recognition
{
  "steps": [
    {
      "type": "question",
      "entity": "file",
      "entity-type": "File",
      "entity-display": "{{file.url}}",
      "messages": [
        "Please, upload your photo"
      ]
    },
    {
      "type": "message",
      "messages": [
        "Your file is located at URL {{file}}"
      ]
    }
  ]
}

Confirmation

Use the Confirmation entity type to retrieve a specific user confirmation from the text as Yes/No. The value of Confirmation entity is boolean: true if the user confirms or false if the user declines.

EntitiesConfirmation

EntitiesConfirmation entity type is reserved for internal use in entities-confirmation step and should not be used for other purposes.

Location

Use the Location entity type to receive locations from a conversation. The value of a Location entity is the location coordinates of the received location. Entities of this type are not understood from the message text. They are filled when the user sends a location to the bot.

The metadata of the location is an object in the following format:

{
  "latitude": 34,
  "longitude": 45
}

and you can configure a simple conversation to collect and display the Location as follow:

{
  "steps": [
    {
      "type": "question",
      "entity": "location",
      "entity-type": "Location",
      "messages": [
        "Could you share your location?"
      ]
    },
    {
      "type": "message",
      "messages": [
        [
          "Test message latitude is {{location.latitude}}",
          "Test message longitude {{location.longitude}}"
        ]
      ]
    }
  ]
}

Developer Entities

Developer entities can and should be used for anything that’s not covered by the built-in entities, and should contain values you can expect from your users.

The more examples and synonyms you provide for each entity, the more your bot will understand.

Lookup Strategies

The lookup-strategy defines the NLP search strategy, and how should NativeChat understand entities from a conversation with a user.

NativeChat offers several different options for training natural language recognition.

Traits

Use the trait lookup strategy if the entity type and its value cannot be identified by a specific word in the sentence. The trait strategy is used when the entity type and value cannot be determined by matching a keyword or synonym from the text, but NLP should understand the meaning of the sentence as a whole. You should define a set of expressions for each value that will be used to identify it.

The chatbot will store the entity value in the bot memory no matter which expression the user actually used.

Keywords

Use the keywords lookup strategy if the entity can be identified by a specific word in the sentence.

You can also add synonyms for each value. The bot will recognize the entity when it sees either the keyword value itself or any of the synonyms.

Even if the user used a synonym the main keyword value will be stored in the short-term memory as a value of the entity.

Regex

Use the regex lookup strategy if the entity has a distinctive pattern like a car registration number, social security number, etc.

Example:

  • \\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+ for recognizing email address.