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:
- User asks for 3 cities.
- 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. - 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?