Class ChatResponseBuilder

ChatResponseBuilder

ChatResponse nesne için oluşturucu.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const cardSection = CardService.newCardSection();
cardSection.addWidget(
    CardService.newTextParagraph().setText('This is a text paragraph widget.'));

const card = CardService.newCardBuilder()
    .setName('Card name')
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCardId('card_id')
    .setCard(card);

const chatResponse = CardService.newChatResponseBuilder()
       .addCardsV2(cardWithId)
       .setText('Example text')
    .build();

Yöntemler

YöntemDönüş türüKısa açıklama
addCardsV2(cardWithId)ChatResponseBuilderİletinin kart alanını ayarlar.
build()ChatResponseGeçerli işlem yanıtını oluşturur ve doğrular.
setActionResponse(actionResponse)ChatResponseBuilderİletinin işlem yanıtı alanını ayarlar.
setText(text)ChatResponseBuilderChat mesajının metnini ayarlar.

Ayrıntılı belgeler

addCardsV2(cardWithId)

İletinin kart alanını ayarlar. Bu, Google Chat mesajında kart göndermek için kullanılır. Her kart benzersiz bir kimlikle ilişkilendirilir. CardWithId nesnesi oluşturulmalı ve bu yöntemle kullanılmalıdır.

const cardSection = CardService.newCardSection();
cardSection.addWidget(
    CardService.newTextParagraph().setText('This is a text paragraph widget.'));

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCardId('card_id')
    .setCard(card);

const chatResponse = CardService.newChatResponseBuilder()
    .addCardsV2(cardWithId)
    .build();

Parametreler

AdTürAçıklama
cardWithIdCardWithIdKullanılacak CardWithId.

Return

ChatResponseBuilder: Zincirleme için kullanılan bu nesne.


build()

Geçerli işlem yanıtını oluşturur ve doğrular.

Return

ChatResponse — Doğrulanmış bir ChatYanıtı.


setActionResponse(actionResponse)

İletinin işlem yanıtı alanını ayarlar.

// Build the card.
const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('card title')).build();

// Creates the dialog.
const dialog = CardService.newDialog()
    .setBody(card);

// Creates the dialog action.
const dialogAction = CardService.newDialogAction()
   .setDialog(dialog)

// Creates the action response and sets the type to DIALOG.
const actionResponse = CardService.newChatActionResponse()
       .setDialogAction(dialogAction).setResponseType(CardService.Type.DIALOG);

// Creates the Chat response and sets the action response.
const chatResponse = CardService.newChatResponseBuilder()
       .setActionResponse(actionResponse)
    .build();

Parametreler

AdTürAçıklama
actionResponseChatActionResponseKullanılacak ChatActionResponse.

Return

ChatResponseBuilder: Zincirleme için kullanılan bu nesne.


setText(text)

Chat mesajının metnini ayarlar.

const chatResponse = CardService.newChatResponseBuilder()
       .setText('Example text')
    .build();

Parametreler

AdTürAçıklama
textStringKullanılacak metin.

Return

ChatResponseBuilder: Zincirleme için kullanılan bu nesne.