Class UniversalActionResponse
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
通用動作回應
回應物件,可能會從建立通用動作的方法傳回。
// A universal action that opens a link.
const openLinkUniversalAction =
CardService.newUniversalActionResponseBuilder()
.setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com'))
.build();
const cardBuilder1 = CardService.newCardBuilder();
const cardBuilder2 = CardService.newCardBuilder();
// Finish building the cards ...
// A universal action that shows two static cards.
const cardsUniversalAction =
CardService.newUniversalActionResponseBuilder()
.displayAddOnCards([cardBuilder1.build(), cardBuilder2.build()])
.build();
內容詳盡的說明文件
printJson()
列印此物件的 JSON 表示法。這項設定僅供偵錯。
回攻員
String
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eUniversalActionResponse\u003c/code\u003e objects are returned from methods creating universal actions, like opening links or displaying cards.\u003c/p\u003e\n"],["\u003cp\u003eThese objects can define actions like opening a web link using \u003ccode\u003esetOpenLink()\u003c/code\u003e or showing cards using \u003ccode\u003edisplayAddOnCards()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eFor debugging, the \u003ccode\u003eprintJson()\u003c/code\u003e method outputs the object's JSON representation as a string.\u003c/p\u003e\n"]]],["The `UniversalActionResponse` object is used to define actions within a card-based interface. Key actions include using the `setOpenLink` method to open a URL and `displayAddOnCards` to display multiple static cards. `printJson()` is a method for debugging, that returns the JSON representation of the object as a string. These methods are used within the `UniversalActionResponseBuilder` to create the object.\n"],null,["# Class UniversalActionResponse\n\nUniversalActionResponse\n\nThe response object that may be returned from a method that creates universal action.\n\n```javascript\n// A universal action that opens a link.\nconst openLinkUniversalAction =\n CardService.newUniversalActionResponseBuilder()\n .setOpenLink(CardService.newOpenLink().setUrl('https://www.google.com'))\n .build();\n\nconst cardBuilder1 = CardService.newCardBuilder();\nconst cardBuilder2 = CardService.newCardBuilder();\n// Finish building the cards ...\n\n// A universal action that shows two static cards.\nconst cardsUniversalAction =\n CardService.newUniversalActionResponseBuilder()\n .displayAddOnCards([cardBuilder1.build(), cardBuilder2.build()])\n .build();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------|-------------|------------------------------------------------|\n| [printJson()](#printJson()) | `String` | Prints the JSON representation of this object. |\n\nDetailed documentation\n----------------------\n\n### `print``Json()`\n\nPrints the JSON representation of this object. This is for debugging only.\n\n#### Return\n\n\n`String`"]]