Class ChatResponseBuilder

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

שיטות

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

פרמטרים

שםסוגתיאור
cardWithIdCardWithIdCardWithId שבו צריך להשתמש.

החזרות

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


build()

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

החזרות

ChatResponse – תשובה מאומתת ל-Chat.


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

פרמטרים

שםסוגתיאור
actionResponseChatActionResponseChatActionResponse שבו צריך להשתמש.

החזרות

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


setText(text)

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

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

פרמטרים

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

החזרות

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