<commit_before># Google Assistant Output

Learn more about output templates for Google Assistant.
- [Introduction](#introduction)
- [Generic Output Elements](#generic-output-elements)
  - [Message](#message)
  - [Reprompt](#reprompt)
  - [Listen](#listen)
  - [Quick Replies (Suggestions)](#quick-replies-suggestions)
  - [Card](#card)
  - [Carousel (Collection Browse)](#carousel-collection-browse)
- [Google Assistant-specific Output Elements](#google-assistant-specific-output-elements)
  - [Native Response](#native-response)


## Introduction

Jovo offers the ability to [create structured output](https://github.com/jovotech/jovo-framework/blob/v4dev/docs/routing.md) that is then translated into native platform responses.

This structured output is called [output template](https://github.com/jovotech/jovo-output/blob/master/docs/output-templates.md). Its root properties are generic output elements that work across platforms. [Learn more about how generic output is translated into a Google Assistant response below](#generic-output-elements).

```typescript
{
  message: `Hello world! What's your name?`,
  reprompt: 'Could you tell me your name?',
  listen: true,
}
```

You can also add platform-specific output to an output template. [Learn more about Google Assistant-specific output below](#google-assistant-specific-output-elements).

```typescript
{
  // ...
  platforms: {
    GoogleAssistant: {
      // ...
    }
  }
}
```


## Generic Output Elements

Generic output elements are in the root of the output template and work across platforms. [Learn more in the Jovo Output docs](https://github.com/jovotech/jovo-output/blob/master/docs/output-templates.md).

Below, you can find a list of generic output elements that work with Google Assistant.

### Message

The `message` is what Google Assistant is saying (or displaying) to the user:

```typescript
{
  message: 'Hello world!',
}
```

Under the hood, Jovo translates the `message` into a `firstSimple` response object ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-simple?hl=en)):

```json
{
  "prompt": {
    "firstSimple": {
      "speech": "Hello world!"
    }
  }
}
```

It's also possible to add a `displayText` property:

```typescript
{
  message: {
    text: 'Speech hello world!',
    displayText: 'Display hello world!'
  },
}
```

This is then turned into the following response:

```json
{
  "prompt": {
    "firstSimple": {
      "speech": "Speech hello world!",
      "text": "Display hello world!"
    }
  }
}
```

### Reprompt

If Google Assistant asks a question and the user does not respond after a few seconds, it will state a `reprompt` to ask again:

```typescript
{
  message: `Hello world! What's your name?`,
  reprompt: 'Could you tell me your name?',
  listen: true,
}
```

Under the hood, Jovo translates the `reprompt` into `NO_INPUT_1`, `NO_INPUT_2`, and `NO_INPUT_FINAL`.

**Note**: For Google Assistant to wait for a user to answer a question, the [listen property](#listen) needs to be added.

### Listen

The `listen` property needs to be added to tell Google Assistant that it should keep the microphone open and wait for a user's response.

```typescript
{
  listen: true,
}
```

If `listen` is not set to `true`, Jovo transitions to the `actions.scene.END_CONVERSATION` under the hood.

### Quick Replies (Suggestions)

On Google Assistant, quick replies are called suggestions. [You can learn more in the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts?hl=en#suggestions).

```typescript
{
  // ...
  quickReplies: [ 'Yes', 'No' ]
}
```

### Card

You can display a basic card ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-rich?hl=en)) by using the `card` property:

```typescript
{
  // ...
  card: {
    title: 'Hello world!',
    content: 'Welcome to this new app built with Jovo.'
  },
}
```

### Carousel (Collection Browse)

You can display a collection browse element ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-selection?hl=en)) by using the `carousel` property:

```typescript
{<commit_msg>📝 Change collection browse to collection<commit_after># Google Assistant Output

Learn more about output templates for Google Assistant.
- [Introduction](#introduction)
- [Generic Output Elements](#generic-output-elements)
  - [Message](#message)
  - [Reprompt](#reprompt)
  - [Listen](#listen)
  - [Quick Replies (Suggestions)](#quick-replies-suggestions)
  - [Card](#card)
  - [Carousel (Collection)](#carousel-collection)
- [Google Assistant-specific Output Elements](#google-assistant-specific-output-elements)
  - [Native Response](#native-response)


## Introduction

Jovo offers the ability to [create structured output](https://github.com/jovotech/jovo-framework/blob/v4dev/docs/routing.md) that is then translated into native platform responses.

This structured output is called [output template](https://github.com/jovotech/jovo-output/blob/master/docs/output-templates.md). Its root properties are generic output elements that work across platforms. [Learn more about how generic output is translated into a Google Assistant response below](#generic-output-elements).

```typescript
{
  message: `Hello world! What's your name?`,
  reprompt: 'Could you tell me your name?',
  listen: true,
}
```

You can also add platform-specific output to an output template. [Learn more about Google Assistant-specific output below](#google-assistant-specific-output-elements).

```typescript
{
  // ...
  platforms: {
    GoogleAssistant: {
      // ...
    }
  }
}
```


## Generic Output Elements

Generic output elements are in the root of the output template and work across platforms. [Learn more in the Jovo Output docs](https://github.com/jovotech/jovo-output/blob/master/docs/output-templates.md).

Below, you can find a list of generic output elements that work with Google Assistant.

### Message

The `message` is what Google Assistant is saying (or displaying) to the user:

```typescript
{
  message: 'Hello world!',
}
```

Under the hood, Jovo translates the `message` into a `firstSimple` response object ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-simple?hl=en)):

```json
{
  "prompt": {
    "firstSimple": {
      "speech": "Hello world!"
    }
  }
}
```

It's also possible to add a `displayText` property:

```typescript
{
  message: {
    text: 'Speech hello world!',
    displayText: 'Display hello world!'
  },
}
```

This is then turned into the following response:

```json
{
  "prompt": {
    "firstSimple": {
      "speech": "Speech hello world!",
      "text": "Display hello world!"
    }
  }
}
```

### Reprompt

If Google Assistant asks a question and the user does not respond after a few seconds, it will state a `reprompt` to ask again:

```typescript
{
  message: `Hello world! What's your name?`,
  reprompt: 'Could you tell me your name?',
  listen: true,
}
```

Under the hood, Jovo translates the `reprompt` into `NO_INPUT_1`, `NO_INPUT_2`, and `NO_INPUT_FINAL`.

**Note**: For Google Assistant to wait for a user to answer a question, the [listen property](#listen) needs to be added.

### Listen

The `listen` property needs to be added to tell Google Assistant that it should keep the microphone open and wait for a user's response.

```typescript
{
  listen: true,
}
```

If `listen` is not set to `true`, Jovo transitions to the `actions.scene.END_CONVERSATION` under the hood.

### Quick Replies (Suggestions)

On Google Assistant, quick replies are called suggestions. [You can learn more in the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts?hl=en#suggestions).

```typescript
{
  // ...
  quickReplies: [ 'Yes', 'No' ]
}
```

### Card

You can display a basic card ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-rich?hl=en)) by using the `card` property:

```typescript
{
  // ...
  card: {
    title: 'Hello world!',
    content: 'Welcome to this new app built with Jovo.'
  },
}
```

### Carousel (Collection)

You can display a collection ([see the official Google Assistant docs](https://developers.google.com/assistant/conversational/prompts-selection?hl=en)) by using the `carousel` property:

```typescript
{
{'fraction_non_alphanumeric': 0.12657928917227534, 'fraction_numerical': 0.0007084661707403471, 'mean_word_length': 4.283842794759825, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '646813', 'n_tokens_mistral': 2615, 'n_tokens_neox': 2452, 'n_words': 863}