Class ChatMessage

ChatMessage

A Google Chat message .

Available for Google Workspace add-ons that extend Google Chat.

 const 
  
 card 
  
 = 
  
 CardService 
 . 
 newCardBuilder 
 () 
  
 . 
 setHeader 
 ( 
 CardService 
 . 
 newCardHeader 
 (). 
 setTitle 
 ( 
 "Card Title" 
 )) 
  
 . 
 addSection 
 ( 
 CardService 
 . 
 newCardSection 
 () 
  
 . 
 addWidget 
 ( 
 CardService 
 . 
 newTextParagraph 
 (). 
 setText 
 ( 
 "Text paragraph" 
 ))) 
  
 . 
 build 
 (); 
 const 
  
 cardWithId 
  
 = 
  
 CardService 
 . 
 newCardWithId 
 (). 
 setCardId 
 ( 
 "card_one" 
 ). 
 setCard 
 ( 
 card 
 ); 
 const 
  
 message 
  
 = 
  
 AddOnsResponseService 
 . 
 newChatMessage 
 (). 
 addCardWithId 
 ( 
 cardWithId 
 ); 

Methods

Method Return type Brief description
Chat Message Sets the accessoryWidget for this action.
Chat Message Sets the card of the message.
Chat Message Sets the text of the message.

Detailed documentation

addAccessoryWidget(accessoryWidget)

Sets the accessoryWidget for this action.

Parameters

Name Type Description
accessory Widget
Accessory Widget The accessoryWidget to set.

Return

ChatMessage — This object, for chaining.


addCardWithId(cardWithId)

Sets the card of the message.

 const 
  
 card 
  
 = 
  
 CardService 
 . 
 newCardBuilder 
 () 
  
 . 
 setHeader 
 ( 
 CardService 
 . 
 newCardHeader 
 () 
 . 
 setTitle 
 ( 
 "Card Title" 
 )) 
  
 . 
 addSection 
 ( 
 CardService 
 . 
 newCardSection 
 () 
  
 . 
 addWidget 
 ( 
 CardService 
 . 
 newTextParagraph 
 () 
 . 
 setText 
 ( 
 "Text paragraph" 
 ))) 
  
 . 
 build 
 (); 
 const 
  
 cardWithId 
  
 = 
  
 CardService 
 . 
 newCardWithId 
 () 
 . 
 setCardId 
 ( 
 "card_one" 
 ) 
 . 
 setCard 
 ( 
 card 
 ); 
 const 
  
 message 
  
 = 
  
 AddOnsResponseService 
 . 
 newChatMessage 
 () 
 . 
 addCardWithId 
 ( 
 cardWithId 
 ); 

Parameters

Name Type Description
card With Id
Card With Id The cardWithId to set.

Return

ChatMessage — This object, for chaining.


setText(text)

Sets the text of the message.

 const 
  
 message 
  
 = 
  
 AddOnsResponseService 
 . 
 newChatMessage 
 () 
 . 
 setText 
 ( 
 "Example text" 
 ); 

Parameters

Name Type Description
text
String The text part of a message.

Return

ChatMessage — This object, for chaining.

Create a Mobile Website
View Site in Mobile | Classic
Share by: