These are concepts you absolutely need to understand when you begin learning Dialogflow.
Want to learn Dialogflow basics quickly? Check out the Intro to Dialogflow course.
In this part of the "Must Know Concepts of Dialogflow" series, we will take a look at Dialogflow actions.
Here is the official definition:
This time, I do like the definition and it is quite clear and concise.
Here is my definition, from the perspective of webhooks:
Actions tell your webhook what business logic to execute
Let us consider the agent which added two numbers (from the webhooks example).
Suppose we want this agent to be a calculator which can perform the following four operations:
Now, to do these different computations, we will use different subroutines in our code. We will have four subroutines, one corresponding to each type of computation.
Add an action to the intent
In the intent we had defined previously for adding two numbers, we will add a suitable value in the Action field.
Inspect the JSON sent to your webhook
In the JSON which is sent to the webhook, the action field is set based on which intent was triggered.
For example, these are some sample JSON files sent over to your webhook for the different computations.
Parse the JSON
In your webhook you will look at the "action" field. Then you will invoke the corresponding subroutine - for e.g. if the action is "numbers.divide" you will invoke the code which computes the division.
You will need to pass two numbers to your subroutine for each of these computations, and you can get these by looking at the "parameters" field and parsing the values for "number" and "number1" respectively.
The action field in an intent is used to choose the action to perform. With respect to webhooks, the action field is used to tell the webhook exactly what business logic should be performed.