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चैट मैसेज का टेक्स्ट सेट करता है.

ज़्यादा जानकारी वाला दस्तावेज़

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();

पैरामीटर

नामटाइपब्यौरा
cardWithIdCardWithIdइस्तेमाल करने के लिए CardWithId.

रिटर्न

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();

पैरामीटर

नामटाइपब्यौरा
actionResponseChatActionResponseइस्तेमाल करने के लिए ChatActionResponse.

रिटर्न

ChatResponseBuilder — यह ऑब्जेक्ट, चेन बनाने के लिए है.


setText(text)

चैट मैसेज का टेक्स्ट सेट करता है.

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

पैरामीटर

नामटाइपब्यौरा
textStringइस्तेमाल करने के लिए टेक्स्ट.

रिटर्न

ChatResponseBuilder — यह ऑब्जेक्ट, चेन बनाने के लिए है.