stopsatgreen
stopsatgreen

Reputation: 2082

Provide different responses to options in an Assistant List using only Dialogflow?

I have an intent with an Assistant List containing two options, Apples and Cheese. I want to provide a different response to each option chosen.

My first attempt was to use follow-up intents for each item, but when I do this I get a “not understood” message when tapping/choosing the item. On reading more, I understand this is because the actions_intent_OPTION event has been fired and there is no intent to handle it.

My second attempt was to add the actions_intent_OPTION event handler to each of my follow-up intents. When I did this, only the Cheese intent was invoked each time. I understand this is because actions_intent_OPTION can only be handled by a single intent.

So my conclusion is that the only way I can provide different responses for different items in an Assistant List is to handle this event with a webhook, and that it’s not possible using Dialogflow alone. Can anyone confirm or point me in the right direction if not?

Upvotes: 0

Views: 608

Answers (2)

stopsatgreen
stopsatgreen

Reputation: 2082

The answer is, as suspected, that you can’t use an Assistant List purely in Dialogflow, you have to add a handler function in the fulfilment, that fires on the event actions_intent_OPTION. For example:

const option = conv.arguments.get('OPTION'); if (!option) { conv.ask('No choice made'); } else if (option === 'optionA') { // Do something } else if (option === 'optionB') { // Do something else }

Upvotes: 1

Abhinav Tyagi
Abhinav Tyagi

Reputation: 5266

Follow this ideal approach:

  • remove follow-up intents
  • add a new intent with event set as actions_intent_OPTION
  • enable webhook for the new intent
  • in the webhook extract the selected option
  • based on the selected option, pass the required response

If you want to use only Dialogflow, then it won't work! This is because, when you select an option, the output context and the generated event both will be the same as the 2 intents - cheese and apple. There will be no way for the AI engine to decide which Intent should be triggered. Whichever intent is first, it will be called every time.

I tried to recreate what you did all be Dialogflow and even put cheese and apple as training phrases for the 2 intents just to provide some differentiation to the AI engine, but it still selected only one intent.

Upvotes: 0

Related Questions