Navigation

A helper object that controls card navigation. See the [card navigation guide](https://developers.google.com/workspace/add-ons/how-tos/navigation) for more details.

Sample usage:

```javascript
function myFunction() {
  return AddOnsResponseService.newChatDataActionBuilder();
}
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#popCard()` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | > [!WARNING] > **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#popToNamedCard(String)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | > [!WARNING] > **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#popToRoot()` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | > [!WARNING] > **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#printJson()` | `String` | Prints the JSON representation of this object. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#pushCard(Card)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | Pushes the given card onto the stack. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#setEndNavigation(EndNavigation)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | Sets the end navigation action. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#updateCard(Card)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` | Does an in-place replacement of the current card. |

## Detailed documentation

### `popCard()`


> [!WARNING]
> **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.

<br />

Available for Google Workspace add-ons that extend Google Chat.

Pops a card from the navigation stack. Can be chained with other card navigation actions.

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.

*** ** * ** ***

### `popToNamedCard(cardName)`


> [!WARNING]
> **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.

<br />

Available for Google Workspace add-ons that extend Google Chat.

Pops to the specified card by its card name. Can be chained with other card navigation
actions.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `cardName` | `String` | The name of the card to navigate to. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.

*** ** * ** ***

### `popToRoot()`


> [!WARNING]
> **Developer Preview:** Available as part of the [Google Workspace Developer Preview Program](https://developers.google.com/workspace/preview), which grants early access to certain features.

<br />

Available for Google Workspace add-ons that extend Google Chat.

Pops the card stack to the root card. Can be chained with other card navigation actions.

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.

*** ** * ** ***

### `printJson()`

Prints the JSON representation of this object. This is for debugging only.

#### Return


`String`

*** ** * ** ***

### `pushCard(card)`

Pushes the given card onto the stack. Can be chained with other card navigation actions.

```javascript
const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const navigation = AddOnsResponseService.newNavigation()
    .pushCard(card);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `card` | `https://developers.google.com/apps-script/reference/card-service/card.html` | A card to add to the stack. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.

*** ** * ** ***

### `setEndNavigation(endNavigation)`

Sets the end navigation action.

```javascript
const navigation = AddOnsResponseService.newNavigation()
    .setEndNavigation(AddOnsResponseService.EndNavigation.CLOSE_DIALOG);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `endNavigation` | `https://developers.google.com/apps-script/reference/add-ons-response-service/end-navigation` | The `https://developers.google.com/apps-script/reference/add-ons-response-service/end-navigation` to use. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.

*** ** * ** ***

### `updateCard(card)`

Does an in-place replacement of the current card. Can be chained with other card navigation
actions.

```javascript
const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const navigation = AddOnsResponseService.newNavigation()
    .updateCard(card);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `card` | `https://developers.google.com/apps-script/reference/card-service/card.html` | A card to replace the current card with. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/navigation#` --- This object, for chaining.