GetThreadReadState() メソッドを呼び出し、スレッドの読み取り状態の name を渡して、ユーザー ID またはエイリアスとスペース ID を取得します。スレッドの読み取り状態の取得は、呼び出し元のユーザーの読み取り状態の取得のみをサポートしています。これは、次のいずれかを設定することで指定できます。
me エイリアス。例: users/me/spaces/SPACE/threads/THREAD/threadReadState
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 thread read state for a space and calling userasyncfunctionmain(){// Create a clientconstchatClient=awaitcreateClientWithUserCredentials(USER_AUTH_OAUTH_SCOPES);// Initialize request argument(s)constrequest={// Replace SPACE_NAME and THREAD_NAME herename:'users/me/spaces/SPACE_NAME/threads/THREAD_NAME/threadReadState'};// Make the requestconstresponse=awaitchatClient.getThreadReadState(request);// Handle the responseconsole.log(response);}main().catch(console.error);
このサンプルを実行するには、次のように置き換えます。
SPACE_NAME: スペースの name の ID。ID は、ListSpaces() メソッドを呼び出すか、スペースの URL から取得できます。
THREAD_NAME: スレッドの name の ID。ID は、Chat API を使用してメッセージを非同期で作成した後に返されたレスポンス本文から取得できます。また、作成時にメッセージに割り当てられたカスタム名から取得することもできます。
Google Chat API は、指定されたスレッドの読み取り状態を取得し、ThreadReadState のインスタンスを返します。
[[["わかりやすい","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 message thread using the Google Chat API."],["The `ThreadReadState` resource provides details about a user's last read message in a thread."],["To get the thread read state, you need a Google Workspace account, a configured Google Cloud project with the Google Chat API enabled, and the Node.js Cloud Client Library installed."],["You must use the `chat.users.readstate` or `chat.users.readstate.readonly` authorization scope and call the `GetThreadReadState()` method, specifying the thread read state's name."],["The API returns a `ThreadReadState` instance containing the user's read state information."]]],["This guide details retrieving a user's read state within a Google Chat message thread using the `get()` method on the `ThreadReadState` resource. Key actions involve setting up a Google Cloud project, enabling the Chat API, and obtaining OAuth credentials. The process requires specifying either the `chat.users.readstate` or `chat.users.readstate.readonly` authorization scope, then calling `GetThreadReadState()` with the thread read state's `name`, including a user ID/alias and space ID. The method returns a `ThreadReadState` instance.\n"]]