Building a Google Chat user management tool

Most technical articles tell the story of a success, while only a few tell the story of a failure. The one you have before you is in the latter category. Somewhat.

But failure can teach powerful lessons.

While I was initially tempted to scrap this planned post and swiftly move on to sunnier apps scripting fields —after all, we all prefer to be our brightest and most triumphant selves when publishing content— I've decided instead to put pen to paper and tell you this short tale of defeat.

Please, indulge me 🙏.

Ever since I discovered last month that the ability to authenticate to the Google Chat API with user credentials was generally available, I've been more and more inclined to build tools to ease the burden on domain administrators when it comes to managing Google Chat rooms and users.

Some weeks ago, I released Google Chat Majordomo, an Apps Script automation based on Google Sheets that provides an easy way for process managers to review and approve membership requests submitted by users who whant to join chat spaces using a form (you may want to have a look at the full post here).

đź“ť Adding users to Google Chat spaces on demand with Apps Script

If you already read it (thanks), you may recall that one of the design decisions we made at the time was that only internal domain users would be able to perform such requests. And trying to get around that restriction later opened up a whole new can of worms.

But before this approval workflow got in the way, my ultimate goal in approaching the Google Chat API was to build a tool that could synchronize lists of users, stored in different worksheets of a Google spreadsheet, with their corresponding Google Chat spaces on a nightly basis

An just because I happen to be the guy who manages this lovely Google Workspace thing at my school, in fact two Workspace accounts as we are actually two schools sharing some resources and staff, this tool would ideally be able to handle users coming from different domains. And also users who have regular Google user accounts, for the occasional external contractor.

So now you are sufficiently acquainted with the general plot of this tale of One Man and his API, let's get into scripting time!

Maurice Moss, from the IT Crowd sitcom, yelling awkwardly.

TABLE OF CONTENTS

The API and its M.U.E. (Most Useful Endpoints)

 

How to deploy our (attempt at a) Chat User Management Tool™

 

A generalized Apps Script function to hit the Chat API hard.

 

Listing Chat spaces

 

Listing members of a Chat space

 

The Blues of External Users (part I)

 

Messing up with the People API

 

Removing members from a Chat space

 

Adding members to a Chat space

 

The Blues of External Users (part II)

 

A full Chat space member sync?

 

Final comments and next steps

 

 

 

 

Comentarios