Class ChatActionResponse

ChatActionResponse

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

Chỉ dành cho các ứ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ứcKiểu dữ liệu trả vềMô tả ngắn
setDialogAction(dialogAction)ChatActionResponseĐặt thao tác trên 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 Chat.
setUpdatedWidget(updatedWidget)ChatActionResponseĐặt tiện ích đã cập nhật, dùng để cung cấp các lựa 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 trên 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ả
dialogActionDialogActionThao tác hộp thoại cần đặt.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này, để liên kết.


setResponseType(responseType)

Loại phản hồi của ứng dụng 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, để liên kết.


setUpdatedWidget(updatedWidget)

Đặt tiện ích đã cập nhật, dùng để cung cấp các lựa 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ành cho các ứ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 sẽ được đặt.

Cầu thủ trả bóng

ChatActionResponse – Đối tượng này, để liên kết.


setUrl(url)

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

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, để liên kết.