Chat
nesneleri için bir oluşturucu.
Yalnızca Google Chat uygulamaları için kullanılabilir. Google Workspace eklentilerinde 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 |
---|---|---|
add | Chat | İletinin kart alanını ayarlar. |
build() | Chat | Mevcut işlem yanıtını oluşturur ve doğrular. |
set | Chat | İletinin işlem yanıtı alanını ayarlar. |
set | Chat | Chat mesajının metnini ayarlar. |
Ayrıntılı dokümanlar
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. Card
nesnesi bu yöntemle oluşturulmalı ve 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 |
---|---|---|
card | Card | Kullanılacak Card . |
Return
Chat
: Zincirleme için 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 |
---|---|---|
action | Chat | Kullanılacak Chat . |
Return
Chat
: Zincirleme için 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
Chat
: Zincirleme için bu nesne.