Intents have a built-in response handler that can return responses after the intent is matched. This feature only supports static responses, though you can use parameter references in these responses to make them somewhat dynamic. This is helpful for recapping information provided by the end-user. For example, your intent response could look like: "Okay, I booked a room for you on $date".
In some cases, this is all you need. In cases where your code needs to take some action or build a more dynamic response, you should use one of the dynamic response options below. Agents typically use a combination of static and dynamic responses.
Multiple types of responses can be provided. The basic response type is a text response. Other types of responses are available (image, audio, synthesized speech, and so on), some of which are platform-specific.
If you define more than one response variation for an intent, your agent will select a response at random. You should add several response variations to make your agent more conversational.
When building an agent, you should provide response data for each intent. When you use the API or fulfillment to interact with Dialogflow, you technically may not need to provide response data, because both of these methods can dynamically generate any response. However, if you want to use the simulator for testing or define intents that have a simple response, you should provide response data.
As a general rule, your intent responses should prompt the end-user to provide an expression that will match another intent. Your responses should also guide the end-user to provide specific data. For example, a question like "What city were you born in?" is better than a more open-ended question like "Where were you born?".
Where to find this data
When building an agent, it is most common to use the Dialogflow ES console (visit documentation, open console). The instructions below focus on using the console. To access intent response data:
- Go to the Dialogflow ES console.
- Select an agent.
- Select Intents in the left sidebar menu.
- Select an intent.
- Scroll down to the Responses section.
If you are building an agent using the API instead of the console, see the Intents reference. The API field names are similar to the console field names. The instructions below highlight any important differences between the console and the API.
Response platforms
Each response is defined for either the Default platform
(referred to as PLATFORM_UNSPECIFIED
in the API) or a specific
integration platform.
If you are not using an integration,
all of your responses can use the default platform.
If you are using integrations,
each integration can have a unique response,
or it can be configured to use the default response.
For more information on platform-specific responses, see Rich response messages.
Create built-in responses
To create built-in responses:
- Select Default or a specific platform.
- If the desired type of response (for example, Text response) is not already listed, click Add Responses and select the response type.
- Enter required information for the response.
- Click Save.
Dynamic responses with fulfillment
Using fulfillment, you can create dynamic responses. See the fulfillment documents for more information.
Dynamic responses with the API
Using the API, you can create dynamic responses. See the API overview for more information.
Special characters
Some special characters require escaping in your response.
To use the dollar sign $
or the number sign #
in a response,
add braces {}
around the content that immediately follows the sign.
For example:
${100}
resolves to$100
${$number}
resolves to$100
, where$number
is a parameter reference with a value of 100#{hello}
resolves to#hello
To use braces {}
in a response,
use double braces.
For example:
{{hello}}
resolves to{hello}
Handling empty parameter values
If your intent has a parameter that can resolve to an empty value, you must provide at least one response variant that does not use that parameter.
For example, if your intent has 2 parameters (p1
and p2
),
and either or both could be empty,
you should provide at least four response variants:
- Got it. You said $p1 and $p2.
- Got it. You said $p1.
- Got it. You said $p2.
- Got it.