Every intent must define a response that's returned to the user. There are two primary ways you can return a response to the user — either with a pre-defined, static response or with a response generated from a webhook. In both of these cases, you can use extracted parameters in the response.
As a general rule, your responses to users should prompt them to provide input that will match one of your other intents (in other words, to keep the conversation going). To do this, you should provide your users with a prompt that guides them towards a specific answer. For example, a question like "What city were you born in?" is better than a more open-ended inquiry like "Where were you born?" if your agent requires a city to do some logic.
Static text response
In the Responses section of your intent, you can define one or more static text responses that will be returned when a user's input matches that particular intent. If you have more than one text response defined, your agent will select responses to return at random (but never use a variation twice in a row) until all responses have been used. We recommend adding several varieties of text responses to make your agent more conversational.
You can also specify that a parameter extracted from the user's input be used in your response. For example, if you had an agent that responded to user's input about their favorite color, you could define a response like "I love
$color too!" If the user says "blue" is their favorite color, the response from the agent will be "I love blue too!" In other words, whatever parameter value the user provides will be referenced in the agent's response.
If you want to return dynamic responses to the user, you must use fulfillment, which is code that is deployed as a webhook and responds to HTTP requests from Dialogflow. Your fulfillment code processes the information from the matched intent and constructs a response to return to the user. More specifically, once user input is parsed, Dialogflow sends the name of the intent that was matched, the values of extracted parameters, and other metadata as a JSON payload in an HTTP
POST request to your webhook. Your webhook constructs a response and sends it as a JSON payload to your Dialogflow agent, which then delivers the response to the user.
To use fulfillment to generate responses, you can either use Dialogflow's built-in inline editor, which allows you to deploy your code to Cloud Functions for Firebase within the Dialogflow console, or set up a webhook separately using your preferred development environment.
We provide a convenient webhook library in Node.js, which you can access here.