Class ChatResponseBuilder

ChatResponseBuilder

أداة إنشاء لعناصر 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: هذا الكائن، للتسلسل.