Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use user entities in Dialog Flow?

In Where is the data context in Dialog Flow (API.ai) I asked how to keep user-specific data. For example, the user asks for a list of cities and the webhook service randomly picks three. If you then want to refer later to a city in this list, you somehow need to store it. The answer in the issue was that it could be transferred back and forth in the context.

Now I read about user entities in the documentation. This was an unknown concept to me. My question is now: could we also use user entities for such flow? For example:

  1. User asks for 3 cities.
  2. Webhook is called and 3 random cities are picked. At this moment, the webhook service also creates a user entity @user-cities for the ongoing session via the REST API. We could even have the SQL identifier as the key and the name of the city as a possible synonym.
  3. In later intents, we refer to the @user-cities for a parameter. When a valid city, based on his previous list of cities, is provided to the webhook service, the identifier will be provided. The webhook service can then use this identifier to provide additional information about the city.

Example flow:

User:  Please provide me some interesting cities.
Agent: What about New York, Berlin and Barcelona?
User:  Please tell me more about Barcelona!
Agent: Sure, Barcelona is ...

I did not try this out yet, but I am wondering if this is a good applicaiton of user entities? The follow-up question would be: when would you use user entities and when would you keep the data in the context?

like image 468
Andrew Eers Avatar asked Dec 02 '17 14:12

Andrew Eers


People also ask

What is the use of entities in Dialogflow?

Dialogflow provides predefined system entities that can match many common types of data. For example, there are system entities for matching dates, times, colors, email addresses, and so on. You can also create your own custom entities for matching custom data.

What are session entities?

A session represents a conversation between a Dialogflow agent and an end-user. You can create special entities, called session entities, during a session. Session entities can extend or replace custom entity types and only exist during the session that they were created for.

What are entities of a system?

The elements that make up an organizational system can be referred to as entities. An entity may be a person, a place, or a thing, such as a passenger on an airline, a destination, or a plane. Alternatively, an entity may be an event, such as the end of the month, a sales period, or a machine breakdown.


1 Answers

While this would work... sorta... it isn't really a good application of User Entities. The biggest issue is that you're now making an API call to create an alias for terms like "this" or "that" or "that first one". And you're constantly changing those entity definitions, including removing old aliases and setting new ones.

User Entities are best for things that you know about that user that will differ from other users. To use your cities as an example, you may use user entities to store a person's favorite cities or any nicknames they have for those cities. Once the user logs in, you'd then set @user_cities and their nicknames for a city are now available.

Update To use another example, again with your cities framework.

You might change a User Entity for features and aliases about a particular city once it is selected. So if the user selected "Sydney", you might create a @feature user entity containing entries for the opera house, or the beach, but not anything about a clock tower. While for "London" we might add entities about a tower and a bridge, but not a beach.

The focus is on what you want to hear from the user vs what you want to remember about the conversation.

like image 56
Prisoner Avatar answered Oct 18 '22 03:10

Prisoner