Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically validate allowed entity values in Dialog Flow

In my Dialog Flow agent, I have an entity @city. Possible values are New York, Berlin, ... But Amsterdam is not in that list.

Is there a way to dynamically validate an entity value against the values in my SQL database? For example, if the user writes Amsterdam, I want to give the user an hint that he should ask for another city. Can this be done via a webhook?

Or should I synchronize my database cities with the agent on a regular basis? If so, can this be done via an API?

I am not sure what the standard way of this is here.

like image 242
Andrew Eers Avatar asked Dec 01 '17 20:12

Andrew Eers


People also ask

What is allow automated expansion Dialogflow?

Automated expansion is used when a user input matches an intent but the entity value doesn't exist yet. See a detailed explanation in the documentation. Example: Entity color [blue, green] Intent "My favorite color is [color]"

What is agent validation in Dialogflow?

To help agent designers create high-quality agents, Dialogflow provides a validation feature. Agent validation results are available automatically whenever agent training is performed and completed. You can access the results of validation from either the Dialogflow Console or the API.

How are entities defined in Dialogflow?

How to enable and use developer entities in Dialogflow. Create developer entities. Edit intent to accommodate the newly created developer entity. Test your chatbot.

What are actions and parameters in Dialogflow?

Dialogflow sends an API interaction response for each step of slot filling. For each of these slot filling responses, the intent and action will be the same, and the parameters collected so far will be provided. When building an agent, you provide prompts that the agent will use to get parameter data from the end-user.


1 Answers

You have a few options here, depending on what will work best for you.

In the most simple case you can set the parameter entity type to @sys.any and handle all the name resolution in your webhook. This is the worst possible scenario.

As you've done, you can create your own entity type, @city, and populate it with a few cities. If you want to populate it with the cities in your database, there is an API (hence the old name, API.AI) that lets you create and modify Entities. See the documentation at https://dialogflow.com/docs/reference/agent/entities for details.

Even best, however, might be a combination of the two. You have an Intent that uses @city, and another lower priority Intent that uses @sys.any (or a fallback intent) that handles the case of them saying something you don't understand.

like image 189
Prisoner Avatar answered Oct 31 '22 05:10

Prisoner