The Google Chat API updates are in developer preview. To use the API, developers can apply for access through our Google Workspace Developer Preview Program.
With the launch of the Google Chat API, developers have been able to extend their Chat apps to let users send and receive messaging data between Google Chat and other systems. This real-time collaboration is a critical factor in Chat apps being used in incident management, helpdesk support, workflow automations, and more.
In order to further enhance Chat apps for real-time collaboration, we are excited to announce that Chat apps can now create spaces and memberships - using application identity - through the Google Workspace Developer Preview Program via the Google Chat API!
Chat apps previously have been able to create spaces and memberships on behalf of users. Now, a Chat app can create spaces and memberships using its own application identity - without needing to create these on behalf of a user - to allow for even more sophisticated and autonomous Chat apps.
For example in an incident management scenario, a Chat app can quickly create a space, without any members, if it detects an incident or a service not responding. This Chat app can continue to diagnose and troubleshoot the issue, writing messages into the Chat space, and when the Chat app has determined the correct teams to loop in, it can add in the appropriate incident commanders, site reliability engineers and support teams, and anyone else needed to help resolve the issue.
You can enable this capability with new Chat app-specific OAuth scopes. Using these application scopes, Chat apps can create spaces, create messages, delete spaces that the app created, and more.
Code snippet of the new Chat application scopes and creating a Chat space using the application identity:
const auth = new chat.auth.GoogleAuth({
keyFilename: 'credentials.json',
scopes: [
'https://www.googleapis.com/auth/chat.app.spaces.create',
'https://www.googleapis.com/auth/chat.app.spaces',
'https://www.googleapis.com/auth/chat.app.delete',
'https://www.googleapis.com/auth/chat.app.memberships'
]
});
const authClient = await auth.getClient();
chatClient await chat.chat({
version: 'v1',
auth: authClient
});
space = await chatClient.spaces.create({
requestBody: {
spaceType: 'SPACE',
displayName: 'Incident Management space',
customer: 'customers/my_customer'
}
});
How to get started: