@@ -91,41 +91,47 @@ function createMessageAppCred() {
91
91
// TODO(developer): Replace SPACE_NAME here.
92
92
const parent = 'spaces/SPACE_NAME' ;
93
93
const message = {
94
- text : 'Hello with app credential!'
95
- } ;
96
- const parameters = { } ;
97
-
98
- // Make the request
99
- const response = Chat . Spaces . Messages . create (
100
- message , parent , parameters , getHeaderWithAppCredentials ( )
101
- ) ;
102
-
103
- // Handle the response
104
- console . log ( response ) ;
105
- }
106
- // [END chat_create_message_app_cred]
107
-
108
- // [START chat_create_message_app_cred_with_cards]
109
- /**
110
- * This sample shows how to create message with a card attached with app credential
111
- *
112
- * It relies on the OAuth2 scope 'https://www.googleapis.com/auth/chat.bot'
113
- * used by service accounts.
114
- */
115
- function createMessageAppCredWithCards ( ) {
116
- // Initialize request argument(s)
117
- // TODO(developer): Replace SPACE_NAME here.
118
- const parent = 'spaces/SPACE_NAME' ;
119
- const message = {
120
- text : 'Hello with app credential!' ,
121
- cardsV2 : [ {
122
- cardId : 'card-id' ,
123
- card : {
124
- header : {
125
- title : 'And with a card!' ,
94
+ text : '👋🌎 Hello world! I created this message by calling ' +
95
+ 'the Chat API\'s `messages.create()` method.' ,
96
+ cardsV2 : [ { card : {
97
+ header : {
98
+ title : 'About this message' ,
99
+ imageUrl : 'https://fonts.gstatic.com/s/i/short-term/release/googlesymbols/info/default/24px.svg'
100
+ } ,
101
+ sections : [ {
102
+ header : 'Contents' ,
103
+ widgets : [ { textParagraph : {
104
+ text : '🔡 <b>Text</b> which can include ' +
105
+ 'hyperlinks 🔗, emojis 😄🎉, and @mentions 🗣️.'
106
+ } } , { textParagraph : {
107
+ text : '🖼️ A <b>card</b> to display visual elements' +
108
+ 'and request information such as text 🔤, ' +
109
+ 'dates and times 📅, and selections ☑️.'
110
+ } } , { textParagraph : {
111
+ text : '👉🔘 An <b>accessory widget</b> which adds ' +
112
+ 'a button to the bottom of a message.'
113
+ } }
114
+ ] } , {
115
+ header : "What's next" ,
116
+ collapsible : true ,
117
+ widgets : [ { textParagraph : {
118
+ text : "❤️ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages.reactions/create'>Add a reaction</a>."
119
+ } } , { textParagraph : {
120
+ text : "🔄 <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/patch'>Update</a> " +
121
+ "or ❌ <a href='https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages/delete'>delete</a> " +
122
+ "the message."
123
+ }
124
+ } ]
126
125
}
127
- }
128
- } ]
126
+ ]
127
+ } } ] ,
128
+ accessoryWidgets : [ { buttonList : { buttons : [ {
129
+ text : 'View documentation' ,
130
+ icon : { materialIcon : { name : 'link' } } ,
131
+ onClick : { openLink : {
132
+ url : 'https://developers.google.com/workspace/chat/create-messages'
133
+ } }
134
+ } ] } } ]
129
135
} ;
130
136
const parameters = { } ;
131
137
@@ -137,7 +143,7 @@ function createMessageAppCredWithCards() {
137
143
// Handle the response
138
144
console . log ( response ) ;
139
145
}
140
- // [END chat_create_message_app_cred_with_cards ]
146
+ // [END chat_create_message_app_cred ]
141
147
142
148
// [START chat_create_message_user_cred]
143
149
/**
@@ -151,7 +157,14 @@ function createMessageUserCred() {
151
157
// TODO(developer): Replace SPACE_NAME here.
152
158
const parent = 'spaces/SPACE_NAME' ;
153
159
const message = {
154
- text : 'Hello with user credential!'
160
+ text : '👋🌎 Hello world!' +
161
+ 'Text messages can contain things like:\n\n' +
162
+ '* Hyperlinks 🔗\n' +
163
+ '* Emojis 😄🎉\n' +
164
+ '* Mentions of other Chat users `@` \n\n' +
165
+ 'For details, see the ' +
166
+ '<https://developers.google.com/workspace/chat/format-messages' +
167
+ '|Chat API developer documentation>.'
155
168
} ;
156
169
157
170
// Make the request
0 commit comments