Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is better practice to invoke functions,Intent Name or Action?

In DialogFlow, we can trigger functions and perform tasks based on either Intent Name or Actions.

Which one should we use to decide? What is better practice?

like image 283
sid8491 Avatar asked Aug 04 '18 08:08

sid8491


People also ask

What is intent in dialog flow?

An intent categorizes an end-user's intention for one conversation turn. For each agent, you define many intents, where your combined intents can handle a complete conversation.

What is a follow up intent?

A follow-up intent is a child of its associated parent intent. When you create a follow-up intent, an output context is automatically added to the parent intent and an input context of the same name is added to the follow-up intent.


2 Answers

I've asked a similar question in the past and have experimented with both the function-by-intent and function-by-action patterns, and I have come to view the actions as almost completely useless. Their only benefit seems to be that you can attach the same action to multiple intents, but if anything I would want to have the same intent be handled by multiple functions, based on the specific contexts and parameters. This originates from a design goal of rather having fewer multi-purpose intents than a lot of simpler ones, though the latter pattern is arguably the one implied by many of the Google docs.

Conceptually I think it is useful to think of the fulfillment functions as the transition functions of a finite state machine, where the state is defined by the incoming webhook request, i.e. a tuple of (intent, contexts, parameters, event) plus maybe other metadata such as locale and surface capabilities. I haven't found the actions to add anything to this model.

like image 75
gmolau Avatar answered Sep 23 '22 20:09

gmolau


In most cases, it won't matter. The approach that @gmolau describes is a good one, and I think they're pretty much spot on.

Certainly the documentation is increasingly going towards using Intent Name for everything rather than Action.

The case where I think it makes the most sense to use the action name instead of an Intent name is when you have different Intents that may respond to the same phrase, and ultimately do the same thing, but only in certain contexts. This lets you do the logic for what gets called on the Dialogflow side and not have to register the same Handler against multiple Intents.

like image 25
Prisoner Avatar answered Sep 22 '22 20:09

Prisoner