GetSpaceReadState() メソッドを呼び出し、スペースの読み取り状態の name を渡して、ユーザー ID またはエイリアスとスペース ID を取得します。スペースの読み取り状態の取得は、呼び出し元のユーザーの読み取り状態の取得のみをサポートしています。この状態は、次のいずれかを設定することで指定できます。
import{createClientWithUserCredentials}from'./authentication-utils.js';constUSER_AUTH_OAUTH_SCOPES=['https://www.googleapis.com/auth/chat.users.readstate.readonly'];// This sample shows how to get the space read state for the calling userasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Replace SPACE_NAME herename:'users/me/spaces/SPACE_NAME/spaceReadState'};// Make the requestconstresponse=awaitchatClient.getSpaceReadState(request);// Handle the responseconsole.log(response);}main().catch(console.error);
このサンプルを実行するには、SPACE_NAME をスペースの name の ID に置き換えます。ID は、ListSpaces() メソッドを呼び出すか、スペースの URL から取得できます。
Google Chat API は、指定されたスペースの読み取り状態を取得し、SpaceReadState のインスタンスを返します。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-02-14 UTC。"],[[["This guide explains how to use the `get()` method to retrieve a user's read state within a Google Chat space using the Google Chat API."],["You need a Google Workspace account and a configured Google Cloud project with the Google Chat API enabled to use this functionality."],["The guide provides instructions and code samples (Node.js) to retrieve the calling user's space read state using the `GetSpaceReadState()` method."],["To get the read state, you need to specify the appropriate authorization scope and provide the space name in the request."],["For message-specific read states within a thread, refer to the separate guide on getting thread read states."]]],["To retrieve a user's read state in a Google Chat space, use the `get()` method on the `SpaceReadState` resource. First, ensure you have a Google Workspace account, set up your environment with Node.js, and have appropriate OAuth credentials. Then, specify the `chat.users.readstate` or `chat.users.readstate.readonly` scope, and call `GetSpaceReadState()`, providing the space read state's `name`, including the user's ID or alias and the space ID. This returns a `SpaceReadState` instance.\n"]]