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