Class ChatActionResponse
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
ChatAzioneRisposta
Una classe che rappresenta i parametri che un'app di chat può utilizzare per configurare il modo in cui viene pubblicata la sua risposta.
Disponibile solo per le app Google Chat. Non disponibile per i componenti aggiuntivi di Google Workspace.
const card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Card title'))
.build();
const dialog = CardService.newDialog().setBody(card);
const dialogAction = CardService.newDialogAction().setDialog(dialog);
const chatActionResponse = CardService.newChatActionResponse()
.setResponseType(CardService.Type.DIALOG)
.setDialogAction(dialogAction);
Documentazione dettagliata
setDialogAction(dialogAction)
Imposta l'azione di dialogo su un evento correlato a una finestra di dialogo.
const card = CardService.newCardBuilder()
.setHeader(CardService.newCardHeader().setTitle('Card title'))
.build();
const dialog = CardService.newDialog().setBody(card);
const dialogAction = CardService.newDialogAction().setDialog(dialog);
const chatActionResponse = CardService.newChatActionResponse()
.setResponseType(CardService.Type.DIALOG)
.setDialogAction(dialogAction);
Parametri
Nome | Tipo | Descrizione |
dialogAction | DialogAction | L'azione della finestra di dialogo da impostare. |
Invio
ChatActionResponse
: questo oggetto, per l'accodamento.
setResponseType(responseType)
Il tipo di risposta dell'app Chat.
const chatActionResponse = CardService.newChatActionResponse().setResponseType(
CardService.Type.DIALOG,
);
Parametri
Nome | Tipo | Descrizione |
responseType | ResponseType | Il tipo di risposta. |
Invio
ChatActionResponse
: questo oggetto, per l'accodamento.
setUrl(url)
L'URL per l'autenticazione o la configurazione degli utenti. Solo per il tipo di risposta REQUEST_CONFIG
.
const chatActionResponse = CardService.newChatActionResponse()
.setResponseType(CardService.Type.REQUEST_CONFIG)
.setUrl('https://www.google.com');
Parametri
Nome | Tipo | Descrizione |
url | String | L'URL da inviare. |
Invio
ChatActionResponse
: questo oggetto, per l'accodamento.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eChatActionResponse\u003c/code\u003e allows Google Chat apps to configure how their responses are displayed, including dialogs, widgets, and URLs.\u003c/p\u003e\n"],["\u003cp\u003eThis class provides methods like \u003ccode\u003esetDialogAction\u003c/code\u003e, \u003ccode\u003esetResponseType\u003c/code\u003e, \u003ccode\u003esetUpdatedWidget\u003c/code\u003e, and \u003ccode\u003esetUrl\u003c/code\u003e to customize the response behavior.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eChatActionResponse\u003c/code\u003e is exclusively for Google Chat apps and is not supported in Google Workspace Add-ons.\u003c/p\u003e\n"],["\u003cp\u003eEach method within \u003ccode\u003eChatActionResponse\u003c/code\u003e returns the object itself, enabling method chaining for streamlined configuration.\u003c/p\u003e\n"]]],["The `ChatActionResponse` class configures how a Chat app's response is posted, specifically for Google Chat apps. Key actions include setting the response type, which can be a dialog, updating a widget, or requesting configuration. The `setDialogAction` method links an event to a dialog. `setUpdatedWidget` provides autocomplete options, while `setUrl` directs users to a specific URL, mainly for authentication or configuration requests. Each method returns a `ChatActionResponse` object, enabling method chaining.\n"],null,["# Class ChatActionResponse\n\nChatActionResponse\n\nA class that represents the parameters that a Chat app can use to configure how its response is\nposted.\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\nconst chatActionResponse = CardService.newChatActionResponse()\n .setResponseType(CardService.Type.DIALOG)\n .setDialogAction(dialogAction);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------------|-------------------------|-----------------------------------------------------------------------------|\n| [setDialogAction(dialogAction)](#setDialogAction(DialogAction)) | [ChatActionResponse](#) | Sets the dialog action to an event related to a dialog. |\n| [setResponseType(responseType)](#setResponseType(ResponseType)) | [ChatActionResponse](#) | The type of Chat app response. |\n| [setUpdatedWidget(updatedWidget)](#setUpdatedWidget(UpdatedWidget)) | [ChatActionResponse](#) | Sets the updated widget, used to provide autocomplete options for a widget. |\n| [setUrl(url)](#setUrl(String)) | [ChatActionResponse](#) | The URL for users to authenticate or configure. |\n\nDetailed documentation\n----------------------\n\n### `set``Dialog``Action(dialogAction)`\n\nSets the dialog action to an event related to a dialog.\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\nconst chatActionResponse = CardService.newChatActionResponse()\n .setResponseType(CardService.Type.DIALOG)\n .setDialogAction(dialogAction);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------|-------------------------------------------------------------------|---------------------------|\n| `dialog``Action` | [DialogAction](/apps-script/reference/card-service/dialog-action) | The dialog action to set. |\n\n#### Return\n\n\n[ChatActionResponse](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Response``Type(responseType)`\n\nThe type of Chat app response.\n\n```javascript\nconst chatActionResponse = CardService.newChatActionResponse().setResponseType(\n CardService.Type.DIALOG,\n);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------|-------------------------------------------------------------------|--------------------|\n| `response``Type` | [ResponseType](/apps-script/reference/card-service/response-type) | The response type. |\n\n#### Return\n\n\n[ChatActionResponse](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Updated``Widget(updatedWidget)`\n\nSets the updated widget, used to provide autocomplete options for a widget.\n\n```javascript\nconst updatedWidget =\n CardService.newUpdatedWidget()\n .addItem(\n 'Contact 1',\n 'contact-1',\n false,\n 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',\n 'Contact one description',\n )\n .addItem(\n 'Contact 2',\n 'contact-2',\n false,\n 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',\n 'Contact two description',\n )\n .addItem(\n 'Contact 3',\n 'contact-3',\n false,\n 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',\n 'Contact three description',\n )\n .addItem(\n 'Contact 4',\n 'contact-4',\n false,\n 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',\n 'Contact four description',\n )\n .addItem(\n 'Contact 5',\n 'contact-5',\n false,\n 'https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png',\n 'Contact five description',\n );\n\nconst actionResponse =\n CardService.newChatActionResponse()\n .setUpdatedWidget(updatedWidget)\n .setResponseType(CardService.ResponseType.UPDATE_WIDGET);\n```\nOnly available for Google Chat apps. Not available for Google Workspace add-ons.\n\n#### Parameters\n\n| Name | Type | Description |\n|-------------------|---------------------------------------------------------------------|-------------------------------|\n| `updated``Widget` | [UpdatedWidget](/apps-script/reference/card-service/updated-widget) | The updated widget to be set. |\n\n#### Return\n\n\n[ChatActionResponse](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Url(url)`\n\nThe URL for users to authenticate or configure. Only for the `REQUEST_CONFIG` response\ntype.\n\n```javascript\nconst chatActionResponse = CardService.newChatActionResponse()\n .setResponseType(CardService.Type.REQUEST_CONFIG)\n .setUrl('https://www.google.com');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|----------|------------------|\n| `url` | `String` | The URL to send. |\n\n#### Return\n\n\n[ChatActionResponse](#) --- This object, for chaining."]]