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: تمثّل هذه السمة 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();

المَعلمات

الاسمالنوعالوصف
actionResponseChatActionResponseChatActionResponse المطلوب استخدامه.

الإرجاع

ChatResponseBuilder: هذا العنصر، للتسلسل


setText(text)

تضبط هذه السمة نص رسالة Chat.

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

المَعلمات

الاسمالنوعالوصف
textStringتمثّل هذه السمة النص المطلوب استخدامه.

الإرجاع

ChatResponseBuilder: هذا العنصر، للتسلسل