This contains a small list of suggested updates for the Chat App that was shared on August 25, 2022 as a part of the Creating Google Workspace chat apps—what developers need to know live intro.
Link to Chat App code lab.
It seems that the tutorial was built with the old Apps Script IDE in mind that is due to be sunsetted soon (At the time of writing this).
I am grateful for the tutorial and appreciate all the work put into it.
Note: I am sure that the tutorial was written with a particular style guide in mind. I've tried to keep the language and style as close to the original, but I have no knowledge of the guide.
Original text is quoted, suggested revision is below it
Click File > Rename... and rename the new script ‘Attendance Bot'.
In the top-left of the editor, click on 'Untitled project' and rename the new script ‘Attendance Bot'.
Green note reads:
Note: You can also create a Google Chat app from a template. To do so, in the Apps Script Editor click Help > Welcome screen. In the dialog box under Create a script for, click Google Chat App.
Note: You can also create a Google Chat app from a template. To do so, navigate to the App Script homepage. Select Getting Started from the sidebar menu. Scroll down the list of templates until you find the Chat App card.
Apps script JSON
Currently...
{
"timeZone": "America/Los_Angeles",
"dependencies": {
},
"chat": {}
}
Update to...
{
"timeZone": "America/Los_Angeles",
"dependencies": {
},
"chat": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
The above includes exception login and runtime version that comes standard with the manifest file now.
Create a new Google Cloud Console project - Steps
Items 3 and 4 need updating:
- Click on the menu icon +icon+ in the upper left and navigate to APIs & Services > Credentials. Click on the OAuth consent screen tab (direct link).
- In the field Application name enter "Attendance Bot" and click the Save button at the bottom.
- Click on the menu icon +icon+ in the upper left and navigate to APIs & Services > OAuth consent screen tab (direct link).
- For this tutorial select User type as 'Internal' and select Create
- In the App name field enter "Attendance Bot".
- In the User support email field use the dropdown menu and select your email.
- Scroll down to the bottom of the page and in the Email addresses field under the Developer contact information header, enter your email address.
- Click Save and continue.
- Back in the App Script Editor, click Resources > Cloud Platform project.
- Back in the Apps Script Editor, select Project Settings +icon+ from the sidebar menu.
- Scroll down to the Google Cloud Platform (GCP) Project section. Select Change project.
To publish your Chat app to Google Chat, do the following
- From the Apps Script editor, get the deployment ID for the script by clicking Publish > Deploy from manifest.
- In the Deployments dialog box, click Get ID.
- In the Deployment ID dialog box, copy the value listed for the Deployment ID. Click Close and Close to dismiss the dialog boxes.
- From the Apps Script editor, get the deployment ID for the script by clicking on Deploy > New deployment (Top-right).
- Click the Select Deployment cog icon ++icon++ and select 'Add-on'.
- In the Description dialog box, type 'Initial deployment'.
- Click Deploy.
- Select Copy to copy the Deployment id and click Close.
.. continue from item 4.
8.4. Under Functionality, select App can be messaged directly.
10.4. Under Functionality, select Receive one-to-one messages.
8.6. Under Permissions, select Specific people and groups in your domain. In the text box under the drop-down menu, enter your email address associated with your Google Workspace organization.
10.6. Under Permissions, select Specific people and groups in your domain. In the text box under the options menu, enter your email address associated with your Google Workspace organization.
8.7 Click Save changes.
10.7. Click Save.
After you save your changes, verify that the status on the Google Chat API page shows the App Status to be LIVE – available to users.
After you save your changes, verify that the status on the Google Chat API page shows the App Status to be LIVE – available to users at the top of the Configuration section of the page.
Test the Chat app
- Open Google Chat{:.external target="_blank"}.
Just a typo on this item at the end here.
- Open Google Chat.
Green note reads:
Note: The code for this Chat app logs the event objects received from Google Chat. You can look at the structure of the event objects by viewing the logs. To open the logs, in the Apps Script editor click View > Stackdriver Logging.
This section will trigger the ADDED_TO_SPACE event but will result in errors when a user adds a message to the chat because, at this stage in the tutorial, onMessage() had not been created yet. It might be a good idea to highlight this so that there is no confusion.
The GitHub code for Step-5 does not provide the global variables for the HEADER until Code 6, but it is displayed in the code lab and is required to run the sample at that stage.
Test the Chat app
You will need to create and deploy a new version of the current deployment here.
To test this app, simply go back to your direct message with the app in Google Chat and type a message (any message will do).
To test this app,
- Go back to the Apps Script Editor.
- Select Deployment > Manage deployments.
- Select the Edit pencil icon ++icon++ (Top-right of dialog) to update the Configuration.
- Change the Version drop-down to 'New version'.
- In the Description text input field type 'Update With Cards'.
- Click Deploy.
- Head back to Google Chat and type a message (any message will do).
Finally, you need to enable the Gmail Advanced Service in the project. To enable the Gmail API, do the following:
Needs a rewrite for new IDE.
- Click Resources > Advanced Google Services.
- In the list, find Gmail API and select on.
- Still in the dialog box, click the link Google Cloud Platform API Dashboard below that opens the Google Cloud Console.
- Click Enable APIs and Services.
- Search for ‘Gmail API' and click the Gmail API card.
- On the Gmail API page, click Enable.
- Select the plus button ++icon++ in Servies in the sidebar.
- In the list, find Gmail API and click to select it.
- Select Add.
- From the sidebar, select the Project Settings icon ++icon++
- Under the Google Cloud Platform (GCP) Project header select the Project number to open Google Cloud Console
- From the GCP console sidebar select Apis and services > Library
- Search for ‘Gmail API' and click the Gmail API card.
- On the Gmail API page, click Enable.
- Go back to the Apps Script Editor.
- Select Deployment > Manage deployments.
- Select the Edit pencil icon ++icon++ (Top-right of dialog) to update the Configuration.
- Change the Version drop-down to 'New version'.
- In the Description text input field type 'Include buttons'.
- Click Deploy.
- Head back to Google Chat and type a message (any message will do).
Note: If you are asked to provide access to the app, you may have to type your message a second time.
This probably needs expanding on. Also note, when authorisation is required the auth card does not pop into the chat and you must scroll down to see it.
Should the note also be in Green?
Note: On the first time you run the app, you may get a 'Attendance Bot requires configuration' warning message. This is because the app now accesses both the Calendar and Gmail APIs and needs the user's permission to access these scopes. Click Configure and authorise these scopes.