ChatResponse nesneleri için bir 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 |
|---|---|---|
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ı belgeler
addCardsV2(cardWithId)
İletinin kart alanını ayarlar. Bu izin, 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 |
|---|---|---|
card | Card | Kullanılacak Card. |
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 |
|---|---|---|
action | Chat | Kullanılacak Chat. |
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.