Class ChatActionResponse

ChatActionResponse

這個類別代表 Chat 應用程式可使用的參數,設定回應的發布方式。

僅適用於 Google Chat 應用程式。不適用於 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);

方法

方法傳回類型簡短說明
setDialogAction(dialogAction)ChatActionResponse將對話方塊動作設為與對話方塊相關的事件。
setResponseType(responseType)ChatActionResponseChat 應用程式回應的類型。
setUpdatedWidget(updatedWidget)ChatActionResponse設定更新後的小工具,用來提供小工具的自動完成選項。
setUrl(url)ChatActionResponse供使用者驗證或設定的網址。

內容詳盡的說明文件

setDialogAction(dialogAction)

將對話方塊動作設為與對話方塊相關的事件。

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);

參數

名稱類型說明
dialogActionDialogAction要設定的對話方塊動作。

回攻員

ChatActionResponse:這個物件用於鏈結。


setResponseType(responseType)

Chat 應用程式回應的類型。

const chatActionResponse = CardService.newChatActionResponse()
   .setResponseType(CardService.Type.DIALOG)

參數

名稱類型說明
responseTypeResponseType回應類型。

回攻員

ChatActionResponse:這個物件用於鏈結。


setUpdatedWidget(updatedWidget)

設定更新後的小工具,用來提供小工具的自動完成選項。

const updatedWidget = CardService.newUpdatedWidget()
    .addItem("Contact 1", "contact-1", false,
       "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png",
       "Contact one description")
    .addItem("Contact 2", "contact-2", false,
       "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png",
       "Contact two description")
    .addItem("Contact 3", "contact-3", false,
       "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png",
       "Contact three description")
    .addItem("Contact 4", "contact-4", false,
       "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png",
       "Contact four description")
    .addItem("Contact 5", "contact-5", false,
       "https://www.gstatic.com/images/branding/product/2x/contacts_48dp.png",
       "Contact five description");

const actionResponse = CardService.newChatActionResponse()
    .setUpdatedWidget(updatedWidget)
    .setResponseType(CardService.ResponseType.UPDATE_WIDGET);
僅適用於 Google Chat 應用程式。不適用於 Google Workspace 外掛程式。

參數

名稱類型說明
updatedWidgetUpdatedWidget要設定的更新小工具。

回攻員

ChatActionResponse:這個物件用於鏈結。


setUrl(url)

供使用者驗證或設定的網址。僅適用於 REQUEST_CONFIG 回應類型。

const chatActionResponse = CardService.newChatActionResponse()
   .setResponseType(CardService.Type.REQUEST_CONFIG)
   .setUrl('https://www.google.com');

參數

名稱類型說明
urlString要傳送的網址。

回攻員

ChatActionResponse:這個物件用於鏈結。