سازنده برای اشیاء ChatResponse
.
فقط برای برنامههای گپ Google در دسترس است. برای افزونههای 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 | متن پیام چت را تنظیم می کند. |
مستندات دقیق
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)
متن پیام چت را تنظیم می کند.
const chatResponse = CardService.newChatResponseBuilder() .setText('Example text') .build();
مولفه های
نام | تایپ کنید | شرح |
---|---|---|
text | String | متن مورد استفاده |
برگشت
ChatResponseBuilder
- این شی، برای زنجیر کردن.