Class ChatMessage

Chat Message

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 card of the message.
Chat Message Sets the text of the message.

Detailed documentation

add Card With Id(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

Chat Message — This object, for chaining.


set Text(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

Chat Message — This object, for chaining.

Design a Mobile Site
View Site in Mobile | Classic
Share by: