Package google.chat.v1

索引

ChatService

開發人員可在 Google Chat 平台上建構 Chat 應用程式和整合功能。

CompleteImportSpace

rpc CompleteImportSpace(CompleteImportSpaceRequest) returns (CompleteImportSpaceResponse)

完成指定空間的匯入程序,並向使用者顯示。

需要使用者驗證和全網域委派,並使用以下授權範圍

  • https://www.googleapis.com/auth/chat.import

詳情請參閱「授權 Google Chat 應用程式匯入資料」。

授權範圍

需要下列 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.import

詳情請參閱授權指南

CreateCustomEmoji

rpc CreateCustomEmoji(CreateCustomEmojiRequest) returns (CustomEmoji)

建立自訂表情符號。

自訂表情符號僅適用於 Google Workspace 帳戶,且管理員必須為機構啟用自訂表情符號。詳情請參閱「瞭解 Google Chat 中的自訂表情符號」和「管理自訂表情符號權限」。

需要使用授權範圍進行使用者驗證

  • https://www.googleapis.com/auth/chat.customemojis
授權範圍

需要下列 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.customemojis

詳情請參閱授權指南

CreateMembership

rpc CreateMembership(CreateMembershipRequest) returns (Membership)

為通話 Chat 應用程式、使用者或 Google 群組建立成員資格。目前不支援為其他 Chat 應用程式建立成員資格。建立成員時,如果指定成員關閉了自動接受政策,系統會邀請對方加入,且對方必須接受邀請才能加入。否則,建立成員資格會直接將成員新增至指定聊天室。

支援下列類型的驗證

  • 應用程式驗證 (須經管理員核准),授權範圍如下:

    • https://www.googleapis.com/auth/chat.app.memberships
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.memberships
    • https://www.googleapis.com/auth/chat.memberships.app (將通話應用程式加入聊天室)
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)
    • 當管理員帳戶通過驗證時,使用者驗證會授予管理員權限,use_admin_accesstrue,且使用下列授權範圍:
      • https://www.googleapis.com/auth/chat.admin.memberships

應用程式驗證不支援下列用途:

  • 邀請不屬於聊天室所屬 Workspace 機構的使用者。
  • 將 Google 群組新增至聊天室。
  • 將 Chat 應用程式新增至聊天室。

如需使用範例,請參閱:

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.admin.memberships
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.app

詳情請參閱授權指南

CreateMessage

rpc CreateMessage(CreateMessageRequest) returns (Message)

在 Google Chat 聊天室中建立訊息。如需範例,請參閱「傳送訊息」。

支援下列類型的驗證

  • 使用授權範圍進行應用程式驗證
    • https://www.googleapis.com/auth/chat.bot
  • 透過下列任一授權範圍進行使用者驗證
    • https://www.googleapis.com/auth/chat.messages.create
    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)

Chat 會根據您在要求中使用的驗證類型,以不同方式歸因訊息傳送者。

下圖顯示使用應用程式驗證時,Chat 如何將訊息歸因於應用程式。Chat 會將 Chat 應用程式顯示為訊息傳送者。訊息內容可包含文字 (text)、資訊卡 (cardsV2) 和配件小工具 (accessoryWidgets)。

透過應用程式驗證傳送的訊息

下圖說明使用使用者驗證時,Chat 如何將訊息歸因於使用者。Chat 會將使用者顯示為訊息傳送者,並顯示 Chat 應用程式的名稱,將訊息歸給該應用程式。訊息內容只能包含文字 (text)。

透過使用者驗證傳送的訊息

郵件大小上限為 32,000 個位元組,包括郵件內容。

如果是 Webhook 要求,回應不會包含完整訊息。除了要求中的資訊外,回應只會填入 namethread.name 欄位。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.create

詳情請參閱授權指南

CreateReaction

rpc CreateReaction(CreateReactionRequest) returns (Reaction)

建立回應並新增至訊息。如需範例,請參閱「對訊息新增回應」。

需要使用者驗證,並使用下列其中一個授權範圍

  • https://www.googleapis.com/auth/chat.messages.reactions.create
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages.reactions.create

詳情請參閱授權指南

CreateSpace

rpc CreateSpace(CreateSpaceRequest) returns (Space)

建立聊天室。可用於在 Import mode 中建立具名聊天室或群組對話。如需範例,請參閱「建立聊天室」。

支援下列類型的驗證

  • 應用程式驗證 (須經管理員核准),以及下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.app.spaces.create
    • https://www.googleapis.com/auth/chat.app.spaces
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.spaces.create
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)

以應用程式身分驗證時,必須在要求中設定 space.customer 欄位。

以應用程式身分驗證時,Chat 應用程式會新增為聊天室成員。不過,與真人驗證不同的是,Chat 應用程式不會新增為聊天室管理員。根據預設,所有聊天室成員都能從聊天室中移除 Chat 應用程式。如要只允許聊天室管理員從聊天室移除應用程式,請將 space.permission_settings.manage_apps 設為 managers_allowed

建立聊天室時的成員資格取決於聊天室是否在 Import mode 中建立:

  • 匯入模式:不會建立任何成員。
  • 所有其他模式:系統會將通話使用者新增為成員。包括:
    • 使用應用程式驗證時,應用程式本身。
    • 使用使用者驗證時的人類使用者。

如果在建立聊天室時收到 ALREADY_EXISTS 錯誤訊息,請嘗試使用其他 displayName。Google Workspace 機構中現有的聊天室可能已使用這個顯示名稱。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.spaces.create
  • https://www.googleapis.com/auth/chat.app.spaces
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.create

詳情請參閱授權指南

DeleteCustomEmoji

rpc DeleteCustomEmoji(DeleteCustomEmojiRequest) returns (Empty)

刪除自訂表情符號。根據預設,使用者只能刪除自己建立的自訂表情符號。管理員指派的表情符號管理員可以刪除機構中的任何自訂表情符號。請參閱「瞭解 Google Chat 中的自訂表情符號」。

自訂表情符號僅適用於 Google Workspace 帳戶,且管理員必須為機構啟用自訂表情符號。詳情請參閱「瞭解 Google Chat 中的自訂表情符號」和「管理自訂表情符號權限」。

需要使用授權範圍進行使用者驗證

  • https://www.googleapis.com/auth/chat.customemojis
授權範圍

需要下列 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.customemojis

詳情請參閱授權指南

DeleteMembership

rpc DeleteMembership(DeleteMembershipRequest) returns (Membership)

刪除會員資格。如需範例,請參閱「從聊天室中移除使用者或 Google Chat 應用程式」。

支援下列類型的驗證

  • 應用程式驗證 (須經管理員核准),授權範圍如下:

    • https://www.googleapis.com/auth/chat.app.memberships
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.memberships
    • https://www.googleapis.com/auth/chat.memberships.app (從聊天室中移除通話應用程式)
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)
    • 當管理員帳戶通過驗證時,使用者驗證會授予管理員權限,use_admin_accesstrue,且使用下列授權範圍:
      • https://www.googleapis.com/auth/chat.admin.memberships

應用程式驗證不支援下列用途:

  • 從聊天室中移除 Google 網路論壇。
  • 從聊天室移除 Google Chat 應用程式。

如要刪除聊天室管理員的成員資格,要求者必須是聊天室管理員。如果使用應用程式驗證,則必須由 Chat 應用程式建立聊天室。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.admin.memberships
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.app

詳情請參閱授權指南

DeleteMessage

rpc DeleteMessage(DeleteMessageRequest) returns (Empty)

刪除訊息。如需範例,請參閱「刪除訊息」一文。

支援下列類型的驗證

  • 應用程式驗證 (授權範圍):

    • https://www.googleapis.com/auth/chat.bot
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)

使用應用程式驗證時,要求只能刪除呼叫的 Chat 應用程式建立的訊息。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages

詳情請參閱授權指南

DeleteReaction

rpc DeleteReaction(DeleteReactionRequest) returns (Empty)

刪除訊息的回應。如需範例,請參閱刪除回應

需要使用者驗證,並使用下列其中一個授權範圍

  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.reactions

詳情請參閱授權指南

DeleteSpace

rpc DeleteSpace(DeleteSpaceRequest) returns (Empty)

刪除具名空間。一律執行連鎖刪除作業,也就是一併刪除聊天室的子項資源,例如聊天室中發布的訊息和成員資格。如需範例,請參閱「刪除聊天室」。

支援下列類型的驗證

  • 應用程式驗證 (須經管理員核准),授權範圍如下:

    • https://www.googleapis.com/auth/chat.app.delete (僅限應用程式建立的聊天室)
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.delete
    • https://www.googleapis.com/auth/chat.import (僅限匯入模式聊天室)
    • 當管理員帳戶通過驗證時,使用者驗證會授予管理員權限,use_admin_accesstrue,且使用下列授權範圍:
      • https://www.googleapis.com/auth/chat.admin.delete
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.delete
  • https://www.googleapis.com/auth/chat.admin.delete
  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.delete

詳情請參閱授權指南

FindDirectMessage

rpc FindDirectMessage(FindDirectMessageRequest) returns (Space)

傳回與指定使用者現有的即時訊息。如果找不到任何直接訊息空間,則會傳回 404 NOT_FOUND 錯誤。如需範例,請參閱「尋找即時訊息」。

透過應用程式驗證,傳回指定使用者與發出呼叫的 Chat 應用程式之間的即時訊息空間。

透過使用者驗證,傳回指定使用者和已驗證使用者之間的即時訊息空間。

支援下列類型的驗證

  • 應用程式驗證 (授權範圍):

    • https://www.googleapis.com/auth/chat.bot
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.bot

詳情請參閱授權指南

GetAttachment

rpc GetAttachment(GetAttachmentRequest) returns (Attachment)

取得郵件附件的中繼資料。附件資料是使用媒體 API 擷取。如需範例,請參閱「取得郵件附件的中繼資料」。

需要使用授權範圍進行應用程式驗證

  • https://www.googleapis.com/auth/chat.bot
授權範圍

需要下列 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.bot

詳情請參閱授權指南

GetCustomEmoji

rpc GetCustomEmoji(GetCustomEmojiRequest) returns (CustomEmoji)

傳回自訂表情符號的詳細資料。

自訂表情符號僅適用於 Google Workspace 帳戶,且管理員必須為機構啟用自訂表情符號。詳情請參閱「瞭解 Google Chat 中的自訂表情符號」和「管理自訂表情符號權限」。

需要使用者驗證,並使用下列其中一個授權範圍

  • https://www.googleapis.com/auth/chat.customemojis.readonly
  • https://www.googleapis.com/auth/chat.customemojis
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.customemojis
  • https://www.googleapis.com/auth/chat.customemojis.readonly

詳情請參閱授權指南

GetMembership

rpc GetMembership(GetMembershipRequest) returns (Membership)

傳回會員方案的詳細資料。如需範例,請參閱「取得使用者或 Google Chat 應用程式的成員資格詳細資料」。

支援下列類型的驗證

  • 應用程式驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.bot
    • https://www.googleapis.com/auth/chat.app.memberships (需要管理員核准)
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.memberships.readonly
    • https://www.googleapis.com/auth/chat.memberships
    • 使用者驗證會在管理員帳戶驗證時授予管理員權限,use_admin_accesstrue,且使用下列其中一個授權範圍:
      • https://www.googleapis.com/auth/chat.admin.memberships.readonly
      • https://www.googleapis.com/auth/chat.admin.memberships
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.admin.memberships
  • https://www.googleapis.com/auth/chat.admin.memberships.readonly
  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly

詳情請參閱授權指南

GetMessage

rpc GetMessage(GetMessageRequest) returns (Message)

傳回訊息的詳細資料。如需範例,請參閱「取得訊息詳細資料」。

支援下列類型的驗證

  • 應用程式驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.bot:使用這個授權範圍時,這個方法會傳回 Chat 應用程式可存取的訊息詳細資料,例如即時訊息和叫用 Chat 應用程式的斜線指令
    • https://www.googleapis.com/auth/chat.app.messages.readonly管理員核准 (適用於開發人員預覽版)。使用這個驗證範圍時,這個方法會傳回空間中公開訊息的詳細資料。
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.messages.readonly
    • https://www.googleapis.com/auth/chat.messages

注意:系統可能會傳回已封鎖成員或聊天室的訊息。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.readonly
  • https://www.googleapis.com/auth/chat.app.messages.readonly

詳情請參閱授權指南

GetSpace

rpc GetSpace(GetSpaceRequest) returns (Space)

傳回聊天室的詳細資料。如需範例,請參閱「取得空間詳細資料」。

支援下列類型的驗證

  • 應用程式驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.bot
    • https://www.googleapis.com/auth/chat.app.spaces 須經管理員核准
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
    • 使用者驗證會在管理員帳戶驗證時授予管理員權限,use_admin_accesstrue,且使用下列其中一個授權範圍:
      • https://www.googleapis.com/auth/chat.admin.spaces.readonly
      • https://www.googleapis.com/auth/chat.admin.spaces

應用程式驗證有下列限制:

  • 只有在使用 chat.app.spaces 範圍時,才會填入 space.access_settings
  • 只有在使用 chat.app.spaces 範圍時,且僅限應用程式建立的聊天室,才會填入 space.predefind_permission_settingsspace.permission_settings
授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.admin.spaces
  • https://www.googleapis.com/auth/chat.admin.spaces.readonly
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.bot
  • https://www.googleapis.com/auth/chat.app.spaces

詳情請參閱授權指南

GetSpaceEvent

rpc GetSpaceEvent(GetSpaceEventRequest) returns (SpaceEvent)

從 Google Chat 聊天室傳回事件。事件酬載包含變更資源的最新版本。舉例來說,如果您要求取得新訊息的事件,但該訊息稍後更新,伺服器會在事件酬載中傳回更新後的 Message 資源。

注意:這項要求的空間事件資料空間物件不會傳回 permissionSettings 欄位。

支援下列類型的驗證,並提供適當的授權範圍,可讀取所要求的資料:

  • 應用程式驗證 (須經管理員核准) 開發人員預覽版,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.app.spaces
    • https://www.googleapis.com/auth/chat.app.messages.readonly
    • https://www.googleapis.com/auth/chat.app.memberships
  • 使用者驗證,並使用下列其中一個授權範圍:

    • https://www.googleapis.com/auth/chat.spaces.readonly
    • https://www.googleapis.com/auth/chat.spaces
    • https://www.googleapis.com/auth/chat.messages.readonly
    • https://www.googleapis.com/auth/chat.messages
    • https://www.googleapis.com/auth/chat.messages.reactions.readonly
    • https://www.googleapis.com/auth/chat.messages.reactions
    • https://www.googleapis.com/auth/chat.memberships.readonly
    • https://www.googleapis.com/auth/chat.memberships

如要取得事件,經過驗證的呼叫者必須是聊天室成員。

如需範例,請參閱「取得 Google Chat 聊天室的活動詳細資料」。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.app.memberships
  • https://www.googleapis.com/auth/chat.app.messages.readonly
  • https://www.googleapis.com/auth/chat.app.spaces
  • https://www.googleapis.com/auth/chat.spaces
  • https://www.googleapis.com/auth/chat.spaces.readonly
  • https://www.googleapis.com/auth/chat.messages
  • https://www.googleapis.com/auth/chat.messages.readonly
  • https://www.googleapis.com/auth/chat.memberships
  • https://www.googleapis.com/auth/chat.memberships.readonly
  • https://www.googleapis.com/auth/chat.messages.reactions
  • https://www.googleapis.com/auth/chat.messages.reactions.readonly

詳情請參閱授權指南

GetSpaceNotificationSetting

rpc GetSpaceNotificationSetting(GetSpaceNotificationSettingRequest) returns (SpaceNotificationSetting)

取得聊天室通知設定。如需範例,請參閱「取得通話者的空間通知設定」。

需要使用授權範圍進行使用者驗證

  • https://www.googleapis.com/auth/chat.users.spacesettings
授權範圍

需要下列 OAuth 範圍:

  • https://www.googleapis.com/auth/chat.users.spacesettings

詳情請參閱授權指南

GetSpaceReadState

rpc GetSpaceReadState(GetSpaceReadStateRequest) returns (