Create a Google Chat space and add members (original) (raw)

This guide explains how to use thesetUp()method on the Space resource of the Google Chat API to create a Chat space, and add members to it.

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

You can use the setUp() method to do any of the following:

When setting up a space, consider the following:

Prerequisites

Node.js

#set-up-environment).

Python

#set-up-environment).

Java

#set-up-environment).

Apps Script

Set up a space

To set up a space, pass the following in your request:

To create a DM between the calling user and another human user, specify a membership of the human user in your request.

To create a DM between the calling user and the calling app, setspace.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, seecreate a membership.

The following example creates a named space and creates one membership to the space for two human users (the authenticated user and one other user).

Node.js

Python

Java

Apps Script

To run the sample, replace the following:

To go to the space, use the space's resource ID to build the space's URL. You can get the resource ID from the space name in the Google Chat response body. For example, if your space's name is spaces/1234567, you can go to the space using the following URL:https://mail.google.com/chat/u/0/#chat/space/1234567.