Class ChatActionResponse

ChatActionResponse

Một lớp đại diện cho các tham số mà một ứng dụng Chat có thể dùng để định cấu hình cách phản hồi của ứng dụng đã đăng.

Chỉ dùng được cho ứng dụng Google Chat. Không dùng được cho các Tiện ích bổ sung của 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);

Phương thức

Phương thứcLoại dữ liệu trả vềMô tả ngắn
setDialogAction(dialogAction)ChatActionResponseĐặt thao tác của hộp thoại thành một sự kiện liên quan đến hộp thoại.
setResponseType(responseType)ChatActionResponseLoại phản hồi của ứng dụng trong Chat.
setUpdatedWidget(updatedWidget)ChatActionResponseĐặt tiện ích đã cập nhật, dùng để cung cấp các tuỳ chọn tự động hoàn thành cho một tiện ích.
setUrl(url)ChatActionResponseURL để người dùng xác thực hoặc định cấu hình.

Tài liệu chi tiết

setDialogAction(dialogAction)

Đặt thao tác của hộp thoại thành một sự kiện liên quan đến hộp thoại.

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

Tham số

TênLoạiMô tả
dialogActionDialogActionHành động hộp thoại cần đặt.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này để tạo chuỗi.


setResponseType(responseType)

Loại phản hồi của ứng dụng trong Chat.

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

Tham số

TênLoạiMô tả
responseTypeResponseTypeLoại phản hồi.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này để tạo chuỗi.


setUpdatedWidget(updatedWidget)

Đặt tiện ích đã cập nhật, dùng để cung cấp các tuỳ chọn tự động hoàn thành cho một tiện ích.

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);
Chỉ dùng được cho ứng dụng Google Chat. Không dùng được cho các Tiện ích bổ sung của Google Workspace.

Tham số

TênLoạiMô tả
updatedWidgetUpdatedWidgetTiện ích đã cập nhật cần đặt.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này để tạo chuỗi.


setUrl(url)

URL để người dùng xác thực hoặc định cấu hình. Chỉ dành cho phản hồi REQUEST_CONFIG loại.

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

Tham số

TênLoạiMô tả
urlStringURL cần gửi.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này để tạo chuỗi.