Response
Introduction
The response is the data that you send to the platform after processing the request. It consists of information like:
- output, e.g. speech, audio, etc.
- permission requests,
- or session data
Here's an example response:
The main component is the output. Besides the platform independent output, Google Conversational Actions provide multiple other types of output. You can find out more about that in Interfaces section of the documentation.
$response Object
The $response
object supports a handful of cross-platform helper methods to get/set its values. You can find them in the general response docs.
Besides that, Google Assistant supports the following getter methods:
Name | Description | Return Value |
---|---|---|
getBasicCard() |
Returns the response's basic card object. | basic card object or undefined |
hasDisplayText() |
Checks whether the response contains a display text | boolean |
getDisplayText() |
Returns the response's display text. | string or undefined |
hasMediaResponse() |
Checks whether the response contains a media response | boolean |
getMediaResponse() |
Returns the media response object | object or undefined |
hasSuggestionChips(chips?: string[]) |
Returns true if the response contains suggestion chips. If you parse an array of strings, the method will only return true if the suggestion chip's title are equal to the parsed array's values (same order) | boolean |
getSuggestionChips() |
Returns the response's suggestion chips array. | array or undefined |
hasImageCard(title?: string, content?: string, imageUrl?: string) |
Returns true if the response contains an image card. If you parse any of the cards properties, the method will only return true if they are equal to the ones in the response. | boolean |
hasSimpleCard(title?: string, content?: string) |
Returns true if the response contains a simple card. If you parse any of the cards properties, the method will only return true if they are equal to the ones in the response. | boolean |