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