A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.google.com/apps-script/advanced/chat below:

Advanced Chat Service | Apps Script

Advanced Chat Service

Stay organized with collections Save and categorize content based on your preferences.

The Advanced Chat service lets you use the Google Chat API in Apps Script. This API allows scripts to find, create, and modify Chat spaces, add or remove members to spaces, and read or post messages with text, cards, attachments, and reactions.

Prerequisites Note: This is an advanced service that you must turn on before use. Reference

For more information about this service, see the Chat API reference documentation. Like all advanced services in Apps Script, the Chat service uses the same objects, methods, and parameters as the public API.

Sample code

These samples show you how to perform common Google Chat API actions using the advanced service.

Post a message with user credentials

The following example demonstrates how to post a message to a Chat space on behalf of the user.

  1. Add the chat.messages.create authorization scope to the Apps Script project's appsscript.json file:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.messages.create"
    ]
    
  2. Add a function like this one to the Apps Script project's code:

Post a message with app credentials

The following example demonstrates how to post a message to a Chat space on behalf of the app. Using the advanced Chat service with a service account doesn't require you to specify authorization scopes in appsscript.json. For details about authentication with service accounts, see Authenticate as a Google Chat app.

Get a space

The following example demonstrates how to get information about a Chat space.

  1. Add the chat.spaces.readonly authorization scope to the Apps Script project's appsscript.json file:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.spaces.readonly"
    ]
    
  2. Add a function like this one to the Apps Script project's code:

Create a space

The following example demonstrates how to create a Chat space.

  1. Add the chat.spaces.create authorization scope to the Apps Script project's appsscript.json file:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.spaces.create"
    ]
    
  2. Add a function like this one to the Apps Script project's code:

List memberships

The following example demonstrates how to list all the members of a Chat space.

  1. Add the chat.memberships.readonly authorization scope to the Apps Script project's appsscript.json file:

    "oauthScopes": [
      "https://www.googleapis.com/auth/chat.memberships.readonly"
    ]
    
  2. Add a function like this one to the Apps Script project's code:

Troubleshoot

If you encounter Error 400: invalid_scope with the error message Some requested scopes cannot be shown, it means you haven't specified any authorization scopes in the Apps Script project's appsscript.json file. In most cases, Apps Script automatically determines what scopes a script needs, but when you use the Chat advanced service, you must manually add the authorization scopes that your script uses to your Apps Script project's manifest file. See Setting explicit scopes.

To resolve the error, add the appropriate authorization scopes to the Apps Script project's appsscript.json file as part of the oauthScopes array. For example, to call the spaces.messages.create method, add the following:

"oauthScopes": [
  "https://www.googleapis.com/auth/chat.messages.create"
]
Limits and considerations

The Advanced Chat service doesn't support:

To download a message attachment or call a developer preview method, use UrlFetchApp instead.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-04 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-04 UTC."],[[["The Advanced Chat service enables Apps Script to interact with the Google Chat API, allowing scripts to manage spaces, members, and messages."],["Utilizing this service requires setting up a Google Chat app in the Google Cloud console and configuring proper authentication (user or app)."],["Sample code snippets demonstrate common actions like posting messages and managing spaces using user or app credentials."],["The service mirrors the Chat API's objects and methods but has limitations, such as not supporting media downloads or Developer Preview methods."],["Troubleshooting steps and workarounds are provided for potential issues like scope errors."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4