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öntem | Dönüş türü | Kısa açıklama |
---|---|---|
addCardsV2(cardWithId) | ChatResponseBuilder | İletinin kart alanını ayarlar. |
build() | ChatResponse | Geçerli işlem yanıtını oluşturur ve doğrular. |
setActionResponse(actionResponse) | ChatResponseBuilder | İletinin işlem yanıtı alanını ayarlar. |
setText(text) | ChatResponseBuilder | Chat 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
Ad | Tür | Açıklama |
---|---|---|
cardWithId | CardWithId | Kullanılacak CardWithId . |
Return
ChatResponseBuilder
: Zincirleme için kullanılan bu nesne.
build()
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
Ad | Tür | Açıklama |
---|---|---|
actionResponse | ChatActionResponse | Kullanı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
Ad | Tür | Açıklama |
---|---|---|
text | String | Kullanılacak metin. |
Return
ChatResponseBuilder
: Zincirleme için kullanılan bu nesne.