Week 3

Team Contribution

In Week 2, you expanded the conversational capabilities of your agent with a feature such as ingredients for recipe selection, and so on. This week, you will focus on user-initiated responses and extending the agent with capabilities for handling questions and responding with new questions when information is missing. As a result, your conversational agent will be able to:

  • handle multiple features for recipe selection

  • handle user appreciation

  • provide additional clarification when a user asks how to perform a recipe step

  • provide clarification when a user asks questions about ingredients

  • provide clarification when a user asks questions about the cooking utensils needed

Recipe Selection

You will enable your agent to select a recipe through multiple features.

Enable Selection from Three Selected Features

In week 1, you selected three features for designing the conversations from your cooking assistant. In Week 2, you selected the recipe from one feature, (in the example we focused on country of origin as feature). This week you will extend on this by asking the user for all three features, thereby further filtering on the recipes after each feature specified by the user. This needs to be done in a dynamic way, such that the user should already be able to choose for a recipe before the three filtering steps have been completed, and it may be the case that a certain filtering does not lead to any matches. Finally, it would be helpful if the agent could cope with multiple features mentioned in a single utterance by the user.

To enable a basic filtering based on three features you need to cover the following aspects:

  • The feature values need to be included in facts about each recipe in recipes.pl

  • The feature values need to be included as entities in your dialogflow agent

  • Specify a variable to keep track of the filtered recipes at each point

  • Specify prolog rules to select recipes based on the given feature values

  • Specify patterns that cover the recipe selection activity including up to three feature values

  • Implement the user intents and agent intents that are included in these patterns

    • Making sure the specified entities are well covered in the user intent training examples

  • Make sure that the proper display is rendered to support the recipe selection dialog (mainly a task of the visual support team)

The most basic pattern by which recipe selection with multiple features can be achieved, is by having the agent ask the user for each of the different features. This may not be optimal, though, as sometimes after selecting even only one feature only a few recipes remain. A more sophisticated solution perhaps is to provide the user with more flexibility in how to select features and provide different patterns (these can be very simple!) for each feature and use the automatic sub-pattern instantiation incorporated in the SUPPLE dialogue management engine.

Of course, there can be several deviations from the happy flow. Some examples:

  • The user asks for a feature or feature/value combination that is not supported;

  • There are no recipes that match the combination of feature values provided by the user;

  • The set of recipes is already small after providing one feature as filter and the user already selects a recipe based on that single filter;

  • The user changes its mind about a specified feature.

When having implemented and tested the happy flow, you need to enable the agent to cope with such scenario’s. A slot-filling implementation in the form of a slotfilling pattern (patterns.pl) and trigger (dialog_generation.mod2g) is already given in the basic GOAL agent. However, this implementation is particular to a scenario where a user intent is lacking one or more entity values. For the current purposes, a particular recipe selection trigger needs to be specified, specifying the missing parameters in another way.

Recipe Instruction

You must make your agent capable of clarifying the user’s questions. Also, you must handle the user’s appraisal.

Enable Clarification Questions

It is good practice to allow a user to ask for help at any moment during an interaction with a chatbot. There are many ways a user could do this. Simply shout for “help". Following are some ways to facilitate users in this.

Recipe Steps

Let’s formulate and elaborate recipe requests for help. Consider when a user says “Can you clarify this for me?", or ''How do I do that?", or even “What do you mean?". How the agent should respond will differ for each intent and pattern that is active. So, here, we will focus on adding more detailed information related to recipe steps and enabling the agent to provide this information when a user asks for it.

  • As a first step, add a user intent requestClarification to your Dialogflow agent.

  • Second, introduce a new predicate elicit(Recipe, StepNr, Info) to add more detailed clarification for recipe steps in your recipes. Add this predicate to the cooking.pl file for as many recipe steps as possible to further clarify a step.

  • Note that this predicate has exactly the same structure as the step/3 predicate. For example, even for a simple recipe instruction, ''Boil a pan full of water.", you could add the more detailed instruction "Fill your pan until about three-fourth of water and heat until the water boils.".

  • Finally, add a pattern (see A2.5 in the patterns.pl file), and introduce an agent intent provideClarification that you also need to add to the text.pl file.

Ingredients Clarification

There are many questions that a user might raise about the ingredients in a recipe, but here we will focus on users that ask for a reminder about the quantity that is needed of an ingredient for a recipe. For now, we will assume that a recipe is mentioned in the request, or if not, that a recipe has already been selected. A user might ask, ''What is the amount of water needed for the pasta?". To address this request, you can now benefit from the entities that you have introduced earlier for recipes and ingredients.

Dialogflow will return values for these entities too to the chatbot agent (water and pasta for the example request). For requests that do not mention a recipe, like “What is the amount of water needed?", first, try and test the pattern you will introduce only after a recipe has been selected (as we will assume that a recipe is known in that case).

To implement requests about quantities, first add a new user intent requestRecipeQuantity to your Dialogflow agent and then add a new A2.5 pattern for addressing requests about ingredient quantities (see again the patterns.pl file for more information).

Utensils Clarification

Like for ingredients, add a pattern that allows a user to inquire about the need for a utensil for a particular recipe. The user should, for example, be able to ask whether it will need a grater for cooking pasta. Note that the agent should simply reply with a "yes" or "no" answer in this case, which is slightly different from requests about ingredient quantities.

Collecting Missing Information

In the previous subsections, we have assumed that all the relevant information for answering a user request is available. Here, we will address the cases where this is not true. For example, a user might simply ask how much water is needed, without indicating for which recipe, while no recipe has been selected either yet. In such a case, the agent cannot answer the question, because it is missing information, and the agent should take the initiative and ask for this information itself. The SUPPLE dialog engine has already been prepared to handle this by a process called slot filling. It can detect that parameters are missing when a user intent is received from Dialogflow with parameters without a value. If it detects that parameters are missing, a slotFilling intent will be generated (see top of the dialog_generation.mod2g file). Moreover, it will store the parameters for which information is missing in a list using the missingSlots/1 predicate and indicate the number of missing parameters in the totalSteps/1 predicate.

To start asking for the right information, however, it needs to know what kind of question to ask. In other words, the engine needs to be provided with the right pattern to ask for the right information. It is your job to provide the agent with such a pattern. More specifically, you are asked to do so for the user intent requestRecipeQuantity. In the patterns.pl file, the name of the pattern that you should implement has also already been provided by means of the slotFill/2 predicate. Please implement the pattern and the associated intents to enable the agent to ask for more information.

User Appreciation

User appreciation is a simple example of a user taking the initiative by, for example, thanking the agent. The agent should receive this kind of appreciation appropriately and respond to it to show this. To make this happen, add an appreciation intent to your Dialogflow agent and implement the B1.3 pattern in the patterns.pl file.

Visual Support

During this week, you must work on the displays during the recipe selection by multiple features. Moreover, you should work on the displays during the recipe steps regarding the clarification questions.

Display during recipe selection

The information on the display is essential to recipe selection. It is not feasible to have the agent mention all the recipes that fit a certain filter. The user is rather helped when being presented with all or part of the recipe names as the selection progresses, along with other information on the recipe selection, such as the chosen feature values and the number of recipes that match these values. As a background to this implementation, it is helpful to read the following sources:

Then think of how to extend on the design you made for the selection of a recipe based on a single feature value in week 2. Is there any additional information that you want to display as the available recipes are presented (such as the feature values that have been chosen), and where would you place this information?

After you have thought of a nice design, implement it in html.pl as prolog rule. The different information units you want to include in the display can be included as different input variables to the rule’s head.

You may want to test whether your implementation is operational by rendering the page with some hardcoded values as a dialog_update and dialog_generation rule.

The next step is to work on the content side. The Recipe Selection team has probably already worked on the filtering of recipes. In so far you want to display other information, like the number of recipes that were filtered, implement rules for this. It makes most sense to specify these rules in cooking.pl, referring to them from your dialog_update and dialog_generation modules. Make sure that the right information is gathered at each moment during recipe selection, and incorporated in the display. It is vital to know about the different contexts during conversation, and you therefore need to communicate well with the recipe selection team to for example know of their pattern and intent implementation.

Displays during recipe steps and clarification questions

For the three recipes that your team has selected, visuals can be used to enrich the information as a step is instructed or clarification question is answered. It is open to your vision and creativity what kind of displays you want to implement, with what kind of information. There may information particular to a recipe step, such as a video or picture that shows a certain operation or cooking skill needed for the step. There could also be general information you would like to display alongside each instruction, such as the number of the step.

When having designed the templates to enrich the displays during recipe instruction, you need to find the html code needed and define a prolog rule in html.pl to dynamically include the active information in the template. In addition, the information you want to include given a context needs to be accessible by implementing prolog rules in cooking.pl.

Finally, make sure that the right page and information are presented according to the agent intent (dialog_generation) or expected intent (dialog_update).

Testing Phase 3

Now, your Cooking Assistant is able to do the following:

  • Recipe Selection with three features combined.

  • Proper display to support recipe selection

  • Clarifying Ingredients and Utensils

  • Navigate the dialog flow during recipe instruction (of the three chosen recipes)

    • Help users recognize their requirement(s) through conversational text

    • Help users recognize their requirement(s) through visuals

    • Ensure smooth execution

  • Handle user appreciation

Week-3 Deliverables

You need to provide

  • Code

  • Weekly progress report in .doc format (See Guidelines). Remember, you also need to work on your final report already.