أداة إنشاء لعناصر 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();
الطُرق
| الطريقة | نوع القيمة التي تم إرجاعها | وصف قصير |
|---|---|---|
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()
تنشئ هذه السمة ردّ الإجراء الحالي وتتحقّق من صحته.
الإرجاع
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();
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
action | Chat | Chat المطلوب استخدامه. |
الإرجاع
ChatResponseBuilder: هذا العنصر، للتسلسل
setText(text)
تضبط هذه السمة نص رسالة Chat.
const chatResponse = CardService.newChatResponseBuilder().setText('Example text').build();
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
text | String | تمثّل هذه السمة النص المطلوب استخدامه. |
الإرجاع
ChatResponseBuilder: هذا العنصر، للتسلسل