Class ChatResponseBuilder

כליליצירתתשובות בצ'אט

ה-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

שיטהסוג הערך המוחזרתיאור קצר
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();

פרמטרים

שםסוגתיאור
cardWithIdCardWithIdה-CardWithId לשימוש.

חזרה

ChatResponseBuilder – האובייקט הזה, לצורך קישור.


build()

יצירת התגובה הנוכחית של הפעולה ואימות שלה.

חזרה

ChatResponse – תשובה מאומתת מסוג ChatResponse.


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();

פרמטרים

שםסוגתיאור
actionResponseChatActionResponseה-ChatActionResponse לשימוש.

חזרה

ChatResponseBuilder – האובייקט הזה, לצורך קישור.


setText(text)

הגדרת הטקסט של ההודעה ב-Chat.

const chatResponse =     CardService.newChatResponseBuilder().setText('Example text').build();

פרמטרים

שםסוגתיאור
textStringהטקסט שרוצים להשתמש בו.

חזרה

ChatResponseBuilder – האובייקט הזה, לצורך קישור.