Create an agent and Read about How to Make Intents and Entities:
Before you start anything make sure your agent is connected to Dialogflow:
Make sure your naming is precisely the same for intents and entities as the ones given or you will run into issues later on!
Greeting Intent
Make an intent called greeting. In Training Phrases add some user expressions(at least 10). These would be things that the user could say as a greeting, try and be thorough. Under Action and parameters make sure the box above the table is filled with the name of your intent as shown in the image below.
Appreciation, Confirmation, Disconfirmation, Farewell Intents
Repeat the same process as the one for Greeting Intent for the following intents:
appreciation
If a user expresses appreciation or gratitude (for example: ‘thanks’)
confirmation
If a user wants to agree or say yes
disconfirmation
If a user wants to disagree or say no
farewell
If a user wants to say goodbye
Check Capability Intent
checkCapability is the intent for when a user wishes to know what your bot can do. Add some appropriate training phrases. An example would be “What can you do?”.
Fallback Intent
The Default fallback intent is one of the more important intents and it already present when creating your Dialogflow agent. Fallback intents are triggered if a user's input is not matched by any of the other intents known by the agent, or if it matches the training phrases you input. It is unnecessary to input phrases that are completely unrelated to the topic as that would definitely come back as an unknown intent. Thus, what you should do is think of related phrases that would be close to an intent but should not match it. For example, one could argue “I do not like mushrooms” is food related and has an ingredient entity inside but should not be matched to any other intent because likes and dislikes are not directly discussed with your bot. (However, one could argue you could use I like and I dislike as training phrases for filtering by something, that is a design decision for you to make). This fallback intent should be updated as you add more intents throughout the project.
Entities
Before we can continue creating intents we have to create the entities we need, since these will be part of the intent specification for certain entities (e.g.: the presence of an entity type is used as a feature by the Dialogflow classifier model to recognize certain intents by). Some of these entities are given to you in a Folder. For information on how to upload and create entities, you should have read this page. : DialogFlow: Create an Agent, Intents and Entities
Some entities were not provided provided by us, and you have to add them yourself (see the list below). We provide an example for most to make sure you have at least a few entries for each entity. If the word you enter has synonyms, use the synonym option rather than entering them as multiple entity inputs.
removekeyword - words to remove filters (for example ‘remove’)
timeKeyWord - words that refer to measurements of time
shortTimeKeyWord - for example ‘fast’
negationKeyword - to specify that something needs to be omitted (for example ‘without’ or ‘don’t’)
easyKeyWord - to specify recipes that are not hard to make (for example ‘simple’)
When you are done your entities page should look as follows:
Add Filter Intent
Add filter intent is one of the most important intents. It is used to filter recipes for the user based on a variety of criteria. This is the first intent that employs all the entities we have created. In the user expressions, where the user is asking to filter, all different entities need to occur and be tagged in the set of examples. For example, for a training phrase like “ I want a Chinese recipe”, ‘Chinese' needs to be tagged as ‘cuisine’, so this phrase can be parsed by Dialogflow in order to apply the filter Chinese to the recipes in our database. The addFilter intent can be found in the folder provided to you, and should be uploaded in Dialogflow by you.
Recipe Filtering Functions Helper Functions
To filter the recipes for the user in the way they intend, we parse their utterances with the intents and entities we made in Dialogflow. This then returns the identified intent(for example addFilter) and entity information(cuisine - “Chinese”). We must now take this information and create Prolog rules to access and gather the filtered recipes. This is done via the following functions. The heads of all rules can be seen in recipe_selection.pl and that is where the bodies should be added. We need a few helper functions before we can start filtering these, which are described below.
nrOfIngredients
We will start off easy.
nrOfIngredients(RecipeID, N) :-
Create a rule to return N, the length of the list of ingredients for a certain RecipeID. HINT: your Visual Support groupmates should have made an ingredients function that could help.
nrSteps
nrSteps(RecipeID, N) :-
Create a rule to return N, the number of steps for a certain RecipeID. HINT: your groupmates should have made a recipeSteps function that could help.
Diet
diet(RecipeID, DietaryRestriction) :-
In the diet rule, we need to find all the ingredients that a certain recipe has and then input them into a new function we shall create below diet called ingredientsMeetDiet which returns a list of ingredients that fit the dietary restriction. This list should be returned with the name DietaryRestriction.
ingredientsMeetDiet([], _).
The fact above is our stop clause as ingredientsMeetDiet will be a recursive rule that will check each ingredient to see if it fits the dietary restriction. The predicate typeIngredient can check if an ingredient meets a dietary restriction. Fill in the body of the rule for ingredientsMeetDiet.
ingredientsMeetDiet([ Ingredient | Rest ], DietaryRestriction) :-
What’s an Easy Recipe?
easyRecipe(RecipeID) :-
Make a rule that can return all easy recipes
A recipe is easy when:
they can be made within 45 minutes,
have less than 18 steps, and
less than 15 ingredients
Recipe Filtering Functions applyFilter Functions
applyFilter Functions
These functions filter our recipes and return a list of filtered recipes in the form of their RecipeIDs. The heads of the rules are in the recipe_selection.pl file.
applyFilter(+ParamName, +Value, +RecipeIDs, -FilteredRecipes)
Filters the recipes provided as input using the (Key) feature with associated value and returns the recipes that satisfy the feature as output.
ParamName: A parameter name referring to a feature that the recipes should have(ex.’cuisine’).
Value: The associated value of the feature (parameter name) (The user requested filter value like Chinese).
RecipeIDs: The recipes that need to be filtered.
FilteredRecipes: The recipes that have the required feature.
Thus you must find all recipes that fit the filter criteria and return a list of the filtered recipes. Make sure to use the naming conventions for the variables that we provided. For the first two functions, I shall provide some hints. These hints could apply to more than one applyFilter rule. The heads can be found in recipe_selection.pl.
A list of all your applyFilter functions and some notes on how to create them:
Predicate Description | Rule Head | Notes/Instructions |
---|---|---|
The predicate to filter recipes on cuisines (e.g., Italian recipes) | applyFilter('cuisine', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes that meet the dietary restrictions (vegetarian etc). | applyFilter('dietaryrestriction', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the max amount of time | applyFilter('duration', Minutes, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter easy recipes | applyFilter('easykeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient | applyFilter('excludeingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient type (ex. beef) | applyFilter('excludeingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicates to filter recipes on a specific ingredient inclusion | applyFilter('ingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter by including an ingredient type | applyFilter('ingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on meal type (breakfast e.g.) | applyFilter('mealType', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of ingredients | applyFilter('nrOfIngredients', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of steps | applyFilter('nrSteps', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes and return fast recipes. A recipe is fast if it takes less than 30 minutes | applyFilter('shorttimekeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter on the number of servings | applyFilter('servings', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on tag ex. pizza is a tag | applyFilter('tag', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Further Necessary Intents
deleteFilterValue
delete filter value is for when the user requests to remove a filter that they have already put on specifically. For example, “I wish to remove the onion filter”, “Forget about excluding broccoli”, and “Can you delete the Chinese cuisine”.
It is thus important that in your training phrases you include a variety of entities and that these entities are also given specific values and parameter names in the Action and Parameters tables. Your entity table under Action and Parameters should thus look like this when you are done.
deleteParameter
The delete parameter intent is identified when the user requests to remove a kind of constraint. For example, “I wish to remove the ingredient constraint”, and “Please drop the step constraint”. This intent requires the use of a certain entity, make sure to include it in your action and parameters section.
noMoreFilters
No more filters is used when the user does not want to add any more filters to their recipes list and wishes to see the available recipes.
recipeRequest
Recipe request is used to confirm the user's choice of recipes. “I want this specific recipe name here”. In entities, you can find an entity for the recipe names in our database.
In the end, your Intent page should look like this:
0 Comments