Class v1.ChatServiceClient (0.11.0)

Enables developers to build Chat apps and integrations on Google Chat Platform. v1

Package

@google-apps/chat

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of ChatServiceClient.

Parameters
Name Description
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new ChatServiceClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

chatServiceStub

chatServiceStub?: Promise<{
        [name: string]: Function;
    }>;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

attachmentPath(space, message, attachment)

attachmentPath(space: string, message: string, attachment: string): string;

Return a fully-qualified attachment resource name string.

Parameters
Name Description
space string
message string
attachment string
Returns
Type Description
string

{string} Resource name string.

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
Type Description
Promise<void>

{Promise} A promise that resolves when the client is closed.

completeImportSpace(request, options)

completeImportSpace(request?: protos.google.chat.v1.ICompleteImportSpaceRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ICompleteImportSpaceResponse,
        protos.google.chat.v1.ICompleteImportSpaceRequest | undefined,
        {} | undefined
    ]>;

Completes the [import process](https://developers.google.com/workspace/chat/import-data) for the specified space and makes it visible to users.

Requires [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) and domain-wide delegation. For more information, see [Authorize Google Chat apps to import data](https://developers.google.com/workspace/chat/authorize-import).

Parameters
Name Description
request ICompleteImportSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ICompleteImportSpaceResponse, protos.google.chat.v1.ICompleteImportSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing CompleteImportSpaceResponse. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the import mode space.
   *  Format: `spaces/{space}`
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callCompleteImportSpace() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.completeImportSpace(request);
    console.log(response);
  }

  callCompleteImportSpace();

completeImportSpace(request, options, callback)

completeImportSpace(request: protos.google.chat.v1.ICompleteImportSpaceRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ICompleteImportSpaceResponse, protos.google.chat.v1.ICompleteImportSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICompleteImportSpaceRequest
options CallOptions
callback Callback<protos.google.chat.v1.ICompleteImportSpaceResponse, protos.google.chat.v1.ICompleteImportSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

completeImportSpace(request, callback)

completeImportSpace(request: protos.google.chat.v1.ICompleteImportSpaceRequest, callback: Callback<protos.google.chat.v1.ICompleteImportSpaceResponse, protos.google.chat.v1.ICompleteImportSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICompleteImportSpaceRequest
callback Callback<protos.google.chat.v1.ICompleteImportSpaceResponse, protos.google.chat.v1.ICompleteImportSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createMembership(request, options)

createMembership(request?: protos.google.chat.v1.ICreateMembershipRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMembership,
        protos.google.chat.v1.ICreateMembershipRequest | undefined,
        {} | undefined
    ]>;

Creates a membership for the calling Chat app, a user, or a Google Group. Creating memberships for other Chat apps isn't supported. When creating a membership, if the specified member has their auto-accept policy turned off, then they're invited, and must accept the space invitation before joining. Otherwise, creating a membership adds the member directly to the specified space.

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

For example usage, see:

  • [Invite or add a user to a space](https://developers.google.com/workspace/chat/create-members#create-user-membership).

  • [Invite or add a Google Group to a space](https://developers.google.com/workspace/chat/create-members#create-group-membership).

  • [Add the Chat app to a space](https://developers.google.com/workspace/chat/create-members#create-membership-calling-api).

Parameters
Name Description
request ICreateMembershipRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMembership, protos.google.chat.v1.ICreateMembershipRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the space for which to create the
   *  membership.
   *  Format: spaces/{space}
   */
  // const parent = 'abc123'
  /**
   *  Required. The membership relation to create.
   *  The `memberType` field must contain a user with the `user.name` and
   *  `user.type` fields populated. The server will assign a resource name
   *  and overwrite anything specified.
   *  When a Chat app creates a membership relation for a human user, it must use
   *  certain authorization scopes and set specific values for certain fields:
   *  - When authenticating as a
   *  user (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
   *  the `chat.memberships` authorization scope is required.
   *  - When authenticating as an
   *  app (https://developers.google.com/workspace/chat/authenticate-authorize-chat-app),
   *  the `chat.app.memberships` authorization scope is required.
   *  Authenticating as an app is available in Developer
   *  Preview (https://developers.google.com/workspace/preview).
   *  - Set `user.type` to `HUMAN`, and set `user.name` with format
   *  `users/{user}`, where `{user}` can be the email address for the user. For
   *  users in the same Workspace organization `{user}` can also be the `id` of
   *  the person (https://developers.google.com/people/api/rest/v1/people) from
   *  the People API, or the `id` for the user in the Directory API. For example,
   *  if the People API Person profile ID for `user@example.com` is `123456789`,
   *  you can add the user to the space by setting the `membership.member.name`
   *  to `users/user@example.com` or `users/123456789`.
   *  Inviting users external to the Workspace organization that owns the space
   *  requires user
   *  authentication (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
   *  When a Chat app creates a membership relation for itself, it must
   *  authenticate as a
   *  user (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user)
   *  and use the `chat.memberships.app` scope, set `user.type` to `BOT`, and set
   *  `user.name` to `users/app`.
   */
  // const membership = {}
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.memberships` OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   *  Creating app memberships or creating memberships for users outside the
   *  administrator's Google Workspace organization isn't supported using admin
   *  access.
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callCreateMembership() {
    // Construct request
    const request = {
      parent,
      membership,
    };

    // Run request
    const response = await chatClient.createMembership(request);
    console.log(response);
  }

  callCreateMembership();

createMembership(request, options, callback)

createMembership(request: protos.google.chat.v1.ICreateMembershipRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.ICreateMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateMembershipRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.ICreateMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createMembership(request, callback)

createMembership(request: protos.google.chat.v1.ICreateMembershipRequest, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.ICreateMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateMembershipRequest
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.ICreateMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createMessage(request, options)

createMessage(request?: protos.google.chat.v1.ICreateMessageRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMessage,
        protos.google.chat.v1.ICreateMessageRequest | undefined,
        {} | undefined
    ]>;

Creates a message in a Google Chat space. For an example, see [Send a message](https://developers.google.com/workspace/chat/create-messages).

The create() method requires either [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) or [app authentication](https://developers.google.com/workspace/chat/authorize-import). Chat attributes the message sender differently depending on the type of authentication that you use in your request.

The following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (text), cards (cardsV2), and accessory widgets (accessoryWidgets).

![Message sent with app authentication](https://developers.google.com/workspace/chat/images/message-app-auth.svg)

The following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (text).

![Message sent with user authentication](https://developers.google.com/workspace/chat/images/message-user-auth.svg)

The maximum message size, including the message contents, is 32,000 bytes.

For [webhook](https://developers.google.com/workspace/chat/quickstart/webhooks) requests, the response doesn't contain the full message. The response only populates the name and thread.name fields in addition to the information that was in the request.

Parameters
Name Description
request ICreateMessageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMessage, protos.google.chat.v1.ICreateMessageRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Message. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the space in which to create a message.
   *  Format: `spaces/{space}`
   */
  // const parent = 'abc123'
  /**
   *  Required. Message body.
   */
  // const message = {}
  /**
   *  Optional. A unique request ID for this message. Specifying an existing
   *  request ID returns the message created with that ID instead of creating a
   *  new message.
   */
  // const requestId = 'abc123'
  /**
   *  Optional. Specifies whether a message starts a thread or replies to one.
   *  Only supported in named spaces.
   *  When responding to user
   *  interactions (https://developers.google.com/workspace/chat/receive-respond-interactions),
   *  this field is ignored. For interactions within a thread, the reply is
   *  created in the same thread. Otherwise, the reply is created as a new
   *  thread.
   */
  // const messageReplyOption = {}
  /**
   *  Optional. A custom ID for a message. Lets Chat apps get, update, or delete
   *  a message without needing to store the system-assigned ID in the message's
   *  resource name (represented in the message `name` field).
   *  The value for this field must meet the following requirements:
   *  * Begins with `client-`. For example, `client-custom-name` is a valid
   *    custom ID, but `custom-name` is not.
   *  * Contains up to 63 characters and only lowercase letters, numbers, and
   *    hyphens.
   *  * Is unique within a space. A Chat app can't use the same custom ID for
   *  different messages.
   *  For details, see Name a
   *  message (https://developers.google.com/workspace/chat/create-messages#name_a_created_message).
   */
  // const messageId = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callCreateMessage() {
    // Construct request
    const request = {
      parent,
      message,
    };

    // Run request
    const response = await chatClient.createMessage(request);
    console.log(response);
  }

  callCreateMessage();

createMessage(request, options, callback)

createMessage(request: protos.google.chat.v1.ICreateMessageRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateMessageRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createMessage(request, callback)

createMessage(request: protos.google.chat.v1.ICreateMessageRequest, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateMessageRequest
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createReaction(request, options)

createReaction(request?: protos.google.chat.v1.ICreateReactionRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IReaction,
        protos.google.chat.v1.ICreateReactionRequest | undefined,
        {} | undefined
    ]>;

Creates a reaction and adds it to a message. Only unicode emojis are supported. For an example, see [Add a reaction to a message](https://developers.google.com/workspace/chat/create-reactions).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request ICreateReactionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IReaction, protos.google.chat.v1.ICreateReactionRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Reaction. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The message where the reaction is created.
   *  Format: `spaces/{space}/messages/{message}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The reaction to create.
   */
  // const reaction = {}

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callCreateReaction() {
    // Construct request
    const request = {
      parent,
      reaction,
    };

    // Run request
    const response = await chatClient.createReaction(request);
    console.log(response);
  }

  callCreateReaction();

createReaction(request, options, callback)

createReaction(request: protos.google.chat.v1.ICreateReactionRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IReaction, protos.google.chat.v1.ICreateReactionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateReactionRequest
options CallOptions
callback Callback<protos.google.chat.v1.IReaction, protos.google.chat.v1.ICreateReactionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createReaction(request, callback)

createReaction(request: protos.google.chat.v1.ICreateReactionRequest, callback: Callback<protos.google.chat.v1.IReaction, protos.google.chat.v1.ICreateReactionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateReactionRequest
callback Callback<protos.google.chat.v1.IReaction, protos.google.chat.v1.ICreateReactionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createSpace(request, options)

createSpace(request?: protos.google.chat.v1.ICreateSpaceRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace,
        protos.google.chat.v1.ICreateSpaceRequest | undefined,
        {} | undefined
    ]>;

Creates a space with no members. Can be used to create a named space, or a group chat in Import mode. For an example, see [Create a space](https://developers.google.com/workspace/chat/create-spaces).

If you receive the error message ALREADY_EXISTS when creating a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

When authenticating as an app, the space.customer field must be set in the request.

Parameters
Name Description
request ICreateSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace, protos.google.chat.v1.ICreateSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The `displayName` and `spaceType` fields must be populated.  Only
   *  `SpaceType.SPACE`  and `SpaceType.GROUP_CHAT` are supported.
   *  `SpaceType.GROUP_CHAT` can only be used if `importMode` is set to true.
   *  If you receive the error message `ALREADY_EXISTS`,
   *  try a different `displayName`. An existing space within the Google
   *  Workspace organization might already use this display name.
   *  The space `name` is assigned on the server so anything specified in this
   *  field will be ignored.
   */
  // const space = {}
  /**
   *  Optional. A unique identifier for this request.
   *  A random UUID is recommended.
   *  Specifying an existing request ID returns the space created with that ID
   *  instead of creating a new space.
   *  Specifying an existing request ID from the same Chat app with a different
   *  authenticated user returns an error.
   */
  // const requestId = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callCreateSpace() {
    // Construct request
    const request = {
      space,
    };

    // Run request
    const response = await chatClient.createSpace(request);
    console.log(response);
  }

  callCreateSpace();

createSpace(request, options, callback)

createSpace(request: protos.google.chat.v1.ICreateSpaceRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ICreateSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateSpaceRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ICreateSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

createSpace(request, callback)

createSpace(request: protos.google.chat.v1.ICreateSpaceRequest, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ICreateSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ICreateSpaceRequest
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ICreateSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteMembership(request, options)

deleteMembership(request?: protos.google.chat.v1.IDeleteMembershipRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMembership,
        protos.google.chat.v1.IDeleteMembershipRequest | undefined,
        {} | undefined
    ]>;

Deletes a membership. For an example, see [Remove a user or a Google Chat app from a space](https://developers.google.com/workspace/chat/delete-members).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IDeleteMembershipRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMembership, protos.google.chat.v1.IDeleteMembershipRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the membership to delete. Chat apps can delete
   *  human users' or their own memberships. Chat apps can't delete other apps'
   *  memberships.
   *  When deleting a human membership, requires the `chat.memberships` scope and
   *  `spaces/{space}/members/{member}` format. You can use the email as an
   *  alias for `{member}`. For example,
   *  `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
   *  email of the Google Chat user.
   *  When deleting an app membership, requires the `chat.memberships.app` scope
   *  and `spaces/{space}/members/app` format.
   *  Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`.
   */
  // const name = 'abc123'
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.memberships` OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   *  Deleting app memberships in a space isn't supported using admin access.
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callDeleteMembership() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.deleteMembership(request);
    console.log(response);
  }

  callDeleteMembership();

deleteMembership(request, options, callback)

deleteMembership(request: protos.google.chat.v1.IDeleteMembershipRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IDeleteMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteMembershipRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IDeleteMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteMembership(request, callback)

deleteMembership(request: protos.google.chat.v1.IDeleteMembershipRequest, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IDeleteMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteMembershipRequest
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IDeleteMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteMessage(request, options)

deleteMessage(request?: protos.google.chat.v1.IDeleteMessageRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.chat.v1.IDeleteMessageRequest | undefined,
        {} | undefined
    ]>;

Deletes a message. For an example, see [Delete a message](https://developers.google.com/workspace/chat/delete-messages).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

When using app authentication, requests can only delete messages created by the calling Chat app.

Parameters
Name Description
request IDeleteMessageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteMessageRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the message.
   *  Format: `spaces/{space}/messages/{message}`
   *  If you've set a custom ID for your message, you can use the value from the
   *  `clientAssignedMessageId` field for `{message}`. For details, see Name a
   *  message 
   *  (https://developers.google.com/workspace/chat/create-messages#name_a_created_message).
   */
  // const name = 'abc123'
  /**
   *  Optional. When `true`, deleting a message also deletes its threaded
   *  replies. When `false`, if a message has threaded replies, deletion fails.
   *  Only applies when authenticating as a
   *  user (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).
   *  Has no effect when authenticating as a Chat app 
   *  (https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).
   */
  // const force = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callDeleteMessage() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.deleteMessage(request);
    console.log(response);
  }

  callDeleteMessage();

deleteMessage(request, options, callback)

deleteMessage(request: protos.google.chat.v1.IDeleteMessageRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteMessageRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteMessage(request, callback)

deleteMessage(request: protos.google.chat.v1.IDeleteMessageRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteMessageRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteReaction(request, options)

deleteReaction(request?: protos.google.chat.v1.IDeleteReactionRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.chat.v1.IDeleteReactionRequest | undefined,
        {} | undefined
    ]>;

Deletes a reaction to a message. Only unicode emojis are supported. For an example, see [Delete a reaction](https://developers.google.com/workspace/chat/delete-reactions).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IDeleteReactionRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteReactionRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Name of the reaction to delete.
   *  Format: `spaces/{space}/messages/{message}/reactions/{reaction}`
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callDeleteReaction() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.deleteReaction(request);
    console.log(response);
  }

  callDeleteReaction();

deleteReaction(request, options, callback)

deleteReaction(request: protos.google.chat.v1.IDeleteReactionRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteReactionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteReactionRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteReactionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteReaction(request, callback)

deleteReaction(request: protos.google.chat.v1.IDeleteReactionRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteReactionRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteReactionRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteReactionRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteSpace(request, options)

deleteSpace(request?: protos.google.chat.v1.IDeleteSpaceRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        protos.google.chat.v1.IDeleteSpaceRequest | undefined,
        {} | undefined
    ]>;

Deletes a named space. Always performs a cascading delete, which means that the space's child resources—like messages posted in the space and memberships in the space—are also deleted. For an example, see [Delete a space](https://developers.google.com/workspace/chat/delete-spaces).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IDeleteSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the space to delete.
   *  Format: `spaces/{space}`
   */
  // const name = 'abc123'
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.delete` OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callDeleteSpace() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.deleteSpace(request);
    console.log(response);
  }

  callDeleteSpace();

deleteSpace(request, options, callback)

deleteSpace(request: protos.google.chat.v1.IDeleteSpaceRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteSpaceRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

deleteSpace(request, callback)

deleteSpace(request: protos.google.chat.v1.IDeleteSpaceRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDeleteSpaceRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.chat.v1.IDeleteSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

findDirectMessage(request, options)

findDirectMessage(request?: protos.google.chat.v1.IFindDirectMessageRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace,
        protos.google.chat.v1.IFindDirectMessageRequest | undefined,
        {} | undefined
    ]>;

Returns the existing direct message with the specified user. If no direct message space is found, returns a 404 NOT_FOUND error. For an example, see [Find a direct message](/chat/api/guides/v1/spaces/find-direct-message).

With [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app), returns the direct message space between the specified user and the calling Chat app.

With [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user), returns the direct message space between the specified user and the authenticated user.

// Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IFindDirectMessageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace, protos.google.chat.v1.IFindDirectMessageRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the user to find direct message with.
   *  Format: `users/{user}`, where `{user}` is either the `id` for the
   *  person (https://developers.google.com/people/api/rest/v1/people) from the
   *  People API, or the `id` for the
   *  user (https://developers.google.com/admin-sdk/directory/reference/rest/v1/users)
   *  in the Directory API. For example, if the People API profile ID is
   *  `123456789`, you can find a direct message with that person by using
   *  `users/123456789` as the `name`. When authenticated as a
   *  user (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
   *  you can use the email as an alias for `{user}`. For example,
   *  `users/example@gmail.com` where `example@gmail.com` is the email of the
   *  Google Chat user.
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callFindDirectMessage() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.findDirectMessage(request);
    console.log(response);
  }

  callFindDirectMessage();

findDirectMessage(request, options, callback)

findDirectMessage(request: protos.google.chat.v1.IFindDirectMessageRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IFindDirectMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IFindDirectMessageRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IFindDirectMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

findDirectMessage(request, callback)

findDirectMessage(request: protos.google.chat.v1.IFindDirectMessageRequest, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IFindDirectMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IFindDirectMessageRequest
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IFindDirectMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getAttachment(request, options)

getAttachment(request?: protos.google.chat.v1.IGetAttachmentRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IAttachment,
        protos.google.chat.v1.IGetAttachmentRequest | undefined,
        {} | undefined
    ]>;

Gets the metadata of a message attachment. The attachment data is fetched using the [media API](https://developers.google.com/workspace/chat/api/reference/rest/v1/media/download). For an example, see [Get metadata about a message attachment](https://developers.google.com/workspace/chat/get-media-attachments). Requires [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app).

Parameters
Name Description
request IGetAttachmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IAttachment, protos.google.chat.v1.IGetAttachmentRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the attachment, in the form
   *  `spaces/{space}/messages/{message}/attachments/{attachment}`.
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetAttachment() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getAttachment(request);
    console.log(response);
  }

  callGetAttachment();

getAttachment(request, options, callback)

getAttachment(request: protos.google.chat.v1.IGetAttachmentRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IAttachment, protos.google.chat.v1.IGetAttachmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetAttachmentRequest
options CallOptions
callback Callback<protos.google.chat.v1.IAttachment, protos.google.chat.v1.IGetAttachmentRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getAttachment(request, callback)

getAttachment(request: protos.google.chat.v1.IGetAttachmentRequest, callback: Callback<protos.google.chat.v1.IAttachment, protos.google.chat.v1.IGetAttachmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetAttachmentRequest
callback Callback<protos.google.chat.v1.IAttachment, protos.google.chat.v1.IGetAttachmentRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getMembership(request, options)

getMembership(request?: protos.google.chat.v1.IGetMembershipRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMembership,
        protos.google.chat.v1.IGetMembershipRequest | undefined,
        {} | undefined
    ]>;

Returns details about a membership. For an example, see [Get details about a user's or Google Chat app's membership](https://developers.google.com/workspace/chat/get-members).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IGetMembershipRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMembership, protos.google.chat.v1.IGetMembershipRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the membership to retrieve.
   *  To get the app's own membership by using user
   *  authentication (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user),
   *  you can optionally use `spaces/{space}/members/app`.
   *  Format: `spaces/{space}/members/{member}` or `spaces/{space}/members/app`
   *  You can use the user's email as an alias for `{member}`. For example,
   *  `spaces/{space}/members/example@gmail.com` where `example@gmail.com` is the
   *  email of the Google Chat user.
   */
  // const name = 'abc123'
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.memberships` or `chat.admin.memberships.readonly`
   *  OAuth 2.0
   *  scopes (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   *  Getting app memberships in a space isn't supported when using admin access.
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetMembership() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getMembership(request);
    console.log(response);
  }

  callGetMembership();

getMembership(request, options, callback)

getMembership(request: protos.google.chat.v1.IGetMembershipRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IGetMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetMembershipRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IGetMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getMembership(request, callback)

getMembership(request: protos.google.chat.v1.IGetMembershipRequest, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IGetMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetMembershipRequest
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IGetMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getMessage(request, options)

getMessage(request?: protos.google.chat.v1.IGetMessageRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMessage,
        protos.google.chat.v1.IGetMessageRequest | undefined,
        {} | undefined
    ]>;

Returns details about a message. For an example, see [Get details about a message](https://developers.google.com/workspace/chat/get-messages).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Note: Might return a message from a blocked member or space.

Parameters
Name Description
request IGetMessageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMessage, protos.google.chat.v1.IGetMessageRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Message. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the message.
   *  Format: `spaces/{space}/messages/{message}`
   *  If you've set a custom ID for your message, you can use the value from the
   *  `clientAssignedMessageId` field for `{message}`. For details, see Name a
   *  message 
   *  (https://developers.google.com/workspace/chat/create-messages#name_a_created_message).
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetMessage() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getMessage(request);
    console.log(response);
  }

  callGetMessage();

getMessage(request, options, callback)

getMessage(request: protos.google.chat.v1.IGetMessageRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IGetMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetMessageRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IGetMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getMessage(request, callback)

getMessage(request: protos.google.chat.v1.IGetMessageRequest, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IGetMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetMessageRequest
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IGetMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getProjectId()

getProjectId(): Promise<string>;
Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

getSpace(request, options)

getSpace(request?: protos.google.chat.v1.IGetSpaceRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace,
        protos.google.chat.v1.IGetSpaceRequest | undefined,
        {} | undefined
    ]>;

Returns details about a space. For an example, see [Get details about a space](https://developers.google.com/workspace/chat/get-spaces).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IGetSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace, protos.google.chat.v1.IGetSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the space, in the form `spaces/{space}`.
   *  Format: `spaces/{space}`
   */
  // const name = 'abc123'
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.spaces` or `chat.admin.spaces.readonly` OAuth 2.0
   *  scopes (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetSpace() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getSpace(request);
    console.log(response);
  }

  callGetSpace();

getSpace(request, options, callback)

getSpace(request: protos.google.chat.v1.IGetSpaceRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IGetSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IGetSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getSpace(request, callback)

getSpace(request: protos.google.chat.v1.IGetSpaceRequest, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IGetSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceRequest
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IGetSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getSpaceEvent(request, options)

getSpaceEvent(request?: protos.google.chat.v1.IGetSpaceEventRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpaceEvent,
        protos.google.chat.v1.IGetSpaceEventRequest | undefined,
        {} | undefined
    ]>;

Returns an event from a Google Chat space. The [event payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload) contains the most recent version of the resource that changed. For example, if you request an event about a new message but the message was later updated, the server returns the updated Message resource in the event payload.

Note: The permissionSettings field is not returned in the Space object of the Space event data for this request.

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user). To get an event, the authenticated user must be a member of the space.

For an example, see [Get details about an event from a Google Chat space](https://developers.google.com/workspace/chat/get-space-event).

Parameters
Name Description
request IGetSpaceEventRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpaceEvent, protos.google.chat.v1.IGetSpaceEventRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing SpaceEvent. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the space event.
   *  Format: `spaces/{space}/spaceEvents/{spaceEvent}`
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetSpaceEvent() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getSpaceEvent(request);
    console.log(response);
  }

  callGetSpaceEvent();

getSpaceEvent(request, options, callback)

getSpaceEvent(request: protos.google.chat.v1.IGetSpaceEventRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpaceEvent, protos.google.chat.v1.IGetSpaceEventRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceEventRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpaceEvent, protos.google.chat.v1.IGetSpaceEventRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getSpaceEvent(request, callback)

getSpaceEvent(request: protos.google.chat.v1.IGetSpaceEventRequest, callback: Callback<protos.google.chat.v1.ISpaceEvent, protos.google.chat.v1.IGetSpaceEventRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceEventRequest
callback Callback<protos.google.chat.v1.ISpaceEvent, protos.google.chat.v1.IGetSpaceEventRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getSpaceReadState(request, options)

getSpaceReadState(request?: protos.google.chat.v1.IGetSpaceReadStateRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpaceReadState,
        protos.google.chat.v1.IGetSpaceReadStateRequest | undefined,
        {} | undefined
    ]>;

Returns details about a user's read state within a space, used to identify read and unread messages. For an example, see [Get details about a user's space read state](https://developers.google.com/workspace/chat/get-space-read-state).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IGetSpaceReadStateRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IGetSpaceReadStateRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing SpaceReadState. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the space read state to retrieve.
   *  Only supports getting read state for the calling user.
   *  To refer to the calling user, set one of the following:
   *  - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
   *  - Their Workspace email address. For example,
   *  `users/user@example.com/spaces/{space}/spaceReadState`.
   *  - Their user id. For example,
   *  `users/123456789/spaces/{space}/spaceReadState`.
   *  Format: users/{user}/spaces/{space}/spaceReadState
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetSpaceReadState() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getSpaceReadState(request);
    console.log(response);
  }

  callGetSpaceReadState();

getSpaceReadState(request, options, callback)

getSpaceReadState(request: protos.google.chat.v1.IGetSpaceReadStateRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IGetSpaceReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceReadStateRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IGetSpaceReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getSpaceReadState(request, callback)

getSpaceReadState(request: protos.google.chat.v1.IGetSpaceReadStateRequest, callback: Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IGetSpaceReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetSpaceReadStateRequest
callback Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IGetSpaceReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getThreadReadState(request, options)

getThreadReadState(request?: protos.google.chat.v1.IGetThreadReadStateRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IThreadReadState,
        protos.google.chat.v1.IGetThreadReadStateRequest | undefined,
        {} | undefined
    ]>;

Returns details about a user's read state within a thread, used to identify read and unread messages. For an example, see [Get details about a user's thread read state](https://developers.google.com/workspace/chat/get-thread-read-state).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IGetThreadReadStateRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IThreadReadState, protos.google.chat.v1.IGetThreadReadStateRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ThreadReadState. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the thread read state to retrieve.
   *  Only supports getting read state for the calling user.
   *  To refer to the calling user, set one of the following:
   *  - The `me` alias. For example,
   *  `users/me/spaces/{space}/threads/{thread}/threadReadState`.
   *  - Their Workspace email address. For example,
   *  `users/user@example.com/spaces/{space}/threads/{thread}/threadReadState`.
   *  - Their user id. For example,
   *  `users/123456789/spaces/{space}/threads/{thread}/threadReadState`.
   *  Format: users/{user}/spaces/{space}/threads/{thread}/threadReadState
   */
  // const name = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callGetThreadReadState() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await chatClient.getThreadReadState(request);
    console.log(response);
  }

  callGetThreadReadState();

getThreadReadState(request, options, callback)

getThreadReadState(request: protos.google.chat.v1.IGetThreadReadStateRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IThreadReadState, protos.google.chat.v1.IGetThreadReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetThreadReadStateRequest
options CallOptions
callback Callback<protos.google.chat.v1.IThreadReadState, protos.google.chat.v1.IGetThreadReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getThreadReadState(request, callback)

getThreadReadState(request: protos.google.chat.v1.IGetThreadReadStateRequest, callback: Callback<protos.google.chat.v1.IThreadReadState, protos.google.chat.v1.IGetThreadReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetThreadReadStateRequest
callback Callback<protos.google.chat.v1.IThreadReadState, protos.google.chat.v1.IGetThreadReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
Type Description
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listMemberships(request, options)

listMemberships(request?: protos.google.chat.v1.IListMembershipsRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMembership[],
        protos.google.chat.v1.IListMembershipsRequest | null,
        protos.google.chat.v1.IListMembershipsResponse
    ]>;

Lists memberships in a space. For an example, see [List users and Google Chat apps in a space](https://developers.google.com/workspace/chat/list-members). Listing memberships with [app authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) lists memberships in spaces that the Chat app has access to, but excludes Chat app memberships, including its own. Listing memberships with [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) lists memberships in spaces that the authenticated user has access to.

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IListMembershipsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMembership[], protos.google.chat.v1.IListMembershipsRequest | null, protos.google.chat.v1.IListMembershipsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listMembershipsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listMemberships(request, options, callback)

listMemberships(request: protos.google.chat.v1.IListMembershipsRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.IListMembershipsRequest, protos.google.chat.v1.IListMembershipsResponse | null | undefined, protos.google.chat.v1.IMembership>): void;
Parameters
Name Description
request IListMembershipsRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.IListMembershipsRequest, protos.google.chat.v1.IListMembershipsResponse | null | undefined, protos.google.chat.v1.IMembership>
Returns
Type Description
void

listMemberships(request, callback)

listMemberships(request: protos.google.chat.v1.IListMembershipsRequest, callback: PaginationCallback<protos.google.chat.v1.IListMembershipsRequest, protos.google.chat.v1.IListMembershipsResponse | null | undefined, protos.google.chat.v1.IMembership>): void;
Parameters
Name Description
request IListMembershipsRequest
callback PaginationCallback<protos.google.chat.v1.IListMembershipsRequest, protos.google.chat.v1.IListMembershipsResponse | null | undefined, protos.google.chat.v1.IMembership>
Returns
Type Description
void

listMembershipsAsync(request, options)

listMembershipsAsync(request?: protos.google.chat.v1.IListMembershipsRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.IMembership>;

Equivalent to listMemberships, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request IListMembershipsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.IMembership>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the space for which to fetch a membership
   *  list.
   *  Format: spaces/{space}
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of memberships to return. The service might
   *  return fewer than this value.
   *  If unspecified, at most 100 memberships are returned.
   *  The maximum value is 1000. If you use a value more than 1000, it's
   *  automatically changed to 1000.
   *  Negative values return an `INVALID_ARGUMENT` error.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token, received from a previous call to list memberships.
   *  Provide this parameter to retrieve the subsequent page.
   *  When paginating, all other parameters provided should match the call that
   *  provided the page token. Passing different values to the other parameters
   *  might lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. A query filter.
   *  You can filter memberships by a member's role
   *  (`role` (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.members#membershiprole))
   *  and type
   *  (`member.type` (https://developers.google.com/workspace/chat/api/reference/rest/v1/User#type)).
   *  To filter by role, set `role` to `ROLE_MEMBER` or `ROLE_MANAGER`.
   *  To filter by type, set `member.type` to `HUMAN` or `BOT`. You can also
   *  filter for `member.type` using the `!=` operator.
   *  To filter by both role and type, use the `AND` operator. To filter by
   *  either role or type, use the `OR` operator.
   *  Either `member.type = "HUMAN"` or `member.type != "BOT"` is required
   *  when `use_admin_access` is set to true. Other member type filters will be
   *  rejected.
   *  For example, the following queries are valid:
   *  

   *  role = "ROLE_MANAGER" OR role = "ROLE_MEMBER"
   *  member.type = "HUMAN" AND role = "ROLE_MANAGER"
   *  member.type != "BOT"
   *  
  • The following queries are invalid:
  • member.type = "HUMAN" AND member.type = "BOT"
  • role = "ROLE_MANAGER" AND role = "ROLE_MEMBER"
  • Invalid queries are rejected by the server with an INVALID_ARGUMENT
  • error. / // const filter = 'abc123' /*
  • Optional. When true, also returns memberships associated with a
  • Google Group google.chat.v1.Membership.group_member, in
  • addition to other types of memberships. If a
  • filter google.chat.v1.ListMembershipsRequest.filter is set,
  • Google Group google.chat.v1.Membership.group_member
  • memberships that don't match the filter criteria aren't returned. / // const showGroups = true /*
  • Optional. When true, also returns memberships associated with
  • invited google.chat.v1.Membership.MembershipState.INVITED members, in
  • addition to other types of memberships. If a
  • filter is set,
  • invited google.chat.v1.Membership.MembershipState.INVITED memberships
  • that don't match the filter criteria aren't returned.
  • Currently requires user
  • authentication (https://developers.google.com/workspace/chat/authenticate-authorize-chat-user). / // const showInvited = true /*
  • Optional. When true, the method runs using the user's Google Workspace
  • administrator privileges.
  • The calling user must be a Google Workspace administrator with the
  • manage chat and spaces conversations
  • privilege (https://support.google.com/a/answer/13369245).
  • Requires either the chat.admin.memberships.readonly or
  • chat.admin.memberships OAuth 2.0
  • scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
  • Listing app memberships in a space isn't supported when using admin access. */ // const useAdminAccess = true

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callListMemberships() { // Construct request const request = { parent, };

    // Run request const iterable = chatClient.listMembershipsAsync(request); for await (const response of iterable) { console.log(response); } }

    callListMemberships();

listMembershipsStream(request, options)

listMembershipsStream(request?: protos.google.chat.v1.IListMembershipsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request IListMembershipsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listMembershipsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listMessages(request, options)

listMessages(request?: protos.google.chat.v1.IListMessagesRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMessage[],
        protos.google.chat.v1.IListMessagesRequest | null,
        protos.google.chat.v1.IListMessagesResponse
    ]>;

Lists messages in a space that the caller is a member of, including messages from blocked members and spaces. If you list messages from a space with no messages, the response is an empty object. When using a REST/HTTP interface, the response contains an empty JSON object, {}. For an example, see [List messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/list).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IListMessagesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMessage[], protos.google.chat.v1.IListMessagesRequest | null, protos.google.chat.v1.IListMessagesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of Message. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listMessagesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listMessages(request, options, callback)

listMessages(request: protos.google.chat.v1.IListMessagesRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.IListMessagesRequest, protos.google.chat.v1.IListMessagesResponse | null | undefined, protos.google.chat.v1.IMessage>): void;
Parameters
Name Description
request IListMessagesRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.IListMessagesRequest, protos.google.chat.v1.IListMessagesResponse | null | undefined, protos.google.chat.v1.IMessage>
Returns
Type Description
void

listMessages(request, callback)

listMessages(request: protos.google.chat.v1.IListMessagesRequest, callback: PaginationCallback<protos.google.chat.v1.IListMessagesRequest, protos.google.chat.v1.IListMessagesResponse | null | undefined, protos.google.chat.v1.IMessage>): void;
Parameters
Name Description
request IListMessagesRequest
callback PaginationCallback<protos.google.chat.v1.IListMessagesRequest, protos.google.chat.v1.IListMessagesResponse | null | undefined, protos.google.chat.v1.IMessage>
Returns
Type Description
void

listMessagesAsync(request, options)

listMessagesAsync(request?: protos.google.chat.v1.IListMessagesRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.IMessage>;

Equivalent to listMessages, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request IListMessagesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.IMessage>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Message. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of the space to list messages from.
   *  Format: `spaces/{space}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of messages returned. The service might return
   *  fewer messages than this value.
   *  If unspecified, at most 25 are returned.
   *  The maximum value is 1000. If you use a value more than 1000, it's
   *  automatically changed to 1000.
   *  Negative values return an `INVALID_ARGUMENT` error.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token received from a previous list messages call. Provide
   *  this parameter to retrieve the subsequent page.
   *  When paginating, all other parameters provided should match the call that
   *  provided the page token. Passing different values to the other parameters
   *  might lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. A query filter.
   *  You can filter messages by date (`create_time`) and thread (`thread.name`).
   *  To filter messages by the date they were created, specify the `create_time`
   *  with a timestamp in RFC-3339 (https://www.rfc-editor.org/rfc/rfc3339)
   *  format and double quotation marks. For example,
   *  `"2023-04-21T11:30:00-04:00"`. You can use the greater than operator `>` to
   *  list messages that were created after a timestamp, or the less than
   *  operator `<` to="" list="" messages="" that="" were="" created="" before="" a="" timestamp.="" to="" *="" filter="" messages="" within="" a="" time="" interval,="" use="" the="" `and`="" operator="" between="" two="" *="" timestamps.="" *="" to="" filter="" by="" thread,="" specify="" the="" `thread.name`,="" formatted="" as="" *="" `spaces/{space}/threads/{thread}`.="" you="" can="" only="" specify="" one="" *="" `thread.name`="" per="" query.="" *="" to="" filter="" by="" both="" thread="" and="" date,="" use="" the="" `and`="" operator="" in="" your="" query.="" *="" for="" example,="" the="" following="" queries="" are="" valid:="" *="">

   *  create_time > "2012-04-21T11:30:00-04:00"
   *  create_time > "2012-04-21T11:30:00-04:00" AND
   *    thread.name = spaces/AAAAAAAAAAA/threads/123
   *  create_time > "2012-04-21T11:30:00+00:00" AND
   *  create_time < "2013-01-01t00:00:00+00:00"="" and="" *="" thread.name="spaces/AAAAAAAAAAA/threads/123" *="" thread.name="spaces/AAAAAAAAAAA/threads/123" *="">
  • Invalid queries are rejected by the server with an INVALID_ARGUMENT
  • error. / // const filter = 'abc123' /*
  • Optional. How the list of messages is ordered. Specify a value to order by
  • an ordering operation. Valid ordering operation values are as follows:
    • ASC for ascending.
    • DESC for descending.
  • The default ordering is create_time ASC. / // const orderBy = 'abc123' /*
  • Optional. Whether to include deleted messages. Deleted messages include
  • deleted time and metadata about their deletion, but message content is
  • unavailable. */ // const showDeleted = true

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callListMessages() { // Construct request const request = { parent, };

    // Run request const iterable = chatClient.listMessagesAsync(request); for await (const response of iterable) { console.log(response); } }

    callListMessages();

listMessagesStream(request, options)

listMessagesStream(request?: protos.google.chat.v1.IListMessagesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request IListMessagesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing Message on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listMessagesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listReactions(request, options)

listReactions(request?: protos.google.chat.v1.IListReactionsRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IReaction[],
        protos.google.chat.v1.IListReactionsRequest | null,
        protos.google.chat.v1.IListReactionsResponse
    ]>;

Lists reactions to a message. For an example, see [List reactions for a message](https://developers.google.com/workspace/chat/list-reactions).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IListReactionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IReaction[], protos.google.chat.v1.IListReactionsRequest | null, protos.google.chat.v1.IListReactionsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of Reaction. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listReactionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listReactions(request, options, callback)

listReactions(request: protos.google.chat.v1.IListReactionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.IListReactionsRequest, protos.google.chat.v1.IListReactionsResponse | null | undefined, protos.google.chat.v1.IReaction>): void;
Parameters
Name Description
request IListReactionsRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.IListReactionsRequest, protos.google.chat.v1.IListReactionsResponse | null | undefined, protos.google.chat.v1.IReaction>
Returns
Type Description
void

listReactions(request, callback)

listReactions(request: protos.google.chat.v1.IListReactionsRequest, callback: PaginationCallback<protos.google.chat.v1.IListReactionsRequest, protos.google.chat.v1.IListReactionsResponse | null | undefined, protos.google.chat.v1.IReaction>): void;
Parameters
Name Description
request IListReactionsRequest
callback PaginationCallback<protos.google.chat.v1.IListReactionsRequest, protos.google.chat.v1.IListReactionsResponse | null | undefined, protos.google.chat.v1.IReaction>
Returns
Type Description
void

listReactionsAsync(request, options)

listReactionsAsync(request?: protos.google.chat.v1.IListReactionsRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.IReaction>;

Equivalent to listReactions, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request IListReactionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.IReaction>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Reaction. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The message users reacted to.
   *  Format: `spaces/{space}/messages/{message}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of reactions returned. The service can return
   *  fewer reactions than this value. If unspecified, the default value is 25.
   *  The maximum value is 200; values above 200 are changed to 200.
   */
  // const pageSize = 1234
  /**
   *  Optional. (If resuming from a previous query.)
   *  A page token received from a previous list reactions call. Provide this
   *  to retrieve the subsequent page.
   *  When paginating, the filter value should match the call that provided the
   *  page token. Passing a different value might lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. A query filter.
   *  You can filter reactions by
   *  emoji (https://developers.google.com/workspace/chat/api/reference/rest/v1/Emoji)
   *  (either `emoji.unicode` or `emoji.custom_emoji.uid`) and
   *  user (https://developers.google.com/workspace/chat/api/reference/rest/v1/User)
   *  (`user.name`).
   *  To filter reactions for multiple emojis or users, join similar fields
   *  with the `OR` operator, such as `emoji.unicode = "🙂" OR emoji.unicode =
   *  "👍"` and `user.name = "users/AAAAAA" OR user.name = "users/BBBBBB"`.
   *  To filter reactions by emoji and user, use the `AND` operator, such as
   *  `emoji.unicode = "🙂" AND user.name = "users/AAAAAA"`.
   *  If your query uses both `AND` and `OR`, group them with parentheses.
   *  For example, the following queries are valid:
   *  

   *  user.name = "users/{user}"
   *  emoji.unicode = "🙂"
   *  emoji.custom_emoji.uid = "{uid}"
   *  emoji.unicode = "🙂" OR emoji.unicode = "👍"
   *  emoji.unicode = "🙂" OR emoji.custom_emoji.uid = "{uid}"
   *  emoji.unicode = "🙂" AND user.name = "users/{user}"
   *  (emoji.unicode = "🙂" OR emoji.custom_emoji.uid = "{uid}")
   *  AND user.name = "users/{user}"
   *  
  • The following queries are invalid:
  • emoji.unicode = "🙂" AND emoji.unicode = "👍"
  • emoji.unicode = "🙂" AND emoji.custom_emoji.uid = "{uid}"
  • emoji.unicode = "🙂" OR user.name = "users/{user}"
  • emoji.unicode = "🙂" OR emoji.custom_emoji.uid = "{uid}" OR
  • user.name = "users/{user}"
  • emoji.unicode = "🙂" OR emoji.custom_emoji.uid = "{uid}"
  • AND user.name = "users/{user}"
  • Invalid queries are rejected by the server with an INVALID_ARGUMENT
  • error. */ // const filter = 'abc123'

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callListReactions() { // Construct request const request = { parent, };

    // Run request const iterable = chatClient.listReactionsAsync(request); for await (const response of iterable) { console.log(response); } }

    callListReactions();

listReactionsStream(request, options)

listReactionsStream(request?: protos.google.chat.v1.IListReactionsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request IListReactionsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing Reaction on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listReactionsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSpaceEvents(request, options)

listSpaceEvents(request?: protos.google.chat.v1.IListSpaceEventsRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpaceEvent[],
        protos.google.chat.v1.IListSpaceEventsRequest | null,
        protos.google.chat.v1.IListSpaceEventsResponse
    ]>;

Lists events from a Google Chat space. For each event, the [payload](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.oneof_payload) contains the most recent version of the Chat resource. For example, if you list events about new space members, the server returns Membership resources that contain the latest membership details. If new members were removed during the requested period, the event payload contains an empty Membership resource.

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user). To list events, the authenticated user must be a member of the space.

For an example, see [List events from a Google Chat space](https://developers.google.com/workspace/chat/list-space-events).

Parameters
Name Description
request IListSpaceEventsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpaceEvent[], protos.google.chat.v1.IListSpaceEventsRequest | null, protos.google.chat.v1.IListSpaceEventsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of SpaceEvent. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listSpaceEventsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSpaceEvents(request, options, callback)

listSpaceEvents(request: protos.google.chat.v1.IListSpaceEventsRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.IListSpaceEventsRequest, protos.google.chat.v1.IListSpaceEventsResponse | null | undefined, protos.google.chat.v1.ISpaceEvent>): void;
Parameters
Name Description
request IListSpaceEventsRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.IListSpaceEventsRequest, protos.google.chat.v1.IListSpaceEventsResponse | null | undefined, protos.google.chat.v1.ISpaceEvent>
Returns
Type Description
void

listSpaceEvents(request, callback)

listSpaceEvents(request: protos.google.chat.v1.IListSpaceEventsRequest, callback: PaginationCallback<protos.google.chat.v1.IListSpaceEventsRequest, protos.google.chat.v1.IListSpaceEventsResponse | null | undefined, protos.google.chat.v1.ISpaceEvent>): void;
Parameters
Name Description
request IListSpaceEventsRequest
callback PaginationCallback<protos.google.chat.v1.IListSpaceEventsRequest, protos.google.chat.v1.IListSpaceEventsResponse | null | undefined, protos.google.chat.v1.ISpaceEvent>
Returns
Type Description
void

listSpaceEventsAsync(request, options)

listSpaceEventsAsync(request?: protos.google.chat.v1.IListSpaceEventsRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.ISpaceEvent>;

Equivalent to listSpaceEvents, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request IListSpaceEventsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.ISpaceEvent>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing SpaceEvent. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the Google Chat
   *  space (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces)
   *  where the events occurred.
   *  Format: `spaces/{space}`.
   */
  // const parent = 'abc123'
  /**
   *  Optional. The maximum number of space events returned. The service might
   *  return fewer than this value.
   *  Negative values return an `INVALID_ARGUMENT` error.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token, received from a previous list space events call.
   *  Provide this to retrieve the subsequent page.
   *  When paginating, all other parameters provided to list space events must
   *  match the call that provided the page token. Passing different values to
   *  the other parameters might lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Required. A query filter.
   *  You must specify at least one event type (`event_type`)
   *  using the has `:` operator. To filter by multiple event types, use the `OR`
   *  operator. Omit batch event types in your filter. The request automatically
   *  returns any related batch events. For example, if you filter by new
   *  reactions
   *  (`google.workspace.chat.reaction.v1.created`), the server also returns
   *  batch new reactions events
   *  (`google.workspace.chat.reaction.v1.batchCreated`). For a list of supported
   *  event types, see the `SpaceEvents` reference
   *  documentation (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.spaceEvents#SpaceEvent.FIELDS.event_type).
   *  Optionally, you can also filter by start time (`start_time`) and
   *  end time (`end_time`):
   *  * `start_time`: Exclusive timestamp from which to start listing space
   *  events.
   *   You can list events that occurred up to 28 days ago. If unspecified, lists
   *   space events from the past 28 days.
   *  * `end_time`: Inclusive timestamp until which space events are listed.
   *   If unspecified, lists events up to the time of the request.
   *  To specify a start or end time, use the equals `=` operator and format in
   *  RFC-3339 (https://www.rfc-editor.org/rfc/rfc3339). To filter by both
   *  `start_time` and `end_time`, use the `AND` operator.
   *  For example, the following queries are valid:
   *  

   *  start_time="2023-08-23T19:20:33+00:00" AND
   *  end_time="2023-08-23T19:21:54+00:00"
   *  
  • start_time="2023-08-23T19:20:33+00:00" AND
  • (event_types:"google.workspace.chat.space.v1.updated" OR
  • event_types:"google.workspace.chat.message.v1.created")
  • The following queries are invalid:
  • start_time="2023-08-23T19:20:33+00:00" OR
  • end_time="2023-08-23T19:21:54+00:00"
  • event_types:"google.workspace.chat.space.v1.updated" AND
  • event_types:"google.workspace.chat.message.v1.created"
  • Invalid queries are rejected by the server with an INVALID_ARGUMENT
  • error. */ // const filter = 'abc123'

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callListSpaceEvents() { // Construct request const request = { parent, filter, };

    // Run request const iterable = chatClient.listSpaceEventsAsync(request); for await (const response of iterable) { console.log(response); } }

    callListSpaceEvents();

listSpaceEventsStream(request, options)

listSpaceEventsStream(request?: protos.google.chat.v1.IListSpaceEventsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request IListSpaceEventsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing SpaceEvent on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listSpaceEventsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSpaces(request, options)

listSpaces(request?: protos.google.chat.v1.IListSpacesRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace[],
        protos.google.chat.v1.IListSpacesRequest | null,
        protos.google.chat.v1.IListSpacesResponse
    ]>;

Lists spaces the caller is a member of. Group chats and DMs aren't listed until the first message is sent. For an example, see [List spaces](https://developers.google.com/workspace/chat/list-spaces).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

To list all named spaces by Google Workspace organization, use the [spaces.search()](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces/search) method using Workspace administrator privileges instead.

Parameters
Name Description
request IListSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace[], protos.google.chat.v1.IListSpacesRequest | null, protos.google.chat.v1.IListSpacesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listSpacesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listSpaces(request, options, callback)

listSpaces(request: protos.google.chat.v1.IListSpacesRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.IListSpacesRequest, protos.google.chat.v1.IListSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>): void;
Parameters
Name Description
request IListSpacesRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.IListSpacesRequest, protos.google.chat.v1.IListSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>
Returns
Type Description
void

listSpaces(request, callback)

listSpaces(request: protos.google.chat.v1.IListSpacesRequest, callback: PaginationCallback<protos.google.chat.v1.IListSpacesRequest, protos.google.chat.v1.IListSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>): void;
Parameters
Name Description
request IListSpacesRequest
callback PaginationCallback<protos.google.chat.v1.IListSpacesRequest, protos.google.chat.v1.IListSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>
Returns
Type Description
void

listSpacesAsync(request, options)

listSpacesAsync(request?: protos.google.chat.v1.IListSpacesRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.ISpace>;

Equivalent to listSpaces, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request IListSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.ISpace>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Optional. The maximum number of spaces to return. The service might return
   *  fewer than this value.
   *  If unspecified, at most 100 spaces are returned.
   *  The maximum value is 1000. If you use a value more than 1000, it's
   *  automatically changed to 1000.
   *  Negative values return an `INVALID_ARGUMENT` error.
   */
  // const pageSize = 1234
  /**
   *  Optional. A page token, received from a previous list spaces call.
   *  Provide this parameter to retrieve the subsequent page.
   *  When paginating, the filter value should match the call that provided the
   *  page token. Passing a different value may lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. A query filter.
   *  You can filter spaces by the space type
   *  (`space_type` (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#spacetype)).
   *  To filter by space type, you must specify valid enum value, such as
   *  `SPACE` or `GROUP_CHAT` (the `space_type` can't be
   *  `SPACE_TYPE_UNSPECIFIED`). To query for multiple space types, use the `OR`
   *  operator.
   *  For example, the following queries are valid:
   *  

   *  space_type = "SPACE"
   *  spaceType = "GROUP_CHAT" OR spaceType = "DIRECT_MESSAGE"
   *  
  • Invalid queries are rejected by the server with an INVALID_ARGUMENT
  • error. */ // const filter = 'abc123'

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callListSpaces() { // Construct request const request = { };

    // Run request const iterable = chatClient.listSpacesAsync(request); for await (const response of iterable) { console.log(response); } }

    callListSpaces();

listSpacesStream(request, options)

listSpacesStream(request?: protos.google.chat.v1.IListSpacesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request IListSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listSpacesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchAttachmentFromAttachmentName(attachmentName)

matchAttachmentFromAttachmentName(attachmentName: string): string | number;

Parse the attachment from Attachment resource.

Parameter
Name Description
attachmentName string

A fully-qualified path representing Attachment resource.

Returns
Type Description
string | number

{string} A string representing the attachment.

matchMemberFromMembershipName(membershipName)

matchMemberFromMembershipName(membershipName: string): string | number;

Parse the member from Membership resource.

Parameter
Name Description
membershipName string

A fully-qualified path representing Membership resource.

Returns
Type Description
string | number

{string} A string representing the member.

matchMessageFromAttachmentName(attachmentName)

matchMessageFromAttachmentName(attachmentName: string): string | number;

Parse the message from Attachment resource.

Parameter
Name Description
attachmentName string

A fully-qualified path representing Attachment resource.

Returns
Type Description
string | number

{string} A string representing the message.

matchMessageFromMessageName(messageName)

matchMessageFromMessageName(messageName: string): string | number;

Parse the message from Message resource.

Parameter
Name Description
messageName string

A fully-qualified path representing Message resource.

Returns
Type Description
string | number

{string} A string representing the message.

matchMessageFromQuotedMessageMetadataName(quotedMessageMetadataName)

matchMessageFromQuotedMessageMetadataName(quotedMessageMetadataName: string): string | number;

Parse the message from QuotedMessageMetadata resource.

Parameter
Name Description
quotedMessageMetadataName string

A fully-qualified path representing QuotedMessageMetadata resource.

Returns
Type Description
string | number

{string} A string representing the message.

matchMessageFromReactionName(reactionName)

matchMessageFromReactionName(reactionName: string): string | number;

Parse the message from Reaction resource.

Parameter
Name Description
reactionName string

A fully-qualified path representing Reaction resource.

Returns
Type Description
string | number

{string} A string representing the message.

matchQuotedMessageMetadataFromQuotedMessageMetadataName(quotedMessageMetadataName)

matchQuotedMessageMetadataFromQuotedMessageMetadataName(quotedMessageMetadataName: string): string | number;

Parse the quoted_message_metadata from QuotedMessageMetadata resource.

Parameter
Name Description
quotedMessageMetadataName string

A fully-qualified path representing QuotedMessageMetadata resource.

Returns
Type Description
string | number

{string} A string representing the quoted_message_metadata.

matchReactionFromReactionName(reactionName)

matchReactionFromReactionName(reactionName: string): string | number;

Parse the reaction from Reaction resource.

Parameter
Name Description
reactionName string

A fully-qualified path representing Reaction resource.

Returns
Type Description
string | number

{string} A string representing the reaction.

matchSpaceEventFromSpaceEventName(spaceEventName)

matchSpaceEventFromSpaceEventName(spaceEventName: string): string | number;

Parse the space_event from SpaceEvent resource.

Parameter
Name Description
spaceEventName string

A fully-qualified path representing SpaceEvent resource.

Returns
Type Description
string | number

{string} A string representing the space_event.

matchSpaceFromAttachmentName(attachmentName)

matchSpaceFromAttachmentName(attachmentName: string): string | number;

Parse the space from Attachment resource.

Parameter
Name Description
attachmentName string

A fully-qualified path representing Attachment resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromMembershipName(membershipName)

matchSpaceFromMembershipName(membershipName: string): string | number;

Parse the space from Membership resource.

Parameter
Name Description
membershipName string

A fully-qualified path representing Membership resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromMessageName(messageName)

matchSpaceFromMessageName(messageName: string): string | number;

Parse the space from Message resource.

Parameter
Name Description
messageName string

A fully-qualified path representing Message resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromQuotedMessageMetadataName(quotedMessageMetadataName)

matchSpaceFromQuotedMessageMetadataName(quotedMessageMetadataName: string): string | number;

Parse the space from QuotedMessageMetadata resource.

Parameter
Name Description
quotedMessageMetadataName string

A fully-qualified path representing QuotedMessageMetadata resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromReactionName(reactionName)

matchSpaceFromReactionName(reactionName: string): string | number;

Parse the space from Reaction resource.

Parameter
Name Description
reactionName string

A fully-qualified path representing Reaction resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromSpaceEventName(spaceEventName)

matchSpaceFromSpaceEventName(spaceEventName: string): string | number;

Parse the space from SpaceEvent resource.

Parameter
Name Description
spaceEventName string

A fully-qualified path representing SpaceEvent resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromSpaceName(spaceName)

matchSpaceFromSpaceName(spaceName: string): string | number;

Parse the space from Space resource.

Parameter
Name Description
spaceName string

A fully-qualified path representing Space resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromSpaceReadStateName(spaceReadStateName)

matchSpaceFromSpaceReadStateName(spaceReadStateName: string): string | number;

Parse the space from SpaceReadState resource.

Parameter
Name Description
spaceReadStateName string

A fully-qualified path representing SpaceReadState resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromThreadName(threadName)

matchSpaceFromThreadName(threadName: string): string | number;

Parse the space from Thread resource.

Parameter
Name Description
threadName string

A fully-qualified path representing Thread resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchSpaceFromThreadReadStateName(threadReadStateName)

matchSpaceFromThreadReadStateName(threadReadStateName: string): string | number;

Parse the space from ThreadReadState resource.

Parameter
Name Description
threadReadStateName string

A fully-qualified path representing ThreadReadState resource.

Returns
Type Description
string | number

{string} A string representing the space.

matchThreadFromThreadName(threadName)

matchThreadFromThreadName(threadName: string): string | number;

Parse the thread from Thread resource.

Parameter
Name Description
threadName string

A fully-qualified path representing Thread resource.

Returns
Type Description
string | number

{string} A string representing the thread.

matchThreadFromThreadReadStateName(threadReadStateName)

matchThreadFromThreadReadStateName(threadReadStateName: string): string | number;

Parse the thread from ThreadReadState resource.

Parameter
Name Description
threadReadStateName string

A fully-qualified path representing ThreadReadState resource.

Returns
Type Description
string | number

{string} A string representing the thread.

matchUserFromSpaceReadStateName(spaceReadStateName)

matchUserFromSpaceReadStateName(spaceReadStateName: string): string | number;

Parse the user from SpaceReadState resource.

Parameter
Name Description
spaceReadStateName string

A fully-qualified path representing SpaceReadState resource.

Returns
Type Description
string | number

{string} A string representing the user.

matchUserFromThreadReadStateName(threadReadStateName)

matchUserFromThreadReadStateName(threadReadStateName: string): string | number;

Parse the user from ThreadReadState resource.

Parameter
Name Description
threadReadStateName string

A fully-qualified path representing ThreadReadState resource.

Returns
Type Description
string | number

{string} A string representing the user.

membershipPath(space, member)

membershipPath(space: string, member: string): string;

Return a fully-qualified membership resource name string.

Parameters
Name Description
space string
member string
Returns
Type Description
string

{string} Resource name string.

messagePath(space, message)

messagePath(space: string, message: string): string;

Return a fully-qualified message resource name string.

Parameters
Name Description
space string
message string
Returns
Type Description
string

{string} Resource name string.

quotedMessageMetadataPath(space, message, quotedMessageMetadata)

quotedMessageMetadataPath(space: string, message: string, quotedMessageMetadata: string): string;

Return a fully-qualified quotedMessageMetadata resource name string.

Parameters
Name Description
space string
message string
quotedMessageMetadata string
Returns
Type Description
string

{string} Resource name string.

reactionPath(space, message, reaction)

reactionPath(space: string, message: string, reaction: string): string;

Return a fully-qualified reaction resource name string.

Parameters
Name Description
space string
message string
reaction string
Returns
Type Description
string

{string} Resource name string.

searchSpaces(request, options)

searchSpaces(request?: protos.google.chat.v1.ISearchSpacesRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace[],
        protos.google.chat.v1.ISearchSpacesRequest | null,
        protos.google.chat.v1.ISearchSpacesResponse
    ]>;

Returns a list of spaces in a Google Workspace organization based on an administrator's search.

Requires [user authentication with administrator privileges](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user#admin-privileges). In the request, set use_admin_access to true.

Parameters
Name Description
request ISearchSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace[], protos.google.chat.v1.ISearchSpacesRequest | null, protos.google.chat.v1.ISearchSpacesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using searchSpacesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

searchSpaces(request, options, callback)

searchSpaces(request: protos.google.chat.v1.ISearchSpacesRequest, options: CallOptions, callback: PaginationCallback<protos.google.chat.v1.ISearchSpacesRequest, protos.google.chat.v1.ISearchSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>): void;
Parameters
Name Description
request ISearchSpacesRequest
options CallOptions
callback PaginationCallback<protos.google.chat.v1.ISearchSpacesRequest, protos.google.chat.v1.ISearchSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>
Returns
Type Description
void

searchSpaces(request, callback)

searchSpaces(request: protos.google.chat.v1.ISearchSpacesRequest, callback: PaginationCallback<protos.google.chat.v1.ISearchSpacesRequest, protos.google.chat.v1.ISearchSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>): void;
Parameters
Name Description
request ISearchSpacesRequest
callback PaginationCallback<protos.google.chat.v1.ISearchSpacesRequest, protos.google.chat.v1.ISearchSpacesResponse | null | undefined, protos.google.chat.v1.ISpace>
Returns
Type Description
void

searchSpacesAsync(request, options)

searchSpacesAsync(request?: protos.google.chat.v1.ISearchSpacesRequest, options?: CallOptions): AsyncIterable<protos.google.chat.v1.ISpace>;

Equivalent to searchSpaces, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
Name Description
request ISearchSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.chat.v1.ISpace>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires either the `chat.admin.spaces.readonly` or `chat.admin.spaces`
   *  OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   *  This method currently only supports admin access, thus only `true` is
   *  accepted for this field.
   */
  // const useAdminAccess = true
  /**
   *  The maximum number of spaces to return. The service may return fewer than
   *  this value.
   *  If unspecified, at most 100 spaces are returned.
   *  The maximum value is 1000. If you use a value more than 1000, it's
   *  automatically changed to 1000.
   */
  // const pageSize = 1234
  /**
   *  A token, received from the previous search spaces call. Provide this
   *  parameter to retrieve the subsequent page.
   *  When paginating, all other parameters provided should match the call that
   *  provided the page token. Passing different values to the other parameters
   *  might lead to unexpected results.
   */
  // const pageToken = 'abc123'
  /**
   *  Required. A search query.
   *  You can search by using the following parameters:
   *  - `create_time`
   *  - `customer`
   *  - `display_name`
   *  - `external_user_allowed`
   *  - `last_active_time`
   *  - `space_history_state`
   *  - `space_type`
   *  `create_time` and `last_active_time` accept a timestamp in
   *  RFC-3339 (https://www.rfc-editor.org/rfc/rfc3339) format and the supported
   *  comparison operators are: `=`, `<`, `="">`, `<=`, `="">=`.
   *  `customer` is required and is used to indicate which customer
   *  to fetch spaces from. `customers/my_customer` is the only supported value.
   *  `display_name` only accepts the `HAS` (`:`) operator. The text to
   *  match is first tokenized into tokens and each token is prefix-matched
   *  case-insensitively and independently as a substring anywhere in the space's
   *  `display_name`. For example, `Fun Eve` matches `Fun event` or `The
   *  evening was fun`, but not `notFun event` or `even`.
   *  `external_user_allowed` accepts either `true` or `false`.
   *  `space_history_state` only accepts values from the `historyState` 
   *  (https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces#Space.HistoryState)
   *  field of a `space` resource.
   *  `space_type` is required and the only valid value is `SPACE`.
   *  Across different fields, only `AND` operators are supported. A valid
   *  example is `space_type = "SPACE" AND display_name:"Hello"` and an invalid
   *  example is `space_type = "SPACE" OR display_name:"Hello"`.
   *  Among the same field,
   *  `space_type` doesn't support `AND` or `OR` operators.
   *  `display_name`, 'space_history_state', and 'external_user_allowed' only
   *  support `OR` operators.
   *  `last_active_time` and `create_time` support both `AND` and `OR` operators.
   *  `AND` can only be used to represent an interval, such as `last_active_time
   *  < "2022-01-01t00:00:00+00:00"="" and="" last_active_time="">
   *  "2023-01-01T00:00:00+00:00"`.
   *  The following example queries are valid:
   *  

   *  customer = "customers/my_customer" AND space_type = "SPACE"
   *  customer = "customers/my_customer" AND space_type = "SPACE" AND
   *  display_name:"Hello World"
   *  customer = "customers/my_customer" AND space_type = "SPACE" AND
   *  (last_active_time < "2020-01-01t00:00:00+00:00"="" or="" last_active_time="">
   *  "2022-01-01T00:00:00+00:00")
   *  customer = "customers/my_customer" AND space_type = "SPACE" AND
   *  (display_name:"Hello World" OR display_name:"Fun event") AND
   *  (last_active_time > "2020-01-01T00:00:00+00:00" AND last_active_time < *="" "2022-01-01t00:00:00+00:00")="" *="" customer="customers/my_customer" and="" space_type="SPACE" and="" *="" (create_time=""> "2019-01-01T00:00:00+00:00" AND create_time < *="" "2020-01-01t00:00:00+00:00")="" and="" (external_user_allowed="true" )="" and="" *="" (space_history_state="HISTORY_ON" or="" space_history_state="HISTORY_OFF" )="" *="">

/ // const query = 'abc123' /*

  • Optional. How the list of spaces is ordered.
  • Supported attributes to order by are:
    • membership_count.joined_direct_human_user_count — Denotes the count of
  • human users that have directly joined a space.
    • last_active_time — Denotes the time when last eligible item is added to
  • any topic of this space.
    • create_time — Denotes the time of the space creation.
  • Valid ordering operation values are:
    • ASC for ascending. Default value.
    • DESC for descending.
  • The supported syntax are:
    • membership_count.joined_direct_human_user_count DESC
    • membership_count.joined_direct_human_user_count ASC
    • last_active_time DESC
    • last_active_time ASC
    • create_time DESC
    • create_time ASC */ // const orderBy = 'abc123'

    // Imports the Chat library const {ChatServiceClient} = require('@google-apps/chat').v1;

    // Instantiates a client const chatClient = new ChatServiceClient();

    async function callSearchSpaces() { // Construct request const request = { query, };

    // Run request const iterable = chatClient.searchSpacesAsync(request); for await (const response of iterable) { console.log(response); } }

    callSearchSpaces();

searchSpacesStream(request, options)

searchSpacesStream(request?: protos.google.chat.v1.ISearchSpacesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
Name Description
request ISearchSpacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using searchSpacesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

setUpSpace(request, options)

setUpSpace(request?: protos.google.chat.v1.ISetUpSpaceRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace,
        protos.google.chat.v1.ISetUpSpaceRequest | undefined,
        {} | undefined
    ]>;

Creates a space and adds specified users to it. The calling user is automatically added to the space, and shouldn't be specified as a membership in the request. For an example, see [Set up a space with initial members](https://developers.google.com/workspace/chat/set-up-spaces).

To specify the human members to add, add memberships with the appropriate membership.member.name. To add a human user, use users/{user}, where {user} can be the email address for the user. For users in the same Workspace organization {user} can also be the id for the person from the People API, or the id for the user in the Directory API. For example, if the People API Person profile ID for user@example.com is 123456789, you can add the user to the space by setting the membership.member.name to users/user@example.com or users/123456789.

To specify the Google groups to add, add memberships with the appropriate membership.group_member.name. To add or invite a Google group, use groups/{group}, where {group} is the id for the group from the Cloud Identity Groups API. For example, you can use [Cloud Identity Groups lookup API](https://cloud.google.com/identity/docs/reference/rest/v1/groups/lookup) to retrieve the ID 123456789 for group email group@example.com, then you can add the group to the space by setting the membership.group_member.name to groups/123456789. Group email is not supported, and Google groups can only be added as members in named spaces.

For a named space or group chat, if the caller blocks, or is blocked by some members, or doesn't have permission to add some members, then those members aren't added to the created space.

To create a direct message (DM) between the calling user and another human user, specify exactly one membership to represent the human user. If one user blocks the other, the request fails and the DM isn't created.

To create a DM between the calling user and the calling app, set Space.singleUserBotDm to true and don't specify any memberships. You can only use this method to set up a DM with the calling app. To add the calling app as a member of a space or an existing DM between two human users, see [Invite or add a user or app to a space](https://developers.google.com/workspace/chat/create-members).

If a DM already exists between two users, even when one user blocks the other at the time a request is made, then the existing DM is returned.

Spaces with threaded replies aren't supported. If you receive the error message ALREADY_EXISTS when setting up a space, try a different displayName. An existing space within the Google Workspace organization might already use this display name.

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request ISetUpSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace, protos.google.chat.v1.ISetUpSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The `Space.spaceType` field is required.
   *  To create a space, set `Space.spaceType` to `SPACE` and set
   *  `Space.displayName`. If you receive the error message `ALREADY_EXISTS` when
   *  setting up a space, try a different `displayName`. An existing space
   *  within the Google Workspace organization might already use this display
   *  name.
   *  To create a group chat, set `Space.spaceType` to
   *  `GROUP_CHAT`. Don't set `Space.displayName`.
   *  To create a 1:1 conversation between humans,
   *  set `Space.spaceType` to `DIRECT_MESSAGE` and set
   *  `Space.singleUserBotDm` to `false`. Don't set `Space.displayName` or
   *  `Space.spaceDetails`.
   *  To create an 1:1 conversation between a human and the calling Chat app, set
   *  `Space.spaceType` to `DIRECT_MESSAGE` and
   *  `Space.singleUserBotDm` to `true`. Don't set `Space.displayName` or
   *  `Space.spaceDetails`.
   *  If a `DIRECT_MESSAGE` space already exists, that space is returned instead
   *  of creating a new space.
   */
  // const space = {}
  /**
   *  Optional. A unique identifier for this request.
   *  A random UUID is recommended.
   *  Specifying an existing request ID returns the space created with that ID
   *  instead of creating a new space.
   *  Specifying an existing request ID from the same Chat app with a different
   *  authenticated user returns an error.
   */
  // const requestId = 'abc123'
  /**
   *  Optional. The Google Chat users or groups to invite to join the space. Omit
   *  the calling user, as they are added automatically.
   *  The set currently allows up to 20 memberships (in addition to the caller).
   *  For human membership, the `Membership.member` field must contain a `user`
   *  with `name` populated (format: `users/{user}`) and `type` set to
   *  `User.Type.HUMAN`. You can only add human users when setting up a space
   *  (adding Chat apps is only supported for direct message setup with the
   *  calling app). You can also add members using the user's email as an alias
   *  for {user}. For example, the `user.name` can be `users/example@gmail.com`.
   *  To invite Gmail users or users from external Google Workspace domains,
   *  user's email must be used for `{user}`.
   *  For Google group membership, the `Membership.group_member` field must
   *  contain a `group` with `name` populated (format `groups/{group}`). You
   *  can only add Google groups when setting `Space.spaceType` to `SPACE`.
   *  Optional when setting `Space.spaceType` to `SPACE`.
   *  Required when setting `Space.spaceType` to `GROUP_CHAT`, along with at
   *  least two memberships.
   *  Required when setting `Space.spaceType` to `DIRECT_MESSAGE` with a human
   *  user, along with exactly one membership.
   *  Must be empty when creating a 1:1 conversation between a human and the
   *  calling Chat app (when setting `Space.spaceType` to
   *  `DIRECT_MESSAGE` and `Space.singleUserBotDm` to `true`).
   */
  // const memberships = [1,2,3,4]

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callSetUpSpace() {
    // Construct request
    const request = {
      space,
    };

    // Run request
    const response = await chatClient.setUpSpace(request);
    console.log(response);
  }

  callSetUpSpace();

setUpSpace(request, options, callback)

setUpSpace(request: protos.google.chat.v1.ISetUpSpaceRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ISetUpSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISetUpSpaceRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ISetUpSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

setUpSpace(request, callback)

setUpSpace(request: protos.google.chat.v1.ISetUpSpaceRequest, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ISetUpSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISetUpSpaceRequest
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.ISetUpSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

spaceEventPath(space, spaceEvent)

spaceEventPath(space: string, spaceEvent: string): string;

Return a fully-qualified spaceEvent resource name string.

Parameters
Name Description
space string
spaceEvent string
Returns
Type Description
string

{string} Resource name string.

spacePath(space)

spacePath(space: string): string;

Return a fully-qualified space resource name string.

Parameter
Name Description
space string
Returns
Type Description
string

{string} Resource name string.

spaceReadStatePath(user, space)

spaceReadStatePath(user: string, space: string): string;

Return a fully-qualified spaceReadState resource name string.

Parameters
Name Description
user string
space string
Returns
Type Description
string

{string} Resource name string.

threadPath(space, thread)

threadPath(space: string, thread: string): string;

Return a fully-qualified thread resource name string.

Parameters
Name Description
space string
thread string
Returns
Type Description
string

{string} Resource name string.

threadReadStatePath(user, space, thread)

threadReadStatePath(user: string, space: string, thread: string): string;

Return a fully-qualified threadReadState resource name string.

Parameters
Name Description
user string
space string
thread string
Returns
Type Description
string

{string} Resource name string.

updateMembership(request, options)

updateMembership(request?: protos.google.chat.v1.IUpdateMembershipRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMembership,
        protos.google.chat.v1.IUpdateMembershipRequest | undefined,
        {} | undefined
    ]>;

Updates a membership. For an example, see [Update a user's membership in a space](https://developers.google.com/workspace/chat/update-members).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IUpdateMembershipRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMembership, protos.google.chat.v1.IUpdateMembershipRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The membership to update. Only fields specified by `update_mask`
   *  are updated.
   */
  // const membership = {}
  /**
   *  Required. The field paths to update. Separate multiple values with commas
   *  or use `*` to update all field paths.
   *  Currently supported field paths:
   *  - `role`
   */
  // const updateMask = {}
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.memberships` OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callUpdateMembership() {
    // Construct request
    const request = {
      membership,
      updateMask,
    };

    // Run request
    const response = await chatClient.updateMembership(request);
    console.log(response);
  }

  callUpdateMembership();

updateMembership(request, options, callback)

updateMembership(request: protos.google.chat.v1.IUpdateMembershipRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IUpdateMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateMembershipRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IUpdateMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateMembership(request, callback)

updateMembership(request: protos.google.chat.v1.IUpdateMembershipRequest, callback: Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IUpdateMembershipRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateMembershipRequest
callback Callback<protos.google.chat.v1.IMembership, protos.google.chat.v1.IUpdateMembershipRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateMessage(request, options)

updateMessage(request?: protos.google.chat.v1.IUpdateMessageRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IMessage,
        protos.google.chat.v1.IUpdateMessageRequest | undefined,
        {} | undefined
    ]>;

Updates a message. There's a difference between the patch and update methods. The patch method uses a patch request while the update method uses a put request. We recommend using the patch method. For an example, see [Update a message](https://developers.google.com/workspace/chat/update-messages).

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

When using app authentication, requests can only update messages created by the calling Chat app.

Parameters
Name Description
request IUpdateMessageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IMessage, protos.google.chat.v1.IUpdateMessageRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Message. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Message with fields updated.
   */
  // const message = {}
  /**
   *  Required. The field paths to update. Separate multiple values with commas
   *  or use `*` to update all field paths.
   *  Currently supported field paths:
   *  - `text`
   *  - `attachment`
   *  - `cards` (Requires app
   *  authentication (/chat/api/guides/auth/service-accounts).)
   *  - `cards_v2`  (Requires app
   *  authentication (/chat/api/guides/auth/service-accounts).)
   *  - `accessory_widgets`  (Requires app
   *  authentication (/chat/api/guides/auth/service-accounts).)
   */
  // const updateMask = {}
  /**
   *  Optional. If `true` and the message isn't found, a new message is created
   *  and `updateMask` is ignored. The specified message ID must be
   *  client-assigned (https://developers.google.com/workspace/chat/create-messages#name_a_created_message)
   *  or the request fails.
   */
  // const allowMissing = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callUpdateMessage() {
    // Construct request
    const request = {
      message,
      updateMask,
    };

    // Run request
    const response = await chatClient.updateMessage(request);
    console.log(response);
  }

  callUpdateMessage();

updateMessage(request, options, callback)

updateMessage(request: protos.google.chat.v1.IUpdateMessageRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IUpdateMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateMessageRequest
options CallOptions
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IUpdateMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateMessage(request, callback)

updateMessage(request: protos.google.chat.v1.IUpdateMessageRequest, callback: Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IUpdateMessageRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateMessageRequest
callback Callback<protos.google.chat.v1.IMessage, protos.google.chat.v1.IUpdateMessageRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateSpace(request, options)

updateSpace(request?: protos.google.chat.v1.IUpdateSpaceRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpace,
        protos.google.chat.v1.IUpdateSpaceRequest | undefined,
        {} | undefined
    ]>;

Updates a space. For an example, see [Update a space](https://developers.google.com/workspace/chat/update-spaces).

If you're updating the displayName field and receive the error message ALREADY_EXISTS, try a different display name.. An existing space within the Google Workspace organization might already use this display name.

Supports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):

Parameters
Name Description
request IUpdateSpaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpace, protos.google.chat.v1.IUpdateSpaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Space with fields to be updated. `Space.name` must be
   *  populated in the form of `spaces/{space}`. Only fields
   *  specified by `update_mask` are updated.
   */
  // const space = {}
  /**
   *  Required. The updated field paths, comma separated if there are
   *  multiple.
   *  You can update the following fields for a space:
   *  `space_details`: Updates the space's description. Supports up to 150
   *  characters.
   *  `display_name`: Only supports updating the display name for spaces where
   *  `spaceType` field is `SPACE`.
   *   If you receive the error message `ALREADY_EXISTS`, try a different
   *   value. An existing space within the
   *  Google Workspace organization might already use this display name.
   *  `space_type`: Only supports changing a `GROUP_CHAT` space type to
   *  `SPACE`. Include `display_name` together
   *  with `space_type` in the update mask and ensure that the specified space
   *  has a non-empty display name and the `SPACE` space type. Including the
   *  `space_type` mask and the `SPACE` type in the specified space when updating
   *  the display name is optional if the existing space already has the `SPACE`
   *  type. Trying to update the space type in other ways results in an invalid
   *  argument error.
   *  `space_type` is not supported with `useAdminAccess`.
   *  `space_history_state`: Updates space history
   *  settings (https://support.google.com/chat/answer/7664687) by turning
   *  history on or off for the space. Only supported if history settings are
   *  enabled for the Google Workspace organization. To update the
   *  space history state, you must omit all other field masks in your request.
   *  `space_history_state` is not supported with `useAdminAccess`.
   *  `access_settings.audience`: Updates the access
   *  setting (https://support.google.com/chat/answer/11971020) of who can
   *  discover the space, join the space, and preview the messages in named space
   *  where `spaceType` field is `SPACE`. If the existing space has a
   *  target audience, you can remove the audience and restrict space access by
   *  omitting a value for this field mask. To update access settings for a
   *  space, the authenticating user must be a space manager and omit all other
   *  field masks in your request. You can't update this field if the space is in
   *  import
   *  mode (https://developers.google.com/workspace/chat/import-data-overview).
   *  To learn more, see Make a space discoverable to specific
   *  users (https://developers.google.com/workspace/chat/space-target-audience).
   *  `access_settings.audience` is not supported with `useAdminAccess`.
   *  `permission_settings`: Supports changing the
   *  permission settings (https://support.google.com/chat/answer/13340792)
   *  of a space.
   *  When updating permission settings, you can only specify
   *  `permissionSettings` field masks; you cannot update other field masks
   *  at the same time. `permissionSettings` is not supported with
   *  `useAdminAccess`.
   *  The supported field masks include:
   *  - `permission_settings.manageMembersAndGroups`
   *  - `permission_settings.modifySpaceDetails`
   *  - `permission_settings.toggleHistory`
   *  - `permission_settings.useAtMentionAll`
   *  - `permission_settings.manageApps`
   *  - `permission_settings.manageWebhooks`
   *  - `permission_settings.replyMessages`
   */
  // const updateMask = {}
  /**
   *  Optional. When `true`, the method runs using the user's Google Workspace
   *  administrator privileges.
   *  The calling user must be a Google Workspace administrator with the
   *  manage chat and spaces conversations
   *  privilege (https://support.google.com/a/answer/13369245).
   *  Requires the `chat.admin.spaces` OAuth 2.0
   *  scope (https://developers.google.com/workspace/chat/authenticate-authorize#chat-api-scopes).
   *  Some `FieldMask` values are not supported using admin access. For details,
   *  see the description of `update_mask`.
   */
  // const useAdminAccess = true

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callUpdateSpace() {
    // Construct request
    const request = {
      space,
      updateMask,
    };

    // Run request
    const response = await chatClient.updateSpace(request);
    console.log(response);
  }

  callUpdateSpace();

updateSpace(request, options, callback)

updateSpace(request: protos.google.chat.v1.IUpdateSpaceRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IUpdateSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateSpaceRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IUpdateSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateSpace(request, callback)

updateSpace(request: protos.google.chat.v1.IUpdateSpaceRequest, callback: Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IUpdateSpaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateSpaceRequest
callback Callback<protos.google.chat.v1.ISpace, protos.google.chat.v1.IUpdateSpaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateSpaceReadState(request, options)

updateSpaceReadState(request?: protos.google.chat.v1.IUpdateSpaceReadStateRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.ISpaceReadState,
        protos.google.chat.v1.IUpdateSpaceReadStateRequest | undefined,
        {} | undefined
    ]>;

Updates a user's read state within a space, used to identify read and unread messages. For an example, see [Update a user's space read state](https://developers.google.com/workspace/chat/update-space-read-state).

Requires [user authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

Parameters
Name Description
request IUpdateSpaceReadStateRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IUpdateSpaceReadStateRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing SpaceReadState. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The space read state and fields to update.
   *  Only supports updating read state for the calling user.
   *  To refer to the calling user, set one of the following:
   *  - The `me` alias. For example, `users/me/spaces/{space}/spaceReadState`.
   *  - Their Workspace email address. For example,
   *  `users/user@example.com/spaces/{space}/spaceReadState`.
   *  - Their user id. For example,
   *  `users/123456789/spaces/{space}/spaceReadState`.
   *  Format: users/{user}/spaces/{space}/spaceReadState
   */
  // const spaceReadState = {}
  /**
   *  Required. The field paths to update. Currently supported field paths:
   *  - `last_read_time`
   *  When the `last_read_time` is before the latest message create time, the
   *  space appears as unread in the UI.
   *  To mark the space as read, set `last_read_time` to any value later (larger)
   *  than the latest message create time. The `last_read_time` is coerced to
   *  match the latest message create time. Note that the space read state only
   *  affects the read state of messages that are visible in the space's
   *  top-level conversation. Replies in threads are unaffected by this
   *  timestamp, and instead rely on the thread read state.
   */
  // const updateMask = {}

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callUpdateSpaceReadState() {
    // Construct request
    const request = {
      spaceReadState,
      updateMask,
    };

    // Run request
    const response = await chatClient.updateSpaceReadState(request);
    console.log(response);
  }

  callUpdateSpaceReadState();

updateSpaceReadState(request, options, callback)

updateSpaceReadState(request: protos.google.chat.v1.IUpdateSpaceReadStateRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IUpdateSpaceReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateSpaceReadStateRequest
options CallOptions
callback Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IUpdateSpaceReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

updateSpaceReadState(request, callback)

updateSpaceReadState(request: protos.google.chat.v1.IUpdateSpaceReadStateRequest, callback: Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IUpdateSpaceReadStateRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUpdateSpaceReadStateRequest
callback Callback<protos.google.chat.v1.ISpaceReadState, protos.google.chat.v1.IUpdateSpaceReadStateRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

uploadAttachment(request, options)

uploadAttachment(request?: protos.google.chat.v1.IUploadAttachmentRequest, options?: CallOptions): Promise<[
        protos.google.chat.v1.IUploadAttachmentResponse,
        protos.google.chat.v1.IUploadAttachmentRequest | undefined,
        {} | undefined
    ]>;

Uploads an attachment. For an example, see [Upload media as a file attachment](https://developers.google.com/workspace/chat/upload-media-attachments).

Requires user [authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user).

You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see [File types blocked by Google Chat](https://support.google.com/chat/answer/7651457?&co=GENIE.Platform%3DDesktop#File%20types%20blocked%20in%20Google%20Chat).

Parameters
Name Description
request IUploadAttachmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.chat.v1.IUploadAttachmentResponse, protos.google.chat.v1.IUploadAttachmentRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing UploadAttachmentResponse. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. Resource name of the Chat space in which the attachment is
   *  uploaded. Format "spaces/{space}".
   */
  // const parent = 'abc123'
  /**
   *  Required. The filename of the attachment, including the file extension.
   */
  // const filename = 'abc123'

  // Imports the Chat library
  const {ChatServiceClient} = require('@google-apps/chat').v1;

  // Instantiates a client
  const chatClient = new ChatServiceClient();

  async function callUploadAttachment() {
    // Construct request
    const request = {
      parent,
      filename,
    };

    // Run request
    const response = await chatClient.uploadAttachment(request);
    console.log(response);
  }

  callUploadAttachment();

uploadAttachment(request, options, callback)

uploadAttachment(request: protos.google.chat.v1.IUploadAttachmentRequest, options: CallOptions, callback: Callback<protos.google.chat.v1.IUploadAttachmentResponse, protos.google.chat.v1.IUploadAttachmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUploadAttachmentRequest
options CallOptions
callback Callback<protos.google.chat.v1.IUploadAttachmentResponse, protos.google.chat.v1.IUploadAttachmentRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

uploadAttachment(request, callback)

uploadAttachment(request: protos.google.chat.v1.IUploadAttachmentRequest, callback: Callback<protos.google.chat.v1.IUploadAttachmentResponse, protos.google.chat.v1.IUploadAttachmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IUploadAttachmentRequest
callback Callback<protos.google.chat.v1.IUploadAttachmentResponse, protos.google.chat.v1.IUploadAttachmentRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void