אובייקט builder של ChatResponse.
האפשרות הזו זמינה רק באפליקציות של Google Chat. לא זמין לתוספים של Google Workspace.
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();
Methods
| שיטה | סוג הערך שמוחזר | תיאור קצר |
|---|---|---|
add | Chat | הגדרת שדה הכרטיס של ההודעה. |
build() | Chat | המערכת בונה את התגובה לפעולה הנוכחית ומאמתת אותה. |
set | Chat | הגדרת שדה תגובת הפעולה של ההודעה. |
set | Chat | הגדרת הטקסט של ההודעה ב-Chat. |
תיעוד מפורט
addCardsV2(cardWithId)
הגדרת שדה הכרטיס של ההודעה. האפשרות הזו משמשת לשליחת כרטיס בהודעה ב-Google Chat. כל כרטיס משויך למזהה ייחודי, CardWithId צריך ליצור אובייקט ולהשתמש בו עם השיטה הזו.
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();
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
card | Card | ה-Card שבו רוצים להשתמש. |
חזרה
ChatResponseBuilder – האובייקט הזה, לשרשור.
build()
setActionResponse(actionResponse)
הגדרת שדה תגובת הפעולה של ההודעה.
// 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();
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
action | Chat | ה-Chat שבו רוצים להשתמש. |
חזרה
ChatResponseBuilder – האובייקט הזה, לשרשור.
setText(text)
הגדרת הטקסט של ההודעה ב-Chat.
const chatResponse = CardService.newChatResponseBuilder().setText('Example text').build();
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
text | String | הטקסט שבו רוצים להשתמש. |
חזרה
ChatResponseBuilder – האובייקט הזה, לשרשור.