Find a direct message (DM) space (original) (raw)

This guide explains how to use thefindDirectMessage()method on the Space resource of the Google Chat API to get details about a direct message (DM) space.

TheSpace resourcerepresents a place where people and Chat apps can send messages, share files, and collaborate. There are several types of spaces:

When a Google Workspace administratorinstalls a Chat app for their entire Google Workspace organization, Google Chat creates a DM between the installed Chat app and each user in the organization.

Authenticating withapp authenticationlets a Chat app get DMs that the Chat app has access to in Google Chat (for example, DMs it's a member of). Authenticating withuser authentication returns DMs that the authenticated user has access to.

Prerequisites

Node.js

To find a direct message in Google Chat, pass the following in your request:

Find a direct message with user authentication

Here's how to find a direct message withuser authentication:

Node.js

To run this sample, replace USER_NAME with the ID from the user'snamefield.

The Chat API returns an instance ofSpacethat details the specified DM.

Find a direct message with app authentication

Here's how to find a direct message withapp authentication:

Node.js

To run this sample, replace USER_NAME with the ID from the user'snamefield.

The Chat API returns an instance ofSpacethat details the specified DM.