이 가이드에서는 Google Chat API의 ThreadReadState 리소스에서 get() 메서드를 사용하여 메시지 대화목록 내 사용자의 읽기 상태에 관한 세부정보를 가져오는 방법을 설명합니다. 스페이스의 메시지 읽기 상태를 가져오려면 사용자의 스페이스 읽기 상태에 관한 세부정보 가져오기를 참고하세요.
ThreadReadState 리소스는 Google Chat 메시지 대화목록에서 지정된 사용자의 마지막으로 읽은 메시지에 관한 세부정보를 나타내는 싱글톤 리소스입니다.
메시지 대화목록 내에서 사용자의 읽기 상태에 관한 세부정보를 가져오려면 요청에 다음을 포함합니다.
chat.users.readstate 또는 chat.users.readstate.readonly 승인 범위를 지정합니다.
GetThreadReadState() 메서드를 호출하여 사용자 ID 또는 별칭과 스페이스 ID가 포함된 스레드 읽기 상태의 name를 전달하여 가져옵니다. 스레드 읽기 상태 가져오기는 호출 사용자의 읽기 상태 가져오기만 지원하며, 이는 다음 중 하나를 설정하여 지정할 수 있습니다.
me 별칭 예를 들면 users/me/spaces/SPACE/threads/THREAD/threadReadState입니다.
호출 사용자의 Workspace 이메일 주소입니다. 예를 들면 다음과 같습니다.
users/user@example.com/spaces/SPACE/threads/THREAD/threadReadState
호출 사용자의 사용자 ID입니다. 예를 들면 다음과 같습니다.
users/USER/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입니다.
ListSpaces() 메서드를 호출하거나 스페이스의 URL에서 ID를 가져올 수 있습니다.
THREAD_NAME: 대화목록의 name의 ID입니다.
Chat API를 사용하여 메시지를 비동기식으로 만들거나 만들 때 메시지에 할당된 맞춤 이름으로 메시지를 만든 후 반환된 응답 본문에서 ID를 가져올 수 있습니다.
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"]]