philipskokoh
philipskokoh

Reputation: 93

How to properly handle user text input after Google Action List response type

We use actions.intent.OPTION to handle selection for List response type in Google Actions. actions.intent.OPTION not only handles user selection (touch) input, but also handles the user (voice/text) response after the list and nicely maps the user response to an item in the list. It also handles typo to some extent.

However, it is a difficult to handle user response who does not want to select from the List response. Based on Google official guide (https://developers.google.com/actions/assistant/responses#list), we use suggestion chip to pivot or expand the conversation.

I have a use case in which a user may use few possible texts to indicate that he/she does not perform selection. For example:

bot: which food do you want?
(showing list)
- rice
- salad
- pizza
(suggestion chip)
not in this list

These are user response that we can handle:

However, if the user say other texts like "i change my mind", "let's do something else", "let's do it again", or "restart this step", we are unable to handle this because Google action and dialogflow automatically map these texts to the most similar item in the list (string similarity).

Any good practice to handle user response who does not select any item in the list beside suggestion chip? I feel one suggestion chip is not enough to handle many variations from user response.

Upvotes: 1

Views: 429

Answers (1)

gmolau
gmolau

Reputation: 3005

When a user selects a list item via voice the Assistant maps the input against the key and the synonyms of the list item. The key is then send back as input to your Dialogflow agent. When the mapping doesn't succeed the actions_intents_OPTION event is not triggered and the input is simply matched against all intents like any other input. This means that you can capture requests like "let's do something else" by simply adding a normal intent for them. To ensure that this intent is not matched outside of the list-select flow you should set a context when presenting the list and add that context as the input context to the ChangeMyMindIntent.

Here is how this would work in more detail:

  • The normal list selection would be captured by a FoodSelectionIntent. This intent responds to the actions_intents_OPTIONS event, i.e. does not need to have training phrases. It should have the food_selection input context, to separate it from other list select intents.
  • Then you add additional intents for all requests that users could make besides actually selecting an item (ChangeMyMindIntent, RestartIntent). These too should have the food_selection context so that they are not matched at any other point in the conversation.
  • When you render the list you set the food_selection context as well. This ensures that the next webhook request will contain either a valid list selection (captured by the FoodSelectionIntent) or one of the alternative intents that you have scoped to the food_selection context.
  • Don't forget to delete the food_selection context (set its lifespan to 0) after this flow is completed to not limit the intent matching of the next request.

Upvotes: 1

Related Questions