constcard=CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle('card title')).build();// Sets the card of the dialog.constdialog=CardService.newDialog().setBody(card);constdialogAction=CardService.newDialogAction().setDialog(dialog);
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eDialogAction\u003c/code\u003e is a builder for creating interactive dialogs within Google Chat apps.\u003c/p\u003e\n"],["\u003cp\u003eIt allows developers to set the content of the dialog and control its behavior using methods like \u003ccode\u003esetDialog\u003c/code\u003e and \u003ccode\u003esetActionStatus\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThis functionality is exclusive to Google Chat apps and is not available for Google Workspace Add-ons.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDialogAction\u003c/code\u003e uses chaining, meaning methods can be called sequentially to configure the dialog.\u003c/p\u003e\n"]]],["This content describes how to build `DialogAction` objects for Google Chat apps. Key actions involve using `CardService` to create a `DialogAction`, setting its content, and specifying its status. The `setDialog(dialog)` method sets the content of the `DialogAction` using a `Dialog` object, which itself can contain a `Card`. The `setActionStatus(actionStatus)` method sets the action's status using an `ActionStatus` object. Both methods allow chaining.\n"],null,["DialogAction\n\nA builder for [DialogAction](#) objects.\n\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n```javascript\nconst card = CardService.newCardBuilder()\n .setHeader(CardService.newCardHeader().setTitle('Card title'))\n .build();\nconst dialog = CardService.newDialog().setBody(card);\n\nconst dialogAction = CardService.newDialogAction().setDialog(dialog);\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------------------|-------------------|---------------------------------------------|\n| [setActionStatus(actionStatus)](#setActionStatus(ActionStatus)) | [DialogAction](#) | Sets the action status of `Dialog``Action`. |\n| [setDialog(dialog)](#setDialog(Dialog)) | [DialogAction](#) | Sets the dialog of the `Dialog``Action`. |\n\nDetailed documentation \n\n`set``Action``Status(actionStatus)` \nSets the action status of `Dialog``Action`.\n\n```javascript\nconst actionStatus = CardService.newActionStatus().setStatusCode(\n CardService.Status.OK,\n);\n\nconst dialogAction =\n CardService.newDialogAction().setActionStatus(actionStatus);\n```\n\nParameters\n\n| Name | Type | Description |\n|------------------|-------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| `action``Status` | [ActionStatus](/apps-script/reference/card-service/action-status) | The [ActionStatus](/apps-script/reference/card-service/action-status) to use. |\n\nReturn\n\n\n[DialogAction](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n`set``Dialog(dialog)` \nSets the dialog of the `Dialog``Action`.\n\n```javascript\nconst card = CardService.newCardBuilder()\n .setHeader(CardService.newCardHeader().setTitle('card title'))\n .build();\n\n// Sets the card of the dialog.\nconst dialog = CardService.newDialog().setBody(card);\n\nconst dialogAction = CardService.newDialogAction().setDialog(dialog);\n```\n\nParameters\n\n| Name | Type | Description |\n|----------|------------------------------------------------------|------------------------------------------------------------------|\n| `dialog` | [Dialog](/apps-script/reference/card-service/dialog) | The [Dialog](/apps-script/reference/card-service/dialog) to use. |\n\nReturn\n\n\n[DialogAction](#) --- This object, for chaining."]]