Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel2
outlinefalse
typelist
printablefalse

Dialogflow

Entity for number of ingredients and number of recipe steps

While implementing the previous capability we only implemented three features that can be used to filter recipes on. To make our addFilter intent more useful and allow a user to make requests about more recipe features, we need to add more training phrases that can capture what a user wants in Dialogflow. For each type of recipe feature that we want to add, however, we need to also add all of the values of such a feature as entity entries. There is, however, one relatively cheap way to add a new feature that makes use of the system entities of Dialogflow. We can use, for example, the @sys.number entity for implementing feature requests related to the number of ingredients. For example, you can add phrases like “A recipe with less than 10 ingredients” to cater to users looking for simpler recipes. Remember to annotate the number of ingredients in each phrase with the @sys.number system entity so Dialogflow can correctly identify and extract this parameter. And, just as important, you should specify a parameter name such as nrOfIngredients for the parameter Dialogflow should extract. Your new entry in the table in the Actions and parameters section should look as follows:

...

In a similar vein, you can should add phrases about the number of recipe instruction steps such as “I’m looking for a recipe with less than 8 steps”, and the number of servings of a recipe. Use a as parameter name such as names nrOfSteps and servings. This will make sure the MARBEL agent will receive filters of the filter form nrOfSteps=8 and servings=4 and store that in the its conversational memory. Finally, also annotate for recipe duration for a parameter called duration but instead of @sys.number use the @sys.duration system entity of Dialogflow.

Extracting multipe features from a single user expression

Another way to improve your Dialogflow agent is to enable a user to include multiple requests in a single user expression. You can achieve this simply by including many more phrases such as “I’d like a Chinese recipe with less than 8 ingredients”. This will ensure that your conversational agent can recognize multiple filter requests.

Prolog and Patterns

Retrieving the (number of) ingredients and recipe steps

...

  • Now add a similar rule that applies a filter for the nrOfSteps feature; your Training phrases should dictate how to read the constraint. I.e., if your phrase says “less than N recipe steps” than you should write code that implements the filter to mean exactly that.

  • Add a similar rule that applies a filter for the servings feature. You probably want to make sure that a recipe has exactly the right number of servings that the user asked for.

  • Finally, add a rule that applies a filter for the duration feature. This feature is a bit more tricky and you should take the warning above about data types to heart. However, most of the work has already been done for you in the dialog_update.mod2g file in a step called Pre-process parameters of intent. In this step, the duration values received from Dialogflow are transformed to minutes (numbers) using the duration_to_min predicate defined in the utils.pl file. This means that to define the rule for filtering, you simply need to look up the time it takes to cook a recipe in the database (specified in minutes), and compare that value with the maximum duration that the user specified.

Visuals

Extend the recipe confirmation page

...

Ask for recipes with 5 ingredients and see if you receive the following answer.

...

...

Extend your agent to be able to filter by the maximum number of steps in a recipe, recipe duration, and number of servings in a recipe. The process is quite similar to that of the filtering by maximum number of ingredients.

Test it Out

Check if the recipe on the a50 recipe confirm a50recipeConfirm page fulfills the criteria you chose for the number of steps, number of servings, and duration. Make sure to test that all 3 filters introduced for this capability work.

Info

All done?

Proceed with https://socialrobotics.atlassian.net/wiki/spaces/PM2/pages/2216001572/Building+Your+Agent#Agent-Capability-6%3A-Filter-Recipes-by-Exclusion-Recipe-Categorical-Characteristic