Same Entity for user name and user number

Is it possible to use the same entity for both user names and user numbers? For example, if a user’s utterance is ‘My name is Jim, and I want to know my account balance,’ the value ‘Jim’ should be stored in the entity. Similarly, if the user’s utterance is 'My account number is xyz, and I want to know my account balance, then ‘xyz’ should be stored in the same entity. Can anyone confirm if this is achievable?
Thanks.

Yes you can use the exact same entity, but it is not something I would recommend.

An entity is a piece of data that has a particular meaning within a conversation. A user name and an account number are different things, they are referred to differently in conversation and something somewhere must be making a distinction between them because otherwise you would not be talking about them as different things. If you don’t make the distinction during the extraction, then you will have to do it somehow later, and it may well be harder later because you will be missing contextual clues from the user’s utterance.

A key part of an entity definition in the Kore.ai platform is the entity type. This encompasses certain processing rules that implicitly make it easier to extract the entity from the user’s utterance. The most basic entity type is a String which essentially has no boundaries, it will greedily extract as many words as possible. At first glance this type could be used to grab a user name or an account number. The challenge with String entities is knowing where to start and stop within the sentence, and this is where entity patterns come into play.

It is not clear from your description if user name is really a “normal” name, or something more structured - “Jim Smith” or “jim123”. If it is the former, then the Person Name entity type is a good choice because it has knowledge about names. The latter, which would have no rhyme or reason behind the value, could be handled as String with an entity pattern limiting the match to one “word”. Or if the value is always a mixture of letters and numbers, a format that internally is referred to as a “model number”, then you can use a Custom entity where the expression is the name of an internal concept called ~modelnumber. (This concept is dynamically applied to words that are any combination of letters and numbers.)

If the account number has a certain format - such as 8 digits, then a Number entity with an entity rule specifying the length of 8 digits would work. If the format is a specific mixture of letters and numbers (e.g. two letters followed by 6 digits) then a Custom entity type with a regex expression is useful.

Finally you can wrap these two entities up in a Composite entity that will allow you to have a single prompt and will accept either a user name or an account number, depending on how the user responds.

2 Likes

Thanks for your explanation.
I would like the ‘PersonName’ entity to be automatically recognized and populated if the user’s utterance includes a name (e.g., John, Jack, etc.). However, I do not want the ‘PersonName’ entity to be triggered or prompted if the user’s utterance does not contain any name. Is it possible ?

When an entity node is reached in the flow then it will always check the existing utterances in the conversation for a valid value, and will transition on to the next node if there is one. There is an exception to that where you can explicitly force a prompt and not evaluate unused words.

What to do if there isn’t a valid value depends on the mandatory/optional/hidden setting. Hidden entities just check for a value, once, and move on without prompting if there is no value found.

The documentation on entities is at https://developer.kore.ai/docs/bots/bot-builder-tool/dialog-task/working-with-the-entity-node/

1 Like

Just wanted to say thanks for your helpful response. Your explanation about entity nodes really worked for me. Much appreciated!