File tree Expand file tree Collapse file tree 3 files changed +69
-0
lines changed
solutions/webhook-chat-app Expand file tree Collapse file tree 3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 1+ # Google Chat App Webhook
2+
3+ Please see related guide on how to
4+ [ send messages to Google Chat with incoming webhooks] ( https://developers.google.com/workspace/chat/quickstart/webhooks ) .
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright 2023 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+ // [START chat_webhook_thread]
19+ function webhook ( ) {
20+ const url = "https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN&messageReplyOption=REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD"
21+ const options = {
22+ "method" : "post" ,
23+ "headers" : { "Content-Type" : "application/json; charset=UTF-8" } ,
24+ "payload" : JSON . stringify ( {
25+ "text" : "Hello from Apps Script!" ,
26+ "thread" : {
27+ "threadKey" : "THREAD_KEY_VALUE"
28+ }
29+ } )
30+ } ;
31+ const response = UrlFetchApp . fetch ( url , options ) ;
32+ console . log ( response ) ;
33+ }
34+ // [END chat_webhook_thread]
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright 2022 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+ // [START chat_webhook]
19+ function webhook ( ) {
20+ const url = "https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY&token=TOKEN"
21+ const options = {
22+ "method" : "post" ,
23+ "headers" : { "Content-Type" : "application/json; charset=UTF-8" } ,
24+ "payload" : JSON . stringify ( {
25+ "text" : "Hello from Apps Script!"
26+ } )
27+ } ;
28+ const response = UrlFetchApp . fetch ( url , options ) ;
29+ console . log ( response ) ;
30+ }
31+ // [END chat_webhook]
You can’t perform that action at this time.
0 commit comments